A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: Control of externally loaded child movieclip timeline from parent

  1. #1
    Senior Member
    Join Date
    Feb 2006
    Location
    Portland OR
    Posts
    138

    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.PROGRESSloop);
                
    l.contentLoaderInfo.addEventListener(Event.COMPLETEdone);
                
                for (var 
    a:int 0xmlParser.Images.lengtha++){
                    
    myRequest = new URLRequest(xmlParser.Images[a]);
                    
    l.load(myRequestmyContext);
                    
    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");
        } 

  2. #2
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    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.

  3. #3
    Senior Member
    Join Date
    Feb 2006
    Location
    Portland OR
    Posts
    138
    hey thanks for the nudge.

    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.

    ???

  4. #4
    flip-flopper scottPadgett's Avatar
    Join Date
    Jan 2005
    Location
    Boston
    Posts
    425
    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?
    :: scott ::

  5. #5
    Senior Member
    Join Date
    Feb 2006
    Location
    Portland OR
    Posts
    138
    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.

  6. #6
    flip-flopper scottPadgett's Avatar
    Join Date
    Jan 2005
    Location
    Boston
    Posts
    425
    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...
    :: scott ::

  7. #7
    Senior Member
    Join Date
    Feb 2006
    Location
    Portland OR
    Posts
    138
    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
    Attached Files Attached Files
    Last edited by knottyDJ; 03-04-2009 at 09:45 PM.

  8. #8
    Senior Member
    Join Date
    Feb 2006
    Location
    Portland OR
    Posts
    138
    just hoping I could cycle this back around and see if anyone can help out...

    ugggh... it just shouldn't be that hard to access an external mc's timeline

  9. #9
    flip-flopper scottPadgett's Avatar
    Join Date
    Jan 2005
    Location
    Boston
    Posts
    425
    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.
    :: scott ::

  10. #10
    Senior Member
    Join Date
    Feb 2006
    Location
    Portland OR
    Posts
    138
    Thanks scottPadget.

    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!
    PHP Code:
    for(var i:int 02i++){
                        
        
    requestArray.push(myRequest);
            
    loaderArray.push(myLoader);
        
    contextArray.push(myContext);

        
    requestArray[i] = new URLRequest(slideArray[i]);
        
    loaderArray[i].load(requestArray[i], contextArray[i]);
        
    loaderArray[i].contentLoaderInfo.addEventListener(Event.COMPLETEcompleteHandler);
                        
     } 
    I'll totally buy you a beer next time I'm in Boston!

  11. #11
    flip-flopper scottPadgett's Avatar
    Join Date
    Jan 2005
    Location
    Boston
    Posts
    425
    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

    cleaner code and it does the trick, too.


    best,

    sp
    Attached Files Attached Files
    :: scott ::

  12. #12
    flip-flopper scottPadgett's Avatar
    Join Date
    Jan 2005
    Location
    Boston
    Posts
    425
    oh and you can just get rid of your var loadedArray:Array = new Array();

    you don't need it, unless you're using it in some other way i didn't see....
    :: scott ::

  13. #13
    Senior Member
    Join Date
    Feb 2006
    Location
    Portland OR
    Posts
    138
    As we say on the west coast, "dude"

    Thank You!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center