Bring objects to front

How can I implement this? I tried to use:
(this.numChildren - 1)
But it doesn't work. I want to use this code because I have 8 boxes, each are 100px X 100px. You hover each box and they flip over but the "backside" of these cards are larger in both length and width than the front. When they flip over they overlap the neighbouring card. I'm looking for some sort of script so that I can tell each card to align itself above the other cards on the stage.

I have an actionscript file that the FLA file refers to. The following is what is in the AS code. Within this AS code I have it refer to another AS file which handles the image loading. The code that i pasted earlier is what is in the FLA file.
package flashandmath.as3 {
    import flash.display.Sprite;
    import flash.display.Bitmap;
    import flash.display.BitmapData;   
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.text.TextFieldType;
    import flash.filters.DropShadowFilter;
    import flash.geom.Point;
    import flash.geom.PerspectiveProjection;
    import flashandmath.as3.ImageLoader;
    import fl.transitions.Tween;
    import fl.transitions.TweenEvent;
    import fl.transitions.easing.*;
    import flash.net.URLRequest;
    import flash.net.navigateToURL;
    public  class TweenFlipCS4 extends Sprite {
        private var turnSpeed:Number;
        private var bdFirst:BitmapData;
        private var bdSecond:BitmapData;
        private var imgsSrcs:Array; 
        private var imgLoader:ImageLoader;
        private var ErrorBox:TextField;
        private var picWidth:Number;
        private var picHeight:Number;
        private var holder:Sprite; 
        private var side0:Sprite;
          private var side1:Sprite;
        private var sharpSide0Img:Bitmap;
          private var sharpSide1Img:Bitmap;
        private var side0Img:Bitmap;
          private var side1Img:Bitmap;
        private var whichSideNext:int;
        private var spinType:String;
        private var objTw:Object;
        private var tw0:Tween;
        private var tw1:Tween;
        private var pp:PerspectiveProjection;
        public function TweenFlipCS4(img0:String,img1:String,t:String="vertical"){
            imgsSrcs=[img0,img1];
            imgLoader=new ImageLoader();
            //Messages to the user about loading will be displyed in ErrorBox.
            ErrorBox=new TextField();
            this.addChild(ErrorBox);
             setUpErrorBox();
               setErrorBoxSizeAndPos(250,150,0,0);
            setErrorBoxFormat(0xCCCCFF,12);
            turnSpeed=1.5;
            if(t=="vertical"){
                spinType="vertical";
            } else {spinType="horizontal";}
            prepTweens();
            prepImgs();
        //End of constructor.
        public function setSpeed(t:Number):void {
            tw0.duration = t;
            tw1.duration = t;
        public function setFunc(f:Function):void {
            tw0.func = f;
            tw1.func = f;
        //The function InitApp is running after images are successfully loaded.
        private function initApp():void {
            ErrorBox.text="";
            ErrorBox.visible=false;
            bdFirst=imgLoader.bitmapsArray[0].bitmapData;
            bdSecond=imgLoader.bitmapsArray[1].bitmapData;
            side0Img=new Bitmap(bdFirst);
            side1Img=new Bitmap(bdSecond);
            //We create two copies of our images. See comment before twReset function
            //for explanation.
            sharpSide0Img=new Bitmap(bdFirst);
            sharpSide1Img=new Bitmap(bdSecond);
              picWidth=side0Img.width;
              picHeight=side0Img.height;
            holder=new Sprite();
              this.addChild(holder);
            holder.x=picWidth/2;
            holder.y=picHeight/2;
              side0=new Sprite();
              holder.addChild(side0);
              side0Img.x=-picWidth/2;
              side0Img.y=-picHeight/2;
            side0.x=0;
            side0.y=0;
            side0.addChild(side0Img);
            side1=new Sprite();
              holder.addChild(side1);
              side1Img.x=-picWidth/2;
              side1Img.y=-picHeight/2;
            side1.x=0;
            side1.y=0;
            side1.addChild(side1Img);
            //In order to appear correctly after a flip, the back side has to be
            //rotated initially.
            if(spinType=="vertical"){
            side1.rotationY = 180; } else {
                side1.rotationX = 180;
              holder.filters = [ new DropShadowFilter() ];
            this.addChild(sharpSide0Img);
            this.addChild(sharpSide1Img);
            sharpSide0Img.visible=true;
            sharpSide1Img.visible=false;
            //Each instance of the TweenFlipCS4 class has its own PerspectiveProjection object.
            pp=new PerspectiveProjection();
            pp.fieldOfView=60;
            pp.projectionCenter=new Point(picWidth/2,picHeight/2);
            this.transform.perspectiveProjection=pp;
              renderView(0);   
              setUpListeners();
        private function prepTweens():void {
            objTw = {t: 0};
            tw0 = new Tween(objTw,"t",Regular.easeOut,0,180,turnSpeed, true);
            tw0.stop();
            tw0.addEventListener(TweenEvent.MOTION_CHANGE, twRotate);
            tw0.addEventListener(TweenEvent.MOTION_FINISH, twReset);
            tw1 = new Tween(objTw,"t",Regular.easeOut,180,360,turnSpeed, true);
            tw1.stop();
            tw1.addEventListener(TweenEvent.MOTION_CHANGE, twRotate);
            tw1.addEventListener(TweenEvent.MOTION_FINISH, twReset);
        Each time the tw0 or tw1 Tween fires we call the renderView function using objTw.t as its argument.
        private function twRotate(twevt:TweenEvent):void {
            renderView(objTw.t);
        private function twReset(twevt:TweenEvent):void {
            side0.addEventListener(MouseEvent.ROLL_OVER,side0Over);
            side0.addEventListener(MouseEvent.ROLL_OUT,side0Out);
            side1.addEventListener(MouseEvent.ROLL_OVER,side1Over);
            side1.addEventListener(MouseEvent.ROLL_OUT,side1Out);
            this["sharpSide"+String(whichSideNext)+"Img"].visible=true;
          private function renderView(t:Number):void {
            if ( (t < 90) || (t > 270) ) {
                side0.visible = true;
                side1.visible = false;
            else {
                side0.visible = false;
                side1.visible = true;
            if(spinType=="vertical"){
             holder.rotationY = t; } else {
                holder.rotationX = t;
        private function setUpListeners():void {
            imgLoader.removeEventListener(ImageLoader.LOAD_ERROR,errorLoading);
            imgLoader.removeEventListener(ImageLoader.IMGS_LOADED,allLoaded);
            side0.addEventListener(MouseEvent.ROLL_OVER,side0Over);
            side0.addEventListener(MouseEvent.ROLL_OUT,side0Out);
            side1.addEventListener(MouseEvent.ROLL_OVER,side1Over);
            side1.addEventListener(MouseEvent.ROLL_OUT,side1Out);
        When side0 hears the mouse over or out event, the listeners are removed & tw0 starts.
        They will be added back when the Tween tw0 finishes playing.
        private function side0Over(e:MouseEvent):void {
            side0.removeEventListener(MouseEvent.ROLL_OVER,side0Over);
            side1.removeEventListener(MouseEvent.ROLL_OUT,side1Out);
            side0.removeEventListener(MouseEvent.ROLL_OUT,side0Out);
            side1.removeEventListener(MouseEvent.ROLL_OVER,side1Over);
            sharpSide0Img.visible=false;
            sharpSide1Img.visible=false;
            whichSideNext=1;
            tw0.rewind();
            tw0.start();
        private function side0Out(e:MouseEvent):void {
            side0.removeEventListener(MouseEvent.ROLL_OVER,side0Over);
            side1.removeEventListener(MouseEvent.ROLL_OUT,side1Out);
            side0.removeEventListener(MouseEvent.ROLL_OUT,side0Out);
            side1.removeEventListener(MouseEvent.ROLL_OVER,side1Over);
            sharpSide0Img.visible=false;
            sharpSide1Img.visible=false;
            whichSideNext=1;
            tw0.rewind();
            tw0.start();
        When side1 hears the mouse over or out event, the listeners are removed and tw1 starts.
        They will be added back when the Tween tw1 finishes playing.
        private function side1Out(e:MouseEvent):void {
            side0.removeEventListener(MouseEvent.ROLL_OVER,side0Over);
            side1.removeEventListener(MouseEvent.ROLL_OUT,side1Out);
            side0.removeEventListener(MouseEvent.ROLL_OUT,side0Out);
            side1.removeEventListener(MouseEvent.ROLL_OVER,side1Over);
            sharpSide0Img.visible=false;
            sharpSide1Img.visible=false;
            whichSideNext=0;
            tw1.rewind();
            tw1.start();
        private function side1Over(e:MouseEvent):void {
            side0.removeEventListener(MouseEvent.ROLL_OVER,side0Over);
            side1.removeEventListener(MouseEvent.ROLL_OUT,side1Out);
            side0.removeEventListener(MouseEvent.ROLL_OUT,side0Out);
            side1.removeEventListener(MouseEvent.ROLL_OVER,side1Over);
            sharpSide0Img.visible=false;
            sharpSide1Img.visible=false;
            whichSideNext=0;
            tw1.rewind();
            tw1.start();
        // Manage simple navigation to thisURL when side1 is clicked.
        private function prepImgs():void {
            imgLoader.addEventListener(ImageLoader.LOAD_ERROR,errorLoading);
               imgLoader.addEventListener(ImageLoader.IMGS_LOADED,allLoaded);
               imgLoader.loadImgs(imgsSrcs);
            ErrorBox.visible=true;
            ErrorBox.text="Loading images...";
        private function errorLoading(e:Event):void {
           ErrorBox.visible=true;
           ErrorBox.text="There has been an error loading images. The server may be busy. Try refreshing the page.";
           private function allLoaded(e:Event):void {
            initApp();
        private function setUpErrorBox():void {
            ErrorBox.type=TextFieldType.DYNAMIC;
            ErrorBox.wordWrap=true;
            ErrorBox.border=false;
            ErrorBox.background=false;
            ErrorBox.text="";
            ErrorBox.visible=false;
            ErrorBox.mouseEnabled=false;
        public function setErrorBoxFormat(colo:Number,s:Number): void {
            var errorFormat:TextFormat=new TextFormat();
            errorFormat.color=colo;
            errorFormat.size=s;
            errorFormat.font="Arial";
            ErrorBox.defaultTextFormat=errorFormat;
        public function setErrorBoxSizeAndPos(w:Number,h:Number,a:Number,b:Number): void {
            ErrorBox.width=w;
            ErrorBox.height=h;
            ErrorBox.x=a;
            ErrorBox.y=b;

Similar Messages

  • Clicked button brings object to front

    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!

    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

  • Bring object to front on mouseover

    Hello,
    Another simple question here.  I have 2 objects next to each other.  On mouseover I have them enlarge.  I would like to make it so that whatever object is being enlarged is brought to the front.  Here is my code.
    lowgaugefinished.addEventListener(MouseEvent.MOUSE_OVER, lowscaleup);
    lowgaugefinished.addEventListener(MouseEvent.MOUSE_OUT, lowScaledown);
    higaugefinished.addEventListener(MouseEvent.MOUSE_OVER, hiscaleup);
    higaugefinished.addEventListener(MouseEvent.MOUSE_OUT, hiscaledown);
    function lowscaleup (evtObj:MouseEvent)
        lowgaugefinished.scaleX = 2;
        lowgaugefinished.scaleY = 2;
    function lowScaledown (evtObj:MouseEvent)
        lowgaugefinished.scaleX = 1;
        lowgaugefinished.scaleY = 1;
    function hiscaleup (evtObj:MouseEvent)
        higaugefinished.scaleX = 2;
        higaugefinished.scaleY = 2;
    function hiscaledown (evtObj:MouseEvent)
        higaugefinished.scaleX = 1;
        higaugefinished.scaleY = 1;

    Try changing the scale up functions like so...
    function lowscaleup (evtObj:MouseEvent)
        addChild(lowgaugefinished);
        lowgaugefinished.scaleX = 2;
        lowgaugefinished.scaleY = 2;
    function hiscaleup (evtObj:MouseEvent)
        addChild(higaugefinished);
        higaugefinished.scaleX = 2;
        higaugefinished.scaleY = 2;

  • Bring items in front of another

    The applescript dictionary for InDesign says:
    "bring to front v : Brings the object to the front of its layer or in front of a particular item."
    But how do you write to bring the object in front of a particular item? The command only accept one parameter (the object that it brings to front).

    Thanks Jarek,
    you saved my day! Though I had to use the "do script"-command to make it work in Applescript:
    tell application "Adobe InDesign CS5"
              set mySelectedPageItems to selection
              set myObject to item 1 of mySelectedPageItems
              set particularObject to item 4 of mySelectedPageItems
              do script "arguments[0].bringToFront(arguments[1])" language javascript with arguments {myObject, particularObject}
    end tell
    I wasted so many hours yesterday trying to work it out in AS, but failed. Maybe someone know the right syntax in AS?

  • [AIR] May I catch "bring window to front" event?

    Hi,
    I wonder who is responsible for bringing windows to front when user click on that window (application contains more Windows components inside). Is it operating system or AIR runtime? Or perhaps AIR runtime send event to operating system which does it? In this case there would be some chance to catch and stop propagation of that event not to let operating system bring that window to front. Am I right? Any idea how to do it?
    //pyso

    This thread explains my experiences with the toFront() method on Windows 98. It works, but only if the frame has been hidden for about 20 seconds.
    http://forum.java.sun.com/thread.jsp?forum=57&thread=426257

  • How do I bring components to front?

    Does anybody know, if I have overlapping components like JLabels, how can I choose which one to bring to the front?
    In other words, if I have two overlapping JLabels, how can I choose which one gets seen.

    I don't know if you can do this programmatically with one call (like the WinAPI setWindowPos and specify the z order and appropriate flag).
    Swing components are displayed in the order they are added to the container, with the first component being the top most.
    Regards,
    Nick G.

  • What is "bring all to front"

    Under the Window menu is the item "bring all to front" and I have no idea what that means.  I thought it meant to get current windows shown but so far nothing happens when I click on that option.  ??????????????

    For the application showing in the upper left-hand corner, selecting that option brings all of its open windows to the front or on top of any other app's open windows.

  • Method to bring component to front?

    Hey all
    I am looking for a method that can be used to bring a component to front in my applet. I have a few choice menus that arent showing up and i believe it is because labels are being drawn over them.
    The choice menus do not show up at all normally, but they appear just fine if I
    setVisible(false) to the labels.
    It has always been my understanding that components will show up in the order they are added to the applet. So if the labels are added first, then the menu second - the menu should be on top. However my applet also requires a lot of setVisible(true/false) and I am not sure if that is affecting the layering also. Would setting a component as visible automatically bring it to front, or would it remain where it has been added?
    SO, if there is a bring to front method kicking around that would definately solve my problem.
    thanks for the help.

    If possible could you post your compilable code that simulate your
    problem or in short your SSCCE.

  • Automator: Bring Window to Front

    I have been looking for a workflow that can bring a non-active window into active view e.g. bring a window that is in the background to the front view.
    There is no workflow in automator for this action but i wondered if anyone has come across some apple script that is capable of doing this? I could work the apple script into automator.
    Thanks,
    Adrian

    The window i am trying to bring to the front is called 'WorkflowServiceRunner'. Its not an application in the available list in Launch Application action.

  • Bring text to front of image

    how do i bring text to front of image using dream
    weaver?

    You would set the image as a background image- that would be
    a possible
    option. Please remember that the text will not stay static
    and will shift
    when a viewer resizes the text.
    You cannot lose until you give up !!!
    "berry05" <[email protected]> wrote in
    message
    news:fsk74t$d4r$[email protected]..
    > how do i bring text to front of image using dream
    weaver?

  • Snap position object in front of active camera

    I cannot find this function so please let me know if I am just missing it - but it has occurred to me that it would be very handy to have the ability to align any given opblect in front of the currently active camera.
    If a camera Moves throughout a scene and you suddenly want to duplicate an element that is elsewhere in a scene, if you duplicate it, it s duplicated in place.  Is there a way to "snap position" an object existing in a scene in front of a camera?

    Why would I first need to set the origin of the camera to the center of the scene before cutting if the camera i want the object in front of it elsewhere in the scene.
    You don't have to reset the camera, just the duplicated object. If you reset the camera, you'd loose any animation settings you might have.
    Am I to understand that Motion 5 just defaults to placing a cut and pasted object in front of a camera only if it's transforms are reset?  That seems kind of arbitrary.
    I don't know that it's arbitrary,  it seems to be related  to this (from the motion documentation):
    Drag and Drop onto the Canvas
    Dragging and dropping an object onto the Canvas adds the object to the scene at the focal plane of the current camera. Dragging an object into the Layers list or clicking the Apply button in the preview area of the File Browser positions the object at 0, 0, 0.
    Basically, depending on how you add objects, motion determines where to place them in the scene. This seems to be the case for copy and paste too.  Copy and paste includes all of the transformations already applied to the object.  The paste treats your camera focal plane like the origin for the scene, but your object has it's own transforms, that's how it gets offset from the camera focal plane.  Resetting the object to the origin removes those settings and works like using the apply button mentioned in the documentation.
    Here's an example to show what I'm talking about.
    1.Add a camera and rotate it, make sure you can see the origin for the grid.
    2. Add a shape from the library using the apply button in the inspector.
    -The shape gets added at the origin, not at the camera view.
    3. Reposition the camera, make sure to change the position and rotation.
    4. Add the shape but this time drag and drop to the canvas.
    -Notice how the shape is at the focal plane of the camera. If you look at it's settings they match what is needed to position the object at the camera's focal plane.
    5. Reposition the camera one more time.
    6. Now Copy and past each object while in the active camera view.
    -When you copy and past the object at the origin, it's pasted at the focal plane because it doesn't have any transforms.
    -When you copy and paste that was added from the drag and drop, it's offset, it's transforms have been added to the camera focal plane transformation.
    You may also want to review the section in the documentation about Relative coordinates.
    -Cheers

  • One click select object on Front panel

    Hi,
       LabView7.1. On the front panel, I cannot select an object by one left lick. Where can I change the setting?
    Thank you!
    Weitong

    weitong wrote:
    Hi,
       How to set the automatic selection tools true?
    In the tools palette, the LED on the top must be glowing. This indicates that you have selected the "Automatic Tool Selection"
    weitong wrote:
    Hi,
        When I double click the object on Front panel, it opens a new front panel with that object instead of locating that object on Block Diagram.
    It is opening the Control Editor panel because You have checked the "Open control editor when Double click" to true as shown in figure.
    Goto
    Tools>>Options, select front panel from the dropdown menu and uncheck the "Open the control editor with double click"
    Uncheck it.
    Attachments:
    AutomaticToolsSelection.PNG ‏6 KB
    DoubleClick.PNG ‏20 KB

  • Bringing event to front in iCal

    Going to try a slightly different question to the one I posted yesterday.
    If i want to bring an iCal event to the front because it is hidden behind another how do I do this?  Click on it right and it should come to the front?  Since upgrading to Lion this no longer happens.  Any help as to why and how to get over this issue would be very much apppreciated.

    Perhaps my original post wasn't as clear as I thought it was.
    I am running several calendars so that I can see what my colleagues are doing and what is going on at home and there are often events that take place at the same time or overlap times.  In iCal 4.0 I used to be able to click an event that was "under" another from a different calendar and it would come to the front along with all the other events of that calendar.  This no longer happens with iCal in Lion making it very difficult to see events hidden behind others.  I'm sure I can't be only one running more than one calendar in iCal with the potential for overlapping events? 
    My question is: Is this somehting that Apple have changed (if so I am really @£$% about it) or do I have a problem with my set up?  I have already re-installed Lion once to see that helps but no such luck.

  • Dialog programming - bring screen in front

    I have a requirement where I am supposed to call a module pool screen in search help exit  of material using call transaction. It is working when i use F4 help from MM03, but when i am using the same search help from a custom sceen, the new screen opens behind the F4 help screen. Is there a way i can bring that screen in front?
    Thanks,
    HD

    Hi,
    try the following:
    In SE51 of your screen select screen attributes and change screen type to Modal dialog box Then it should come to front!
    Regards,
    Klaus

  • PopUp my GUI and bring it to front

        Hello,
    i have a GUI and want du bring a SubVI-GUI to the front, if special RS232 get in. Is it
    possible, that it popup also when I'm in Word or Excel at this moment?
    Any ideas?
    Thanks, Simon Wieser

    Hi Simon,
    look for the lvwutil32-library. It contains a lot of functions on window handling, also your needed "move window to top"!
    Using Google "lvwutil32 download" brings up this in the first place!
    Searching the NI website shows this!
    Message Edited by GerdW on 01-21-2008 10:00 AM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

Maybe you are looking for