A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: How do I make a swf the parent of others?

  1. #1
    Member
    Join Date
    Jun 2007
    Posts
    61

    How do I make a swf the parent of others?

    Hi There,

    I currently have three swf files: master.swf, navigation.swf and portfolio.swf. master.swf is essentially a background, navigation.swf is made up of four animated movieclips that I am using as buttons and portfolio.swf contains a simple coloured block.

    I have loaded navigation.swf into my master file successfully, but I am having trouble loading my portfolio.swf into the master via the navigation.swf.

    I am trying to use the image loader in my master file so that i can specify a level for the swf to display on beneath my navigation.swf, which I want to always remain on screen at the top of the stacking order.

    To use the imageloader of the master file while writing code in the navigation file do I have to link them in a parent/child relationship somehow? If so how do you do this?

    Here is the code in my master.fla:
    Code:
    var nav_btnsRequest:URLRequest = new URLRequest("navigation_btns.swf");
    
    var nav_btnsLoader:Loader = new Loader();
    nav_btnsLoader.load(nav_btnsRequest);
    
    addChildAt(nav_btnsLoader, 1);
    and here is the code that I have tried to use in my navigation.fla to load the portfolio into the master file once the relevant button is clicked:
    Code:
    stop();
    
    pin_01.addEventListener(MouseEvent.CLICK, onClick_01);
    
    function onClick_01(event:MouseEvent):void
    {
    	pin_01.play();
    	var portfolioReq:URLRequest = new URLRequest("portfolio.swf");
    	Loader(root.parent).load(portfolioReq, 1);
    }
    Any ideas what i should try? Thanks all

  2. #2
    Member
    Join Date
    Jun 2007
    Posts
    61
    ok i think i may have solved this myself but it has spawned a new question. I have added a new image loader on my navigation.swf and loaded the portfolio swf into that. this then works fine in my master.swf.

    However, how can I change the stacking order of the swfs so that the navigation swf is on level 1 and the new loaded portfolio swf is on level 0?

    Here's the rewritten bit of code:
    stop();

    var imageLoader:Loader = new Loader();

    pin_01.addEventListener(MouseEvent.CLICK, onClick_01);

    function onClick_01(event:MouseEvent):void
    {
    pin_01.play();
    var portfolioReq:URLRequest = new URLRequest("portfolio.swf");
    imageLoader.load(portfolioReq);
    addChildAt(imageLoader, 1);
    }

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