A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Help with swapDepths (AS2)

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    15

    Help with swapDepths (AS2)

    I am a Flash newbie and I am trying to create a Flash with a bunch of people layered on the screen and when you rollover the person, you see their name and a description. The problem is that because the people are layered, the names and descriptions were falling behind the other buttons on rollover, so I turned all of the buttons into MCs and then added the following AS to the buttons:
    on (rollOver) {
    this.swapDepths(1000);
    }

    This works great for bringing the button and the rollover text to the forefront, but now what I want is to have the person go back to the back on rollOut. I've tried experimenting with the AS and I can't figure out how to send them back on rollout. Any ideas?

  2. #2
    Junior Member
    Join Date
    Jan 2010
    Posts
    15

    Nevermind

    I think I posted this too soon...I did this and it worked:
    on (rollOut) {
    this.swapDepths(-1000);
    }

    Just in case it can help anyone else!

  3. #3
    Junior Member
    Join Date
    Jan 2010
    Posts
    15

    Oops

    Again, I replied too soon...they're still jumping all around...They seem to switch depths randomly, not just on rollover and rollout.

    Can anyone help? Is there AS I should be using instead?

  4. #4
    Senior Member
    Join Date
    Dec 2009
    Posts
    109
    Put all of your characters depths into an array. Look up a formula to find the least value in an array. Use swap depth to make the MC 1 depth level lower than the lowest depth level detected in the array.

    Also, you could just use the code:
    on (rollOver) {
    this.swapDepths(_root.getNextHighestDepth());
    }
    Syntax Error

  5. #5
    Junior Member
    Join Date
    Jan 2010
    Posts
    15

    Thank you

    That is helpful for the rollover portion, but what would I do for rollout so that the person goes back when you're no longer hovering over them with the mouse?

  6. #6
    Senior Member
    Join Date
    Dec 2009
    Posts
    109
    Put all of your characters depths into an array. Look up a formula to find the least value in an array. Use swap depth to make the MC 1 depth level lower than the lowest depth level detected in the array.
    And put it all under an on (rollOut) function.
    Syntax Error

  7. #7
    Junior Member
    Join Date
    Jan 2010
    Posts
    15

    Thanks

    I wish I knew how to do what you are talking about! Since I am such a noob, can you point me to any tutorials on setting up arrays with swapDepths or give me a bit more detail on how to do that?

    Thanks SO MUCH again!

  8. #8
    Senior Member
    Join Date
    Dec 2009
    Posts
    109
    Are you writing the code within a movie clip, or on the main timeline? Before you can easily use array to contain variables, all the code must be on the main timeline. It would be helpful to see the .fla.

    Either way, I'll make a .swf file to show you how arrays work.

    I'll edit this post when I'm finished with it.
    Syntax Error

  9. #9
    Junior Member
    Join Date
    Jan 2010
    Posts
    15

    FLA file

    Adam - Thanks again for all your help! I can email you the FLA, but I can't post it on here because it has proprietary information and photos of people who signed very specific releases for how they're photos are to be distributed. Can you send me your email address?

    Thanks again!

  10. #10
    Senior Member
    Join Date
    Dec 2009
    Posts
    109
    Syntax Error

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