开发者

Staying put on a frame label

I am trying to use buttons to jump to frame labels. They jump to the label just fine, but they won't stop when pressed again. Below is the code I am using to have the button rest when pressed again.

getting_btn.addEventListener(MouseEvent.CLICK, gettingStarted);

function gettingStarted(evt:MouseEvent):void {
gotoAndPlay("ipad_in");
if (this.currentLabel == "ipad_rest"){
this.g开发者_如何学GootoAndStop("ipad_rest");
}
}


On the following line you are testing the frame name for "ipad_rest" but on the line before you set the frame to "ipad_in" so in effect the currentLabel will never be "ipad_rest"

gotoAndPlay("ipad_in");
if (this.currentLabel == "ipad_rest"){// will never be true

Not tested but this should be about what you want it all depends on if "ipad_in" is still the active frame . You were vague on your description.

function gettingStarted(evt:MouseEvent):void {
  if (this.currentLabel == "ipad_in"){
    this.gotoAndStop("ipad_rest");
  }else{
    gotoAndPlay("ipad_in");
  }
}


Duh have to flip flop them so it checks label first and then goes to desired frame label.

function gettingStarted(evt:MouseEvent):void 
{
   if (this.currentLabel == "ipad_rest")
      this.gotoAndStop("ipad_rest");
   else
      gotoAndPlay("ipad_in");
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜