A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Fixing depths

  1. #1
    Senior Member
    Join Date
    May 2004
    Posts
    322

    Fixing depths

    I've loaded some movieclips into a scrollpane component. Each of the movieclips I've added have a picture attached. I have also used some code to make the picture draggable. So in other words what I want to do is be able to scroll through the list, select a picture and drag it into a box elsewhere on the stage.

    The problem I'm getting is that the picture is on the same level as the scrollpane component and so if I drag it beyond the edges of the component it gets hidden under the layer.

    I think this is something for depthManager class but I'm not sure where to put it or how to fix it. Does anyone have any ideas on this?
    Everybody has a story to tell, what's yours? -- http://www.filmfiler.com

  2. #2
    Senior Member
    Join Date
    May 2004
    Posts
    322
    If I do trace(this.getDepth); it shows that the picture that I want to drag has a depth of -16382. So what I want to do is set the depth to something positive - like 2000 for instance.

    If I use this.setDepthTo(DepthManager.2000); or this.setDepthTo(DepthManager.kTop); the trace function shows the depth as only 0.

    Why could this be and is there a better way to change the depths??
    Everybody has a story to tell, what's yours? -- http://www.filmfiler.com

  3. #3
    Island Boy
    Join Date
    Apr 2006
    Posts
    655
    what command are you using to create the draggable MC or to load the MC into the scrollpane?

    in the create function you could use the getNextHighestDepth() method or use a for loop and assign the specific numbers you want to the depth.

  4. #4
    Senior Member
    Join Date
    May 2004
    Posts
    322
    To clarify:

    'scrollpane' loads a movieclip called 'loader'
    lots of 'item' are attached to 'loader (and this displays in the scrollpane)
    'item' also contains a 'picture' (which is draggable)

    I'm using the following code to make 'picture' draggable. The code is on the 'item' timeline:

    Code:
    function move (x, y) 
    { 
        // drag while mouse is pressed. 
        picture.onPress = function () 
        {
    	trace(this.getDepth());
            startDrag (this); 
        }; 
        // stop dragging when mouse button is released. 
        picture.onRelease = function () 
        {
            stopDrag ();
        }; 
        // stop dragging when mouse is released outside, 
        // just to make sure the object gets released. 
        picture.onReleaseOutside = function () 
        {
            stopDrag (); 
        }; 
    }
    The reason I didn't use getNextHighestDepth is because I am using a component (scrollpane) and the Flash help files advise that DepthManager is better...
    Everybody has a story to tell, what's yours? -- http://www.filmfiler.com

  5. #5
    Spinal Tap's Road Manager
    Join Date
    Sep 2006
    Location
    Purgatory
    Posts
    86
    i had the same problem,

    i had some movieclips and they overtook some menu buttons

    so i just made a copy of the menu buttons being deleted due to conflicting depth so when the initial one was removed the copy was still there

    it's a bit of a "cheat" way to do it, but it works for me

    beats changing the depth for everything too

  6. #6
    Senior Member
    Join Date
    May 2004
    Posts
    322
    Sorry I don't understand what you mean?
    Everybody has a story to tell, what's yours? -- http://www.filmfiler.com

  7. #7
    Spinal Tap's Road Manager
    Join Date
    Sep 2006
    Location
    Purgatory
    Posts
    86
    EDIT: I've notcied what you're trying to do is different to what i've talked about, i got your depths around the wrong way... sorry

    instead of a scrollpane you could always use a mask... when you drag something under the edges of the mask it won't let you drop it so it can't really be hidden that way..

    movieclipname.setMask(maskmovieclipname);

    sorry i can't be more specific with my help, i'm new to helping people.... it's hard to type whats in my head




    Here's what I wrote before, it's helpful for people trying to insert movieclips made at runtime between existing instances

    well, when you assign a depth to a movieclip, it goes directly to that clip, regardless of what was on there before

    so when i assigned my movieclip to be at a certain depth, the movie clip that was initially on that depth dissapeared

    to solve this problem I just made 2 instances of the movie clip, so when the first one gets replaced with my custom movie clip, it seems like it doesn't dissapear

    it's kind of hard to explain.... but it was the only way to get it to work for me, as I had to put my custom movie clips at a lower depth than others... and this was the easier way compared to manually changing the depth for every movie clip
    Last edited by irrelevantjoker; 09-25-2006 at 06:19 PM.

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