dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: can't get swapDepths to work

  1. #1
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165

    can't get swapDepths to work

    hello, i have three movieclips on the _root level, which in order of lowest to highest depth are :
    "test1", "test2", "newParent"

    and then I have a fourth movieclip nested into newParent called newDepth.

    I then draw a rectangle on test1 and test2, such that the rectangle on test2 is above the rectangle on test1.

    I then want the rectangle in test1 to be higher than test2 when I hover over test2.

    So I make test1 swap depths with newDepth when I roll over test2.

    Unfortunately nothing happens.

    I tested it and making a rectangle in newParent makes it above a rectangle in test2.

    I'm using the following code

    code:
    import ui.*;
    //
    //colour
    //
    var blue:Number = 1287332;
    var orange:Number = 13191700;
    var red:Number = 11210768;
    //
    //create clips
    //
    _root.createEmptyMovieClip ("test1", 1);
    _root.createEmptyMovieClip ("test2", 2);
    _root.createEmptyMovieClip ("newParent", 3);
    _root.newParent.createEmptyMovieClip ("newDepth", 1);
    //
    //give the clips some shapes
    //
    shapes.createShape ("rectangle", _root.test1, 0, 0, 200, 200, 0, red, 100, false, false);
    shapes.createShape ("rectangle", _root.test2, 0, 0, 300, 100, 0, blue, 100, false, false);
    //
    //make it so when the mouse rollsover test2, then test1 swaps depth with newDepth so that it is above test2
    //
    _root.test2.onRollOver = function ()
    {
    trace ("giving a new depth to test1");
    _root.test1.swapDepths (_root.newParent.newDepth);
    };



    along with my own shapes class
    (both that code and the class is found in the attached zip)

    so basically, does anyone understand why it isn't swapping depth with newDepth ??

    thnx
    Attached Files Attached Files
    if you find some of my ideas weird, look at my avatar for the reason

  2. #2
    Senior Member mandissected's Avatar
    Join Date
    Jan 2005
    Location
    Berwick - England
    Posts
    338
    how about changing the swap depth to
    Code:
    _root.test1.swapDepths (_root.newParent);

  3. #3
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    The problem I have is that in my project, I have 74 objects under that parent

    and I need some objects to be on different layers than others, so swapping the parent isn't going to work (well, there is one situation where it would)

    though, I think if I seperate them into groups (they are already in groups), and put each group into another movieclip, so it's just [parent [group1 [plugin1, plugin2], group2[plugin1, plugin2], etc] then all I have to do is swap the depths of the group movieclip to move the plugins in that group to the particular layer I want them at....

    though if someone has a way of moving a movieclip from one timeline to another, than that would be really appreciated

    thnx
    if you find some of my ideas weird, look at my avatar for the reason

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