开发者

Timeline navigation buttons inside movieclips

Firstly, apologies if this has been answered elsewhere - believe me I have searched! It requires an incredibly simple solution I'm sure.

I have an MC inside which consists of some images on different frames and some buttons which are supposed to gotoandStop on each of the frames. A simple gallery.

My plan is to create an MC for each gallery on my site and sit each one in a unique frame, so the main navigation btns go to a frame with an MC in it, then the MC buttons navigate within that gallery.

But the buttons aren't working.

Here's the button code inside the MC:

on1_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_5); 

function fl_ClickToGoToAndStopAtFrame_5(event:MouseEvent):void 
{
    gotoAndStop("on1");

}

Note: I've labelled the button instances and frames the same开发者_运维百科 for ease of checking the code, there are multiple buttons here each with the same code except for the change in numbers. I guess there's no need to paste all of them in.

Any help! If you need more info/code don't hesitate to ask.

Many thanks,

Jamie


I'm gathering your buttons aren't on the main timeline. There's a really simple way to access the main timeline from anywhere using this:

MovieClip(root).method();

So for you:

MovieClip(root).gotoAndStop(5);

Also, just for fun - this might be a quicker and neater way to set up multiple buttons with a gotoAndStop action rather than having many, many different functions:

Give your buttons names that end in numbers.. eg goto1, goto6, goto9. Then just add them to the Array at the top of this:

var buttons:Array = ["goto1","goto6","goto9"]; // <--- here

var i:String;
for each(i in buttons)
{
    this[i].addEventListener(MouseEvent.CLICK, goto);
}

function goto(e:MouseEvent):void
{
    var sb:SimpleButton = SimpleButton(e.target);
    var num:uint = uint(sb.name.substr(sb.name.length-1, 1));

    trace(num);
    gotoAndStop(num);
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜