寻找actionscript 3.0的按钮命令

时间:2011-04-29 13:57:39

标签: flash actionscript button flash-cs5

我是动作脚本3.0的新手,目前正在进行Flash演示。除了按钮之外全部完成,我不知道如何使用actionscript 3.0。我有很多按钮,但我需要的是使按钮(点击时)进入另一个场景的命令,并重播它所在的场景。

由于

2 个答案:

答案 0 :(得分:3)

如果你在舞台上有一个按钮,那就说叫button0,然后:

button0.addEventListener("click", button0Clicked);

function button0Clicked(evt:*):void
{
     //do whatever you want to do here
}

还有其他一些事件,只需点击更改为mouseDownmouseUpdoubleClickmouseOvermouseOut。我认为这些类型不言而喻。

如果您使用双击,则必须将doubleClickEnabled设置为true

button0.doubleClickEnabled = true;

知道也很有用:

button0.buttonMode = true;
button0.useHandCursor = true;

如果button0不是Button实例,而是MovieClip实例,并且您希望当鼠标悬停在按钮上时鼠标变成“手”。

我希望这可以帮助您更接近目标。

答案 1 :(得分:0)

 import flash.events.MouseEvent;
 //use stop in the begin to avoid the repeat frames again
 stop();

//here i have play button is play_mc if it click then it goes to the 
 function GameStart

mc.play_mc.addEventListener(MouseEvent.CLICK, GameStart);
mc.play_mc.useHandCursor = true;
mc.play_mc.buttonMode = true;

function GameStart(event:MouseEvent):void
{
 //gotoAndPlay by using to go to the frame Gameplay is the frame name it 
   goes to that frame

   gotoAndPlay("GamePlay");
}

如果您想了解更多信息,请访问此处并了解http://www.adobe.com/devnet/flash/articles/accessible_animated_preso.html