Skip to main content
frederich24114883
Inspiring
July 27, 2018
Answered

.swf PARENT and .swf CHILD (loader) - root/goto

  • July 27, 2018
  • 1 reply
  • 808 views

Hello,

(excuse my bad english)

I load a .swf Child from a .swf Parent with this code :

------------

var conteneurImage1:Loader = new Loader();

var image1:URLRequest = new URLRequest("URLadress");

conteneurImage1.load(image1);

this.addChild(conteneurImage1);

------------

When the Child is loaded, I want to create a button that goes to the parent instance in position 3. I write this :

------------

bouton2.addEventListener(MouseEvent.CLICK, bouton2d);

function bouton2d(event:MouseEvent):void

{MovieClip(root).gotoAndStop(3);}

------------

It does not work !

I try with "{MovieClip(parent.parent).gotoAndStop(3);}" or "{MovieClip(parent.parent).gotoAndStop(3);}"... Nothing !

The player goes to the position 3 at the Child. It stays in the Child.

I thank you VERY MUCH to help me.

This topic has been closed for replies.
Correct answer frederich24114883

you can use external swfs but code to control them should be in the main (loading) swf.


Thank you for your help.

If I have well understood. I can control the buttons in the clip-Child, from the clip-Parent. The bouton1 is in the clip-Child.

I try this, but it doesn't work. Where's my mistake ? This code is in the clip-Parent :

----------

var conteneurImage1:Loader = new Loader();

var image1:URLRequest = new URLRequest("URL/childa.swf");

conteneurImage1.load(image1);

this.addChild(conteneurImage1);

MovieClip(conteneurImage1.content).bouton1.addEventListener(MouseEvent.CLICK, bouton1d);

function bouton1d(event:MouseEvent):void

{MovieClip(this.parent.parent).gotoAndStop(1);}

MovieClip(conteneurImage1.content).bouton2.addEventListener(MouseEvent.CLICK, bouton2d);

function bouton2d(event:MouseEvent):void

{MovieClip(this.parent.parent).gotoAndStop(3);}

----------

1 reply

kglad
Community Expert
Community Expert
July 27, 2018

where's the goto code?

frederich24114883
Inspiring
July 27, 2018

This code is in the .swf Child (root) . In red, you can find the goto code.

bouton2.addEventListener(MouseEvent.CLICK, bouton2d);

function bouton2d(event:MouseEvent):void

{MovieClip(root).gotoAndStop(3);}

I thank you

kglad
Community Expert
Community Expert
July 27, 2018

what timeline relative to the main timeline?  what timeline is the loader relative to its (the loading swf) main timeline?  and what timeline do you want to direct?

if that code IS on the main timeline of the loaded swf and the loader is on the loading swf's main timeline AND you want to direct the main timeline of the loading swf:

MovieClip(this.parent.parent).gotoAndStop(3);