A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Strange swapDepths() problem

  1. #1
    His Flashy Highness
    Join Date
    Aug 2001
    Location
    SF Bay area
    Posts
    56
    Hi.

    I'm having a collection of movieClips that are all created using createEmptyMovieClip and then get drawn using the drawing api. They got names and I put them all into different levels. I remember the highest level I use so that I can do a swapDepths on them when I drag them around.

    I do a _root[name].swapDepths(topLevel); where topLevel is a variable containing the highest level I've used for these clips.

    It's pretty straightforward and exactly the same code I use in another project. There it works just fine. Only here - nothing happens. The MCs never swap depths. They just sit there.

    Does anybody know if MCs that are created using createEmptyMovieClip and then get drawn using the drawing api behave differently (in respect to stacking order) than MC instances from a duplicateMovieClip?

    Any hints would be highly appreciated.

    Thanks,

    Juggle5

  2. #2
    Senior Member
    Join Date
    Sep 2001
    Posts
    178
    Hi,
    I have had a similar problem, and I figured out that the problem is that the movie clip draws the stuff (when you use the Drawing API) in the holder of the movie clip. I.E., if the movie clip is in the root timeline, then it draws in the root timeline. The only way I have figured out to control this is to createEmptyMovieClip within the already created one, then use that second one to draw the lines within the first one. Hope this helps, Chuckles8421

  3. #3
    Danny Gomez Creations ® cosmiceye's Avatar
    Join Date
    Mar 2002
    Location
    under a palmtree in Jamaica waiting for psytopia 2005 to begin
    Posts
    982
    Yeah, it seems that it only uses the mc as a cordinator to start drawing. try using msome code from your previus project, duplicating an empty mc instead of creating new ones. Anyway, this is friggin odd...

  4. #4
    His Flashy Highness
    Join Date
    Aug 2001
    Location
    SF Bay area
    Posts
    56
    Originally posted by Chuckles8421
    Hi,
    I have had a similar problem, and I figured out that the problem is that the movie clip draws the stuff (when you use the Drawing API) in the holder of the movie clip. I.E., if the movie clip is in the root timeline, then it draws in the root timeline. The only way I have figured out to control this is to createEmptyMovieClip within the already created one, then use that second one to draw the lines within the first one. Hope this helps, Chuckles8421
    Chuckles, thanks for your post. So I'm not just going crazy, there IS an issue.

    I've tried to do what you suggest but the movieClips still don't seem to swap levels. You say you got this to work? Maybe I do something wrong...

    I have this array of these visualizations. Each visualization has a name so I store them all in the array referenced by that name.

    In the old version I created the empty MCs I was drawing on using
    <pre>
    _root.createEmptyMovieClip(name, toplevel);
    </pre>

    All drawing functions then used
    <pre>
    _root[name].drawingfunctionname(..);
    </pre>

    Now I have an empty MC (empty_mc). I first create a copy on _root and then create the empty movieclip inside with a non-changable name.

    <pre>
    _root.attachMovie("empty_mc", name, topLevel);
    _root[name].createEmptyMovieClip("star", 1);
    _root[name].onRollOver = showLabel;
    ...
    </pre>

    now all drawing happens using
    <pre>
    _root[name].star.drawingfunctionname(..);
    </pre>

    All works fine exactly as before -- meaning the depths again don't swap. Did I do anything wrong?

    Here is the code I use to swap depths:
    <pre>

    function showLabel(Obj) {
    // pull the star to the top
    makeTopStar(this._name);
    ....
    }


    function makeTopStar(name) {
    // pull this star to the top.
    trace("make top star " + name);
    _root[name].swapDepths(topLevel);
    }
    </pre>

    Do you see any problem that I overlooked?

    Thanks,

    Juggle5



  5. #5
    Senior Member
    Join Date
    Sep 2001
    Posts
    178
    Hmmm..., well I would suggest adding a _root.createEmptyMovieClip (myholdername, toplevel) to the beginning, then change all of your:
    Code:
    _root[name]
    commands to
    [code]
    _root[myholdername][name]
    [\code]

    Or something like that, because the problem is that the movieclips draw on the level that they exist on, not on the level that they hold. When I get more time, I'll make a more thorough response. Chuckles8421

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