Controling a loaded swf with another loaded swf

Participant ,
Mar 18, 2008 Mar 18, 2008

Copy link to clipboard

Copied

I have a blank stage with only AS that loads an swf addChildAt(0) and a second one addChildAt(1). This works. When the user interacts with (1) it calls another addChild (not indexed) and possibly that one loads another, depending on the choices made by the user. How can I get any of these to control that very first child that was loaded at (0)? I have run out of ideas.

Some of the code:

(on the main swf, nothing on the stage, only code that loads the next two)

addChildAt(pHolder, 0);
pLoader.load(pURLReq);
pLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, pLoaded);

and for the second:

addChildAt(mHolder, 1);
mLoader.load(mURLReq);
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, mLoaded);

On the child of childAt(1), I have:

function replaceSWF(e:MouseEvent):void
{
pLoader = new Loader();
pLoader.load(new URLRequest("p.swf"));
pLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, placeNewClip);
}

function placeNewClip(e:Event):void
{
removeChildAt(0);
addChildAt(e.target.content, 0);
}


If I use this exact same code from that very first swf, the one that loads the first two external swfs, it works, but once I put it on one of hte other loadeds and sub loaded swfs, I can't get it to work. In the current state (0) it just makes everything on the stage disappear, so I figured then using the index of (1) would do it, but that or any other number results in absoluly nothing.

Help! I am really out of ideas here.

(the stacking looks like this) ---
sub second loaded SWF <==== needs to tell first loaded SWF to unload then load a new swf at same index
second loaded SWF <==== loads the next one above
first loaded SWF <=== needs to be removed and another swf loaded at the same index
mainSWF (loads two others) <=== code placed here works for first loaded SWF
TOPICS
ActionScript

Views

149

Likes

translate

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
Adobe Community Professional ,
Aug 05, 2020 Aug 05, 2020

Copy link to clipboard

Copied

hi there,

 

its been a while since I programmed loading or swapping SWFs, but the level 0 movie always controlled the main movie, you if you swap that it makes sense that you would lose the other two loaded SWFs. I used to load my movies into Movieclips, since then I could control the movieclip with the new movie inside of it. And I can control the stacking order as well....

but maybe you can try creating a new movie that in frame 1 loads your level 0 movie, but load it on level 1, then have everything else load on level 2. Then you should be able to swap out the level 1 movie. 

Or try loading your movies into a movieclip. I used to place an invisible button at the same size of the movie inside the movieClip so I know what size to expect to load and I can use it to place my items and then scale or control it in anyway I like.

 

Hope this helps!
cheers,

mark

headTrix, Inc. | Adobe Certified Training & Consulting
Consulting | Design | Development | Training

Likes

translate

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