samedi 21 novembre 2015

Remove multiple sprites from stage AS3

I've created a list of sprites (to hold textfields), how would I remove all the created sprites?

creating the sprites:

    for (var i:int = 0; i < optionsArray[currentChoicePart].length; i++) 
    {
        var txt:TextField = new TextField();
        txt.defaultTextFormat = new TextFormat('Verdana',15,0xFFFFFF);
        txt.text = optionsArray[currentChoicePart][i];
        txt.filters = [stroke];
        txt.autoSize = TextFieldAutoSize.LEFT;
        txt.selectable = false;
        txt.width = 400
        txt.height = 25
        var btn:Sprite = new Sprite();
        btn.mouseChildren = false;
        btn.addChild(txt); 
        btn.buttonMode = true;
        btn.x = stage.stageWidth / 10
        btn.y = stage.stageHeight / 2 - 50 * (i * .5)
        btn.name = "p" + String((Number(currentPart.substring(1)) + (i+1)))
        stage.addChild(btn)
        btn.addEventListener(MouseEvent.CLICK, function m(zen:MouseEvent) // when button is clicked 
        {
            choice(zen.currentTarget.name)

        } 
        )
    }

Aucun commentaire:

Enregistrer un commentaire