dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Changing Button Depth?

Hybrid View

  1. #1
    Member
    Join Date
    Sep 2014
    Posts
    77

    Changing Button Depth?

    Hello,

    Is there any function that can be utilized to change the depth of a Button (not movieClip used as a button).

    I know that for mcs there is this function (swapDepths), but is there one for Buttons?

    Regards!

    P.S. A Button, not movieClip as a button.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    Similar, something like
    PHP Code:
    trace(theButton.getDepth());

    theButton.onRelease = function():Void 
    {
        
    this.swapDepths(_root.getNextHighestDepth());
        
    trace(theButton.getDepth());
    }; 
    just drag a component button on to the stage and call it theButton

  3. #3
    Member
    Join Date
    Sep 2014
    Posts
    77
    Thank you,

    That method above is working, perfectly, with a Button component. However, if the button was drawn the old fashion way; like drawing a square or circle and converting it to a button with F8, tried the code, it is not working with that.

    The button component was initially, I guess, built as movieclip, the reason why the function (swapDepths) works with it.
    Last edited by Dr_flash; 03-19-2016 at 05:44 AM.

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    Yes you are right, you can however:

    put your button in a container clip and do it that way, container.swapDepths();

    or you can use this workaround in your code and keep the code I gave with your button

    PHP Code:
    Button.prototype.swapDepths MovieClip.prototype.swapDepths
    found on adobe site

  5. #5
    Member
    Join Date
    Sep 2014
    Posts
    77
    Quote Originally Posted by fruitbeard View Post
    Hi,

    Yes you are right, you can however:

    put your button in a container clip and do it that way, container.swapDepths();

    or you can use this workaround in your code and keep the code I gave with your button

    PHP Code:
    Button.prototype.swapDepths MovieClip.prototype.swapDepths
    found on adobe site

    Hello All,

    Has anyone used the above code in the quote. Did it work with no problems? Did it interfer/miss up with other codes. Beacuse the key word "prototype" could be understood as if the method still in early stages, not consolidated yet. I do not know because I did not use it before. Can some one, who happened to have used it before, weigh on that.

    Any tips,

    Regards!
    Last edited by Dr_flash; 04-24-2016 at 09:07 AM.

  6. #6
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    Test it and see, it did of course work when testing it here.

    http://www.lashf.com/page/actionscript/prototypes

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