当前位置: 动力学知识库 > 问答 > 编程问答 >

actionscript 3 - I am missing my button

问题描述:

I tried to add a SimpleButton...

public class Main extends Sprite

{

public function Main():void

{

if (stage) init();

else addEventListener(Event.ADDED_TO_STAGE, init);

}

private function init(e:Event = null):void

{

removeEventListener(Event.ADDED_TO_STAGE, init);

// entry point

var btn:SimpleButton = new SimpleButton();

this.addChild(btn);

But it is nowhere to be found. Any help?

网友答案:

A SimpleButton needs DisplayObjects (Sprites, for instance) in its constructor. If you don't specify any, it will not have anything to show.

from the manual:

SimpleButton(upState:DisplayObject = null, overState:DisplayObject = null, downState:DisplayObject = null, hitTestState:DisplayObject = null)
分享给朋友:
您可能感兴趣的文章:
随机阅读: