开发者

creating button

I managed to put texts on screen now I want to show the text after the button is clicked but the button does not appear.

Here is the code.

   package 
   {
    import flash.events.MouseEvent;
    import flash.media.Camera;
    import mx.controls.Button;
    import flash.display.Sprite;
    import flash.text.TextField;

    public class test2 extends Sprite 
开发者_JAVA百科    {
           private var tField:TextField;

         public function click(e:MouseEvent):void
         {
            tField = new TextField();
            tField.text="ffff";
            addChild(tField);
        }
           public function test2():void 
           {
            var aa:Button=new Button();
            aa.label="deneme";
            aa.x=100;
            aa.y=200;
            aa.addEventListener(MouseEvent.CLICK, click)
           }
    }
   }


You need to alter the test2 function to actually add the button to the stage:

addChild(aa);


You forgot to add the Child to the stage. After setting the position you still need to do addChild(aa);

 public function test2():void 
           {
            var aa:Button=new Button();
            aa.label="deneme";
            aa.x=100;
            aa.y=200;
            aa.addEventListener(MouseEvent.CLICK, click)
addChild(aa);
           }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜