Control of externally loaded child movieclip timeline from parent
So I've spent the last couple of days digging around on this, hope someone here can help.
I have a basic xml driven portfolio. The xml file holds the path to the portfolio pieces (external .swfs). I have a main navigation that moves from project to project and a subnavigation to view individual pages of that project.
The subnav is where I have the problem, I simply want to call gotoAndPlay("framelabel") of the designated mc. It seems that you can no longer call to the timeline of child movieclips as you could with AS 2. I've found some examples such as (http://code.google.com/p/as3-display-list-library/) that kind of help. Except the examples discuss access of nested movieclips on the stage with assigned instance names.
But the problem I'm facing is that I have each item pulled in via the loader Class then the objects are pushed into an array and my subnav needs to access them dynamically via array notation.
something like this:
PHP Code:
public function loadMe(){
//var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
for (var a:int = 0; a < xmlParser.Images.length; a++){
myRequest = new URLRequest(xmlParser.Images[a]);
l.load(myRequest, myContext);
loadArray.push(l);
}
}
then later where my subNav is called I thought it would be something like:
PHP Code:
function subFwd(e:MouseEvent):void{
trace("getClickedWithIt: "+_nr);
trace("loader array "+loadArray[_nr]);
MovieClip(loadArray[_nr].content).gotoAndPlay("screen_1");
}
I believe I've done what you're asking. In my case, I've declared a variables as a global variable and pass the event results to it. Although this is only part of my code, it should elaborate what I'm doing. You should be able to do the same thing is you push all items to an array
Code:
public var courseware:MovieClip;
/* .... */
l.load(new URLRequest(moviepath));
l.contentLoaderInfo.addEventListener(Event.COMPLETE, onMovieComplete);
this.addChild(l);
/* .... */
private function onMovieComplete(e:Event):void
{
courseware = e.target.content;
}
private function someOtherFunction():void
{
courseware.gotoAndStop(2);
}
Hope this helps out.
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
I've been wrestling with it. I can control the timeline of a single movieclip but am having trouble later access the timeline of each mc by using array notation.
what is _nr in your code above? it seems like you've got the right idea, to me, except why don't you go ahead and push the content into your array instead of the loader instance?
Thanks. _nr is just the var keeping track of which number is currently registered. so as the slides progress from one to the other _nr is added to or subtracted from. that way I can have one function to control the timelines of each mc through the subnav.
I tried pushing the loader.content into the array, but when the images were built on screen for some reason it only displayed the last one rather then all 9 I currently have in there... which is probably a separate problem.
You must just have a bug of some sort affecting your app. What you're doing makes sense to me. You appear to have a variable reference to your movieclips at each slot in your array, so just casting the array element as MovieClip and then calling the gotoAndPlay method should do what you need.
Maybe you could post the .fla? Or keep trying to debug your code...
so I kinda rewired and started from scratch, still coming up against the same issue though. My array should be pulling in each of the external files and placing them on stage one below the other and jumping to the proper frame label of each. But for some reason it keeps pulling in only the last.
Thanks for any help out there.
the file loader.fla is the base. loader.as is where the code lives. the external assets are all named external... swf
ah, i see what you're doing wrong. you need to create more than one Loader instance. From the Flash docs:
As the Loader object can contain only a single child, issuing a subsequent load() request terminates the previous request, if still pending, and commences a new load.
So the reason the last one is the only one that is loading is because you're calling the load method again on the SAME Loader. You should create your loader instances dynamically in your loop, and then assign each a COMPLETE handler there, too.
I tried doing something like that and it still didn't come together for me. I'm still hacking my way through understanding the ins and outs of AS3 and if you've got any advice on how I could tidy this up that would be sweet!
i edited your code. see attached .zip and loader.as
basically declared your myLoader inside a function that you call within your loop. this compartmentalizes your code a little better. then you get to the loader instance within your COMPLETE handler by using e.target.loader