Skip to main content
Known Participant
June 13, 2009
Answered

CLICK in main timeline >> goes to where click is designated in loaded swf?

  • June 13, 2009
  • 1 reply
  • 927 views

Seems doable, but having trouble grasping the concept...

I have a loaded swf slide show, within that slideshow, I have assigned "next" and "prev" buttons to advance and back up my slide shows via frame labels ("oneIn") for instance... here is an example:

btn_next.addEventListener (MouseEvent.CLICK, nextClick);

function nextClick (e:MouseEvent):void{
    this.gotoAndPlay ("twoIn");
}

I would like this function to run when I click a hit state on the main timeline above it. So, how would I trigger the above function from a click on the hit state on the main timeline?

To help, here is my code for the mouse over function using the hit state that refers to the external buttons:

pNextH.addEventListener (MouseEvent.MOUSE_OVER, nextOver);

function nextOver (e:MouseEvent):void{
    var mc:MovieClip = MovieClip(imageLoader.content);
    mc.btn_next.gotoAndPlay ("nextOver");
}

This topic has been closed for replies.
Correct answer kglad

Actually, just as I am confused a bit... would I need no function descriptor?

Just this line? As opposed to:

pNextH.addEventListener(MouseEvent.CLICK, nextClick);

function nextClick (e:MouseEvent):void{
    var mc:MovieClip = MovieClip(imageLoader.content);
    (mc.content).nextClick
}

I know that is wrong, but do i need a function def for the code you gave me? Or just the one line?


pNextH.addEventListener(MouseEvent.CLICK,MovieClip(yourloader.content).nextClick );


ths code i gave is calling the function nextClick() that's defined on the main timeline of your loaded swf, assuming nextClick() is on the main timeline and yourloader is your loader's reference.

1 reply

kglad
Community Expert
Community Expert
June 13, 2009

you use the loader's content property (cast as a movieclip) to reference the main timeline of the loaded swf:

pNextH.addEventListener(MouseEvent.CLICK,MovieClip(yourloader.content).nextClick);

if nextClick() is on the loaded swf's main timeline.

bamaurerAuthor
Known Participant
June 13, 2009

awesome! thanks, all I needed! good day to you sir.

bamaurerAuthor
Known Participant
June 13, 2009

Actually, just as I am confused a bit... would I need no function descriptor?

Just this line? As opposed to:

pNextH.addEventListener(MouseEvent.CLICK, nextClick);

function nextClick (e:MouseEvent):void{
    var mc:MovieClip = MovieClip(imageLoader.content);
    (mc.content).nextClick
}

I know that is wrong, but do i need a function def for the code you gave me? Or just the one line?


pNextH.addEventListener(MouseEvent.CLICK,MovieClip(yourloader.content).nextClick );