4 Replies Latest reply on Jun 26, 2008 6:30 AM by SiHoop

    Delete buttons

    SiHoop Level 1
      I want to delete some AS3 generated buttons. In my AS2 way of thinking, each button is instantiated with a label, so I'm trying to delete each button by using that identifier, but it does not work. What am I doing wrong?
      Thanks!

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application creationComplete="start()" xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Script>
      <![CDATA[
      import mx.controls.*
      private function start():void{
      for(var i:int=0; i < 5; i++) {
      var videoButton:Button = new Button();
      videoButton.label = "Video "+String(i+1);
      videoButton.width = 150;
      videoButton.height = 22;
      hbox1.addChild(videoButton);
      }
      }
      private function deleteButtons():void{
      for(var i:int=0; i < 5; i++) {
      delete "Video "+String(i+1)
      }
      }
      ]]>
      </mx:Script>
      <mx:Canvas x="211" y="183" width="490" height="254" id="canvas1" backgroundColor="#FFFFFF">
      <mx:VBox x="86" y="0" height="100%" width="153" id="hbox1">
      </mx:VBox>
      <mx:Button x="247" y="163" click="deleteButtons()" label="Delete 1, 3, &amp; 5"/>
      </mx:Canvas>
      </mx:Application>