A Flash Developer Resource Site

Page 1 of 3 123 LastLast
Results 1 to 20 of 47

Thread: MX Depths Explained

  1. #1
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361

    MX Depths Explained

    Next up, Depths. Pretty broad topic, but one that has come up a few times in the past couple of weeks so I thought Id finish up what I had previously written on the subject. Might be more to them than you think.

    Because of the broadness and its lack of specific focus, its not as centralized as the others and may be a little less cohesive, though I think it does well enough. Mistakes may certainly well exist, so let me know when you catch them

    http://www.kirupa.com/developer/actionscript/depths.htm

    _____________________________________________


    (last posted article on setInterval)
    Last edited by senocular; 03-08-2004 at 10:44 AM.

  2. #2
    BradyWhite.net Kac's Avatar
    Join Date
    Nov 2000
    Location
    Orem, UT
    Posts
    576
    nice resource site, had fun looking through everything.

  3. #3
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    another great article!

    you haven't mentioned loadMovieNum()...
    ...as it also deals with depths...

    I found this pieces of code:
    code:

    Button.prototype.swapDepths = MovieClip.prototype.swapDepths;
    TextField.prototype.swapDepths = MovieClip.prototype.swapDepths;
    Button.prototype.removeMovieClip = MovieClip.prototype.removeMovieClip;


    and
    code:

    /* removes any movieclip */
    MovieClip.prototype.killMovieClip = function(){
    this.swapDepths(1048000);
    this.removeMovieClip();
    }


    very interesting!!

  4. #4
    Member
    Join Date
    May 2003
    Location
    sky
    Posts
    38
    both article and site are great, I'd appreciate it.
    wanna fly in the sky~

  5. #5
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    yeah I wasnt sure about including loadMovieNum since thats more levels than depths and they arent exactly the same thing, which I guess in itself is worth mentioning. If I get some more time, Ill throw that in thanks

  6. #6
    I'm not junior
    Join Date
    Jul 2002
    Location
    Barcelone
    Posts
    54
    Hello senocular,
    thank you for this tutorial about Flash Mx depth... great!!!
    But has you said in your conclusion, I have always problems with the depth of a movie clip...

    Maybe you can help me???

    I am trying to use a mask and duplicates movie clips.

    I want my duplicateMovieClips to be masked by a square for example... But with the depth problem, my MovieClips ignore that they are masked!!!
    I have tried to give a depth to my square, but the timeline ignore that it's a mask (Logical!!!)

    Do you know a way to arrange this????
    abracadabra!!!
    www.300k.com

  7. #7
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    dynamic masks only work on one movieclip at a time if you want move (ie duplicates) you need to keep them in one clip and mask that single clip

    ie:

    mask_mc
    container_mc
    --- mainClip_mc
    --- [and all duplicates]

    ^ then set the mask_mc to mask the container_mc. All the clips inside will then be masked since they are in container_mc

  8. #8
    I'm not junior
    Join Date
    Jul 2002
    Location
    Barcelone
    Posts
    54
    thank U seno!!!
    Very simple and it works
    abracadabra!!!
    www.300k.com

  9. #9
    Senior Member Dricciotti's Avatar
    Join Date
    Aug 2002
    Posts
    2,988
    very well written tutorial. it answered a whole lot of questions that I probably would have had to bother everone in flashKit with.

  10. #10
    Junior Member
    Join Date
    Jun 2003
    Location
    SF
    Posts
    9

    perhaps I can use depths...

    Hi there seno+++

    mini flash challenge, perhaps... (on the subject of swap depths)

    I posted a question in the Actionscript forum about me trying to figure out how to combine a vertical and horizontal slider in a way that always a movieClip to move within a cross-like shape. Since a "startDrag" command only gives you the option to make a rectangle, to make a cross-like drag area i have to swap something... or combine something... or write some really specific if statements...

    I had started with these simple values...

    movieClip.onPress = function (){
    this.startDrag (false,0,150,0,-150)
    //
    //>AND... (but totally won't work this simple i know...)
    //
    this.startDrag (false,-150,0,150,0)
    }
    movieClip.onRelease = function (){
    this.stopDrag ();
    }
    ...

    think of an elevator that goes up and down, but also has a track to go side to side at a certain point along the up and down axis.

    Could I possibly swap depths at the vertex where the two axes meet??

    I am only posting to you because I've read your posts before and you seem to know alot more about what you're talking about than some of the replies I've gotten to my post. I can almost see how swap depths works...

    I don't need you to write out the code for... just help me get my thinking in the right direction?

    Somebody just messaged me with a components suggestion but I am not sure that's what I am looking for either...

    peace+++
    +++actionscriptEgirl+++

  11. #11
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    you're just trying to get it to drag right? Whats the connection with swapDepths? swapDepths only really just changes arrangement of your clips allowing you to change their overlap order so on clip which may have been below another can appear on top.

  12. #12
    Junior Member
    Join Date
    Jun 2003
    Location
    SF
    Posts
    9

    it's probably my fault

    well i don't really want to use drag ultimately, i want it to follow my mouse using using a bit of inertia, but I figured i'd start with drag and figure out how to get it to shift between a vertical and horizontal axis.

    Really seno, it's a stab in the dark for me and swap depths. But I thought that maybe I could swap depths with the two movieClip axes (a vert and horiz)--- so the object being dragged would be limited to pay attention to one or the other--- depending on where the user's mouse was going....... the position of the mouse for the xy coord's would toggle swap depth?

    hahaa I probably just don't know what I am talking about...

    but it doesn't have to be a drag...

    I don't really know if I am even making sense... I will attach a visual aid...

    thanks seno

    +++E+++
    Attached Images Attached Images

  13. #13
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    yeah I understand the cross thing, but I dont see any relations with swap depths swapdepths is pretty much on the visual side of things. It lets you see one movieclip in front of the other or one movieclip behind another. You can "swap" their "depths" so that their layering is changed and one overlaps the other or vise versa. It doesnt have to do with dragging at all.

    For the dragging thing, you can use startDrag, but you would need to switch between 2 different bounding boxes - one a very small vertical box (small as in 1 pixel wide) and a small horizontal box. How to know when to use which box depends on which line your mouse is closer to. If your mouse is closer to the vertical box, youd use that box; if closer to the horixontal, youd use that box. So all youd need to do there is just check to see which your mouse is closer to and use startDrag with that bounding area. When the mouse is closer to the other line, call the other startDrag command with the other bounds.

    It gets a little more complicated when you throw in inertia

  14. #14
    Junior Member
    Join Date
    Jun 2003
    Location
    SF
    Posts
    9
    okay dude, something that you said made alot of sense...
    i think that'll get me going...

    it's still a bit unclear because I've only been doing actionscript for 4 months... like it's gonna take some of my brain power to figure out how to check for the mouse position in relation to the Vert and Hoirz movieClip, but I think you got the ball rolling with that suggestion...

    THANKS rocknroll you

    +++actionscriptEgirl+++

    ((((and i apologize to be posting this in your swap depths post))))

  15. #15
    Under the influence bvgroote's Avatar
    Join Date
    Nov 2000
    Location
    Perth, Australia
    Posts
    1,408
    man all this stuff goes way over my head, my AS skills are really letting me down

  16. #16
    Peace and good Vibes Pippomusic's Avatar
    Join Date
    Jan 2002
    Location
    Rome, Italy
    Posts
    169
    Thanks Senocular....
    ur posts are always very resourceful...

    Pippo

  17. #17
    Junior Member
    Join Date
    Mar 2001
    Posts
    3

    A Depths Issue in my project

    my problem is for flash mx.

    i read the UMBC article on depths. learned a bit more clearly how they work after what i had picked up already from Moock's ASDG2 book.

    my scenario explained as best as possible>>>
    i'm creating some emptyMovieClips with some createTextFields for some buttons that dynamically load in some variables from an external text file. a Hosting/Section MC (in this instance "mixesClip") on the main timeline of my site in progress makes a function call to the frame 1 of the _root. timeline for my movieclip/text field button creation.

    these clips are indeed created and functionally work properly, but, i want to be able to control them with action script to turn off their visibitly so they come in and out when i want them to (the buttons that i created dynamically that is). I traced the problem down to a depth issue i believe. when i trace the newly created clips and call for a "getDepth" on the movie clips in my code where they get created and come into existance onto the stage, they all come out saying -16260 and in this "mixesClip" section, i have 15 of these button all saying they have a depth of -16260 inside of the "mixesClip" movieclip. it doesn't seem possible that they can all have the same depth. my rollover/rollout/release functions all work properly on these buttons. i just can't control their visibility or even alpha via action script. in the debugger, i can turn them on/off with the _visibility, but _alpha changing does nothing to these clips. in action scripting authoring, _visibility is ineffective on these clips.

    here's some code snippets.
    this is the function i created to create my buttons on placed on frame1 of the main timeline. the buttons actually get placed in "mixesClip" which is a holder clip for the Mixes section of the site placed on the main timeline.i will then show you the code i use to pass data into this function. also, i load in a text file that stores a lot of variables for these function calls. i know this all works, cause, the buttons do all indeed come up on screen and rollovers work and the paths are all okay on that end.

    // MOVIECLIP BUTTON CREATION FUNCTION CALL CODE HERE on fram1 of the main timeline:::
    // textButtonCreator( path, mcn, depth, tfn, x, y, linkTitle, copySection, mixDescription, sectionOverviewClip, urlL)
    //_root.textButtonCreator("_root.discographyClip","a nalogAddictOrigClip", 1, "analogAddictOrig_txt", 0, 220, "discography1Tit", "_root.discographyClip.discographyOverviewClip.dis cographyInfo", "discography1", "_root.discographyClip.discographyOverviewClip ", "http://blancodisco.com/downloads/mpegs/sedvsros_analog_addict.mp3");
    function textButtonCreator(path, mcn, depth, tfn, x, y, linkTitle, copySection, mixDescription, sectionOverviewClip, urlL) {

    mcn = eval(path).loadVarsText[mcn];
    tfn = eval(path).loadVarsText[tfn];
    urlL = eval(path).loadVarsTexts[urlL];
    depth = depth + 1000;

    eval(path).createEmptyMovieClip(mcn, depth);
    eval(path)[mcn].createTextField(tfn, 100, x, y, 300,16);
    eval(path)[mcn][tfn].html = true;
    eval(path)[mcn][tfn].htmlText = eval(path).loadVarsText[linkTitle];
    eval(path)[mcn][tfn].setTextFormat(new TextFormat("kroeger 08-56", 8, 0x006600));
    eval(path)[mcn].hitArea = eval(path)[mcn];
    trace("depth = " + depth);

    eval(path)[mcn].onRollOver = function() {
    eval(path)[mcn][tfn].textColor = 0xffffff;
    eval(copySection).htmlText = eval(path).loadVarsText[mixDescription];
    _global.animationManager.Add(eval(sectionOverviewC lip), "_alpha", 100);
    }

    eval(path)[mcn].onRollOut = function() {
    eval(path)[mcn][tfn].textColor = 0x006600;
    eval(copySection).htmlText = eval(path).loadVarsText[mixDescription];
    _global.animationManager.Add(eval(sectionOverviewC lip), "_alpha", 0);
    }

    eval(path)[mcn].onRelease = function() {
    eval(path)[mcn][tfn].textColor = 0x003300;
    _global.animationManager.Add(eval(sectionOverviewC lip), "_alpha", 0);
    getUrl(urlL, target="_blank");
    }

    }



    here is an example of the data that passes into this function inside of a movie clip called "mixesClip" on the main timeline::
    _root.textButtonCreator("_root.mixesClip", "mcn1", 1, "tfn1", 50, 105, "mix1Tit", "_root.mixesClip.mixesOverviewClip.mixInfo", "mix1", "_root.mixesClip.mixesOverviewClip", "url1");

    all the little abbreviations like "mcn1" "tfn1" etc, make a call to my loaded in text file and read in the value from a matching variable in the text file and the value gets put into place via the button creation code above. it took me a while to figure this code out too. but hit nirvana when i learned about "eval()". that was the ticket in parsing in my passed in data.

    not sure if any of this code will help in deciphering the depth problem i'm having or not. I've tried using swap depths on these movie clips that are created after they have been created on the stage.
    an example:
    _root.mixesClip.ambientAfterhours.swapDepths(10000 );
    result after a trace() is still -16260 on the clip.

    i 've tried adding depth = depth + 1000; in the button creation function to try to raise the depth of these objects into positive number land. i can't seem to get control of these dynamically placed clips. everytime i issue a getDepth trace(), i just get a value of -16260 for each of these 15 clips that i create. if i took out some movie clips, i got a slighty different value, -16317 or something. but still a mega negative number.

    any help, suggestion/s, insight would be appreciated.
    i've held off coming for help on the forum here long enough.
    there's probably some simple quick fix for this. i'm just missing it.

    i'll answer any questions you have regarding this project as needed and to the best of my ability.

    perhaps showing a semi working version of the site will help you to visualize better. if you rollover DISCO and then click on MIXES, you'll see the page load in and the buttons come up in a sequential sort of order. This is an older version of this new site before i added the more tidy dynamic button creation code. this version has the button creation code for each button. it doesn't call the neat little function i made, but, this way, i was able to control how the buttons were created and removed. i think it gives me less control overall, but right now, it works this way, but not the way i think it should be able to work,. i just need to get pass this depth issue.

    the url: http://blancodisco.com/indexV5.0.html
    feel free to download some dj mp3 mixes if you want...


    cheers.
    benny blanco
    blancodisco.com

  18. #18
    Senior Member
    Join Date
    Dec 2000
    Posts
    240
    I could not open the page(url)
    [swf width="300" height="40" background="#666666"]http://www.angelfire.com/weird/webmaya/footer2.swf[/swf]

  19. #19
    Junior Member
    Join Date
    Mar 2001
    Posts
    3
    Originally posted by pranster
    I could not open the page(url)
    the url definitely works. it's a static html page with one simple rollover to get you into the flash area. look for the "ENTER" text (in white) on the page. click on that. and a 800x400 popup window should come up for you.

    http://blancodisco.com/indexV5.0.html

    thanks.
    benny blanco
    blancodisco.com

  20. #20
    Junior Member
    Join Date
    Mar 2001
    Posts
    3

    Re: A Depths Issue in my project

    okay folks, so, i sorta found a workaround to my solution. I don't think it is necessarily the best solution, but it works for my needs immediately so i can get on with it...

    I slightly updated my button creation code to include a swap depths statement which indeed worked.

    // BUTTON CREATION FUNCTION CALL CODE HERE:::
    // textButtonCreator( path, mcn, depth, tfn, x, y, linkTitle, copySection, mixDescription, sectionOverviewClip, urlL)
    //_root.textButtonCreator("_root.discographyClip","a nalogAddictOrigClip", 1, "analogAddictOrig_txt", 0, 220, "discography1Tit", "_root.discographyClip.discographyOverviewClip.dis cographyInfo", "discography1", "_root.discographyClip.discographyOverviewClip ", "http://blancodisco.com/downloads/mpegs/sedvsros_analog_addict.mp3");
    function textButtonCreator(path, mcn, depth, tfn, x, y, linkTitle, copySection, mixDescription, sectionOverviewClip, urlL) {

    mcn = eval(path).loadVarsText[mcn];
    tfn = eval(path).loadVarsText[tfn];
    urlL = eval(path).loadVarsTexts[urlL];

    eval(path).createEmptyMovieClip(mcn, depth);
    eval(path)[mcn].createTextField(tfn, 1, x, y, 300,16);
    eval(path)[mcn][tfn].html = true;
    eval(path)[mcn][tfn].htmlText = eval(path).loadVarsText[linkTitle];
    eval(path)[mcn][tfn].setTextFormat(new TextFormat("kroeger 08-56", 8, 0x006600));
    eval(path)[mcn].hitArea = eval(path)[mcn];

    // NEW CODE HERE>
    eval(path)[mcn].swapDepths(20000 + depth);
    eval(path)[mcn]._visible = false;
    // END NEW CODE HERE <

    eval(path)[mcn].onRollOver = function() {
    eval(path)[mcn][tfn].textColor = 0xffffff;
    eval(copySection).htmlText = eval(path).loadVarsText[mixDescription];
    _global.animationManager.Add(eval(sectionOverviewC lip), "_alpha", 100);
    }

    eval(path)[mcn].onRollOut = function() {
    eval(path)[mcn][tfn].textColor = 0x006600;
    eval(copySection).htmlText = eval(path).loadVarsText[mixDescription];
    _global.animationManager.Add(eval(sectionOverviewC lip), "_alpha", 0);
    }

    eval(path)[mcn].onRelease = function() {
    eval(path)[mcn][tfn].textColor = 0x003300;
    _global.animationManager.Add(eval(sectionOverviewC lip), "_alpha", 0);
    getUrl(urlL, target="_blank");
    }

    }



    i then created one new function on frame 1 of the _root timeline that would be used to simply turn visibility on/off, but i should expand this function so that it can really control any sort of movieclip property in the future. here is that code:

    function textButtonVisiblity (path, mcn, visi) {
    mcn = eval(path).loadVarsText[mcn];
    eval(path)[mcn]._visible = visi;
    }

    and then when i want to turn on the visibility of the button at a particular frame, i just simply put this call into the function above.
    _root.textButtonVisibility("_root.mixesClip", "mcn1", true);

    i'm not really sure why that the only way to control these dynamically created button movie clips is by using the same sort of technique i used to put them together. Using the eval(path)[mcn]. sort of syntax seems to be the only way to directly control these clips within action script once i created with this method. Even though they are visible in the debugger as how you would normally see any other movie clip listed.
    in the dubbuger, the button movie clip above would show up as
    _level0.mixesClip.ambientAfterHours

    i just can't control it with _root.mixesClip.ambientAfterHours._visibility = true;
    which is what i'd ideally like to able to do.

    again, any insight would be appreciated. I found a work around, but i don't fully realize as to why it has to be this way.

    thanks.
    benny blanco
    blancodisco.com

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