Skip to main content
Known Participant
June 10, 2009
Answered

last and greatest: conditional statements for click referring to loaded swf

  • June 10, 2009
  • 1 reply
  • 810 views

Hey forum,

I am so close to being done with this site update it is exciting! I will be sure to throw it up here for you to see, since without this forum I would have been hurting!

The last big hurdle I have, is the following, and I hope someone can just throw me a bit of guidance on this.

I am looking for a way to write a function, that on click of my "next" button in the main timeline, will refer to my loaded swf MovieClip(imageLoader.content) telling it to go to the next frame label, so really a compound if/then situation – just referring to the loaded file throws me.

So, my next button is "pNext," and what I am looking for is something along the lines of:

if (loaded movie) is on frames 12-144, then go here (on click),

if (loaded movie) is on frames 144-155, then go here (on click)

etc. and so forth.

Thanks so much! Below is my code that works on one next click, so you can see the instances etc.

b

pNext.addEventListener (MouseEvent.CLICK, nextClick);

function nextClick (e:MouseEvent):void{
    MovieClip(imageLoader.content).gotoAndPlay ("aboutS1");
}

This topic has been closed for replies.
Correct answer Ned Murphy

If I'm reading your request right, what you can try is to create an array of the frame labels in the order they appear and use the currentLabel property to determine where you are and indicate where to go...

var labels:Array = new Array("one","two","three","four","five"...etc...);

pNext.addEventListener (MouseEvent.CLICK, nextClick);

function nextClick (e:MouseEvent):void{
    var mc:MovieClip = MovieClip(imageLoader.content);
    var nextLabel:String = labels[labels.indexOf(String(mc.currentLabel))+1];
    mc.gotoAndPlay (nextLabel);
}

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
June 10, 2009

If I'm reading your request right, what you can try is to create an array of the frame labels in the order they appear and use the currentLabel property to determine where you are and indicate where to go...

var labels:Array = new Array("one","two","three","four","five"...etc...);

pNext.addEventListener (MouseEvent.CLICK, nextClick);

function nextClick (e:MouseEvent):void{
    var mc:MovieClip = MovieClip(imageLoader.content);
    var nextLabel:String = labels[labels.indexOf(String(mc.currentLabel))+1];
    mc.gotoAndPlay (nextLabel);
}

bamaurerAuthor
Known Participant
June 10, 2009

that sounds right, perfect – thanks Ned!

Ned Murphy
Legend
June 10, 2009

You're welcome.  Hope it works... it did for me, but I only tested it relative to a main timeline.