1 Reply Latest reply on Mar 10, 2014 5:07 PM by Ned Murphy

    clicked button brings object to front

    ebhowell

      hi guys,

       

      so I currently have a set of buttons that when clicked, make certain objects visible. These objects are layered on top of each other and I want to bring each to the front when its button is clicked, but I'm struggling with the code snippets for "bring to front" - I'm pretty new to actionscript so the Child stuff is a little confusing

       

      basically what I'm looking for is this:

       

      button.addEventListener(MouseEvent.CLICK, showobject);

      function showobject(event:MouseEvent):void

      {

        *** code to bring the object to front ***

      }

       

       

      THANKS!

        • 1. Re: clicked button brings object to front
          Ned Murphy Adobe Community Professional & MVP

          There are two ways I can think of to make the object come to the front...

           

          button.addEventListener(MouseEvent.CLICK, showobject);

          function showobject(event:MouseEvent):void

          {

                addChild(objectName);

           

                      //  or

           

                setChildIndex(objectName, numChildren-1);

          }

           

           

          where objectName is replaced with whatever instance name you assign to the object