dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: createEmptyMovieClip Depth Question

Hybrid View

  1. #1
    Senior Member
    Join Date
    Jan 2003
    Posts
    103

    createEmptyMovieClip Depth Question

    I'm trying to somewhat emulate an OS X operating system for the layout of my own personal blog, and I'm having a problem.

    I need the movie clip depth to increase one every time an empty clip is created. For example, if you open Window B and then open Window A, Window A appears on top of Window B. Opening Window C appears on top of both windows. I can't just have a set depth for each window, because if the user opens them in a different order then they still need to layer eachother.

    I know this can be done, I just need to be pointed in the right direction. I'd appreciate any help.. Thanks!
    Last edited by yanathin; 09-28-2005 at 12:38 PM.

  2. #2
    absent
    Join Date
    Aug 2000
    Location
    NB, Canada
    Posts
    155
    Define your depth as a variable (eg: i) then increase that variable (i++) everytime you create a new movieclip.
    I'm sure there are more then a few tutorials on this subject.

    g'luck!
    - g

  3. #3
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    you can use getNextHighestDepth(); to create a clip on top of the others.... then use swapDepths(); after they have been created, to move old windows to the front if a user clicks on it. check your Flash Help files for more detail... but this is sort of the idea:
    Code:
    //create first emptyClip
    this.createEmptyMovieClip("my_MC1", this.getNextHighestDepth());
    //create second emptyClip
    this.createEmptyMovieClip("my_MC2", this.getNextHighestDepth());
    //
    //now obviously, you have to load something INTO these 2 clips to make this work
    //
    //but then, you can swap the depths of the 2 mc's / windows with this...
    //
    my_MC1.onRelease = function() {
      this.swapDepths(my_MC2);
    };
    my_MC2.onRelease = function() {
      this.swapDepths(my_MC1);
    };
    
    //---------
    
    //the two uses of swapDepths are listed below:
    
    my_mc.swapDepths(depth:Number)
    //depth : A number specifying the depth level where my_mc is to be placed.
    
    my_mc.swapDepths(target:String)
    //target: A string specifying the movie clip instance whose depth is swapped by the
    //instance specified by my_mc. Both instances must have the same parent movie clip.

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