• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Load..attach and unload question

Participant ,
Jul 29, 2012 Jul 29, 2012

Copy link to clipboard

Copied

Hello forum members:

1) I have a main movie that loads an external movie with this code:

var loader:Loader = new Loader();

    loader.load(new URLRequest("lessons/lessona/lessona.swf"));

    addChild(loader);

    loader.y=0;

    var myTween:Tween = new Tween(loader, "x", Strong.easeIn, 1500, 0, 1, true);

2) The loaded movie attaches a movieclip from the loaded movieclip library with this code:

var mc:alert_mc=new alert_mc();

    mc.x=320;

    mc.y=210;

    addChild(mc);

3) From the attached movie clip I am trying to remove the attached clip and the loaded movie (and return to my main movie) with this code when the user clicks yep_btn but it is unsucessful (it does not unload or return me to my main movie)

nope_btn.addEventListener(MouseEvent.CLICK, cancelunloadexitb);

yep_btn.addEventListener(MouseEvent.CLICK, unloadexitb);

function cancelunloadexitb(e:MouseEvent):void {

    this.parent.removeChild(this);

}

function unloadexitb(e:MouseEvent):void {

    Loader(this.parent).unloadAndStop();

}

How do I get back to my main movie? Any ideas... Thank you

TOPICS
ActionScript

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Jul 30, 2012 Jul 30, 2012

Trace the chain to see where you are... if the buttons are in the attached library clip then their parent is the clip, and parent.parent should be the lessona swf. So, try something like so until you derive the right object:

function cancelunloadexitb(e:MouseEvent):void {

   trace(parent);

   trace(parent.parent);

   //etc

}

Votes

Translate

Translate
LEGEND ,
Jul 29, 2012 Jul 29, 2012

Copy link to clipboard

Copied

If mc is a child of lessona.swf, then its parent is not the Loader.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 29, 2012 Jul 29, 2012

Copy link to clipboard

Copied

mc is a child of lessona.swf.

How can I access the Loader of lessona.swf from the mc child?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 30, 2012 Jul 30, 2012

Copy link to clipboard

Copied

Trace the chain to see where you are... if the buttons are in the attached library clip then their parent is the clip, and parent.parent should be the lessona swf. So, try something like so until you derive the right object:

function cancelunloadexitb(e:MouseEvent):void {

   trace(parent);

   trace(parent.parent);

   //etc

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 30, 2012 Jul 30, 2012

Copy link to clipboard

Copied

The trace generates this:

[object MainTimeline]

[object Stage]

It does not trace from the main Movie only from the loaded movie

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 30, 2012 Jul 30, 2012

Copy link to clipboard

Copied

LATEST

Thank you. You led me in the right direction.

I used this: Loader(this.parent.parent).unloadAndStop();

Also very important not to have two movieclips with same name in library

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 30, 2012 Jul 30, 2012

Copy link to clipboard

Copied

If mc is a child of the loaded swf, then the loaded swf is the parent of the child.  If the code that is trying to target the Loader is in the mc timeline, then the Loader should be one parent away from the swf, so 'parent.parent' should target the loader

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines