dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Actionscript and Layers

  1. #1
    FLash Beginner
    Join Date
    Jul 2007
    Location
    Netherlands
    Posts
    15

    Actionscript and Layers

    So I'm still making this shooting game, and I got a few different kind of movie clips:
    the mouse cursor (aim visor), bullet holes, and targets. All these movie clips have a linkage to actionscript, where they are created multiple times.
    Now ideally I want the mouse cursor to always be on top, after that the bullet holes and the targets on the background. Currently I am doing this with AddChildAt(), but it's giving me some problems, since I also want to RemoveChildAt() for the bullet holes if there are too many on the screen. I can probably do all this if I keep track of index numbers of the bullets and the targets, but isn't there a way I can attach a movie clip to a layer? That would make more sense and isn't much hassle for me.

  2. #2
    Amazed and Amused Mazoonist's Avatar
    Join Date
    Mar 2006
    Location
    Northern California
    Posts
    201
    The clip that you want to be on top: At the point in the code where you want it to be on top, just issue this command again: addChild(clip). For a clip that's not in the display list, that command would add it. For a clip that's already in the display list, it'll bring it to the front.

  3. #3
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Also, instead of adding directly to the same object, you can add empty sprites as containers.

    pseudocode:
    Code:
    var mouselayer:Sprite;
    var bulletlayer:Sprite;
    ...
    addChild(mouselayer);
    addChild(bulletlayer);
    ...
    mouselayer.addChild(mouseclip);
    bulletlayer.addChild(bullet);
    ...
    That should allow you to simulate layers.

  4. #4
    FLash Beginner
    Join Date
    Jul 2007
    Location
    Netherlands
    Posts
    15
    Ok, thank you both, I think I can manage now.

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