A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Assigning depth to movie clip...

  1. #1
    Registered User
    Join Date
    Jul 2000
    Posts
    88

    Assigning depth to movie clip...

    I have a simple looping .fla which runs through a 3 frame loop, and each time through the loop duplicates a movie clip via:

    _root.tile.duplicateMovieClip("tile"+i,i+1)

    The actions are added into keyframes on the main timeline. That works fine.

    But, whenever I add anything else to the stage, be it some text in another layer (even if put in above the a/s for the looping), the duplicated m/cs generated via the loop always appear above any other content.

    I know that this is to do with the depth of the instances of the m/cs.

    Please can someone advise as to how to add any new content onto the stage, and for that to appear on top of the duplicating m/cs. I have tried working out how to assign a depth level to the new content, but cannot work it out.

    Thanks

    Jim

  2. #2
    Iron Chef In-Training OpethRockr55's Avatar
    Join Date
    Sep 2005
    Location
    Kitchen Stadium
    Posts
    313
    First off, dynamic objects ALWAYS take over staged objects (they might if they have negative depths, but I'm not sure, I've never used them). You might have to make your main timeline an MC and load it dynamically to a depth higher than what you say for your regenerating MC.
    code:
    if (i>1000) {
    i = 0;
    }


    This would put your next MC over 1000 at the bottom, so don't use it. Period. Unless you don't care, then go ahead.

    One other option would be to add a code to your regenerating MC to also put the MC, the one you want on top, on top.
    code:
    _root.createEmptyMovieClip("Trashmc", i+2);
    StuffNeededMC.swapDepths ("Trashmc");


    Haven't tested it, but it looks okay. Repost if you have any problems, which I'm guessing you will with my cruddy coding. You shouldn't need to delete the Trashmc as the regenerating MC will just cover it anyways next time it does regenerate, so it creates a nice loop of swapping.
    Last edited by OpethRockr55; 11-06-2005 at 09:26 PM.

  3. #3
    Junior Member
    Join Date
    Nov 2005
    Posts
    3
    Hi - I had to set up a new acct. as my old one has been disabled for some reason. Anyway, I tried your suggestion but unfortunately it didn't work. Not sure why!

    Thanks

    Jim

  4. #4
    Iron Chef In-Training OpethRockr55's Avatar
    Join Date
    Sep 2005
    Location
    Kitchen Stadium
    Posts
    313
    Yeah, it turns out the swapDepth threw the it off. I made some minor adjustments and threw it into a .fla for you to look at. Everything is done from the main timeline, so just look for the code there. When you see the code that attaches the StuffNeeded MC, that is the exact code for infinite replicating MCs. If you want to have a set limit of MCs, just replace the i+1 depth to one more than your limit of MCs, in my .fla's case that depth would be 1001. Hope this helps.
    Attached Files Attached Files

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