A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Swap Depths, but... don't...

  1. #1
    Junior Member
    Join Date
    Jul 2008
    Posts
    3

    Swap Depths, but... don't...

    OK - I haven't had much luck with help here lately, but I know if anyone can help me, it's you guys. You don't have to write the code for me, I just need to know what to research:

    I'm putting movie clips on the stage physically, not calling them with actionscript and using the Child functions, so I'm having an awful time moving them around. I'd like for them to be able to swap depths or appear to swap depths. Currently, I'm making a hell of a mess masking the ones to appear in back when they're not supposed to be "in the foreground". There are 5. I'd like to click, one zooms to the back and the one clicked comes to the front. Using something similar to below. One state for "off = appear in back", one for "fill = fill the space so it doesn't look cut" and "on = appear to be in the front".

    Actionscript Code:
    waterHold.addEventListener(MouseEvent.CLICK, oneMove);
    function oneMove(event:MouseEvent):void {

        if      (waterFront=="off"){ waterHold.gotoAndPlay("bringWater") }
        else if (waterFront=="on"){ null }
        else if (waterFront=="fill"){ waterHold.gotoAndPlay("bringWater") }

        if      (soulFront=="off"){ soulHold.gotoAndStop("fillSoul") }
        else if (soulFront=="on"){ soulHold.gotoAndPlay("sendSoul") }
        else if (soulFront=="fill"){ soulHold.gotoAndStop("fillSoul") }

        if      (bodyFront=="off"){ bodyHold.gotoAndStop("cutBody") }
        else if (bodyFront=="on"){ bodyHold.gotoAndPlay("sendBody") }
        else if (bodyFront=="fill"){ bodyHold.gotoAndStop("cutBody") }

        if      (mindFront=="off"){ mindHold.gotoAndStop("fillMind") }
        else if (mindFront=="on"){ mindHold.gotoAndPlay("sendMind") }
        else if (mindFront=="fill"){ mindHold.gotoAndStop("fillMind") }

        if      (oppFront=="off"){ oppHold.gotoAndStop("fillOpp") }
        else if (oppFront=="on"){ oppHold.gotoAndPlay("sendOpp") }
        else if (oppFront=="fill"){ oppHold.gotoAndStop("fillOpp") }

    }


    Can anyone help at all? Should I use alpha and make all separate MCs? Or is the a sort of swap depths I can use without calling them with AS? You don't have to write the code for me, I just need to know what to research.

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    I don't understand "fill". Fill what space? It looks like you have each of your states implemented as frames in your xHold clips, which is fine. If you are talking about which ones appear in front of which others, then you need to look at the order they are in as display siblings.
    All children of a display object are rendered back to front, with the child at 0 the furthest back. So to move something to the very back, use addChildAt(item, 0). Obviously, call that method on the same parent it currently has. That will automatically re-arrange all the other children's display order so that they still go from 0 to numChildren-1.

    To add a child to the front, simply use addChild(item). That will put it on top of any other children of the same parent.

    Since a display object can only be on the displaylist once, using addChild works even for things that are already on the display.

  3. #3
    Junior Member
    Join Date
    Jul 2008
    Posts
    3
    Very helpful, thank you very much.

    I was referring to the need to fill the space left unoccupied after a masked object swooped to the front. Picture three objects stacked, but the "back" one is really on top, but masked to not overlap the others:

    _| | |
    __| |
    ___|

    then the middle one moves and you have:

    _| |
    |
    ____|

    So you have to fill the space where the middle one was with the front one, appearing in back. =o) This is why I said I'm making a mess. Thank you. 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