20 Replies Latest reply on Apr 5, 2010 1:32 PM by henry_ford

    Bring objects to front

    henry_ford

      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.

        • 1. Re: Bring objects to front
          kglad Adobe Community Professional & MVP

          to move a displayobject to the top of the display list of its parent, use:

           

          yourdisplayobject.parent.addChild(yourdisplayobject);

          • 2. Re: Bring objects to front
            henry_ford Level 1

            For my code it's the following. Where would I put "yourdisplayobject.parent.addChild(yourdisplayobject);"? I know that I have to change the "your..." to whatever my cards are named.

             

             

            import fl.transitions.easing.*;

             

            import flashandmath.as3.TweenFlipCS4;

             

            var card1:TweenFlipCS4;

             

            var card2:TweenFlipCS4;

             

            var card3:TweenFlipCS4;

             

            var card4:TweenFlipCS4;

             

            var card5:TweenFlipCS4;

             

            var card6:TweenFlipCS4;

             

            var card7:TweenFlipCS4;

             

            var card8:TweenFlipCS4;

             


            card1=new TweenFlipCS4("turtleimage.jpg","sharkcard.jpg");

             

            this.addChild(card1);

             

             

            card2=new TweenFlipCS4("turtleimage.jpg","turtlecard.jpg");

             

            this.addChild(card2);

             

            card3=new TweenFlipCS4("turtleimage.jpg","turtlecard.jpg","horizontal");

             

            this.addChild(card3);

             

            card4=new TweenFlipCS4("turtleimage.jpg","sharkcard.jpg","horizontal");

             

            this.addChild(card4);

             

            card5=new TweenFlipCS4("turtleimage.jpg","sharkcard.jpg","horizontal");

             

            this.addChild(card5);
                     
            card6=new TweenFlipCS4("turtleimage.jpg","turtlecard.jpg","horizontal");

             

            this.addChild(card6);

             

            card7=new TweenFlipCS4("turtleimage.jpg","turtlecard.jpg","horizontal");

             

            this.addChild(card7);

             

            card8=new TweenFlipCS4("turtleimage.jpg","turtlecard.jpg","vertical");

             

            this.addChild(card8);
                     
            setCardsPosAndProps();

             


            function setCardsPosAndProps():void {
               
                card1.x=10;
                card1.y=77;
               
                card2.x=225;
                card2.y=77;
               
                card3.x=323;
                card3.y=77;
               
                card4.x=470;
                card4.y=77;
               
                card5.x=10;
                card5.y=200;
               
                card6.x=225;
                card6.y=220;
               
                card7.x=323;
                card7.y=250;
               
                card8.x=450;
                card8.y=200;

             

                card1.setFunc(Back.easeOut);
                card1.setSpeed(1.5);
                              
                card2.setFunc(Back.easeOut);
                card2.setSpeed(1.5);
               
                card3.setFunc(Back.easeOut);
                card3.setSpeed(1.5);
               
                card4.setFunc(Back.easeOut);
                card4.setSpeed(1.5);
               
                card5.setFunc(Back.easeOut);
                card5.setSpeed(1.5);
                              
                card6.setFunc(Back.easeOut);
                card6.setSpeed(1.5);
               
                card7.setFunc(Back.easeOut);
                card7.setSpeed(1.5);
               
                card8.setFunc(Back.easeOut);
                card8.setSpeed(1.5);

             

            }

            • 3. Re: Bring objects to front
              kglad Adobe Community Professional & MVP

              where and/or when do you want to move a card to the top of the display list?


              • 4. Re: Bring objects to front
                henry_ford Level 1

                Well there are 8 cards and whenever the user hovers over them they flip over but they flip

                under the cards beside them.They are setup like this:

                 

                   [ ] [ ] [ ] [ ]

                   [ ] [ ] [ ] [ ]

                 

                So say if the 1st card on the 1st row flips, it will flip under the cards beside it.Its all random and depends on where the user rolls over.

                • 5. Re: Bring objects to front
                  kglad Adobe Community Professional & MVP

                  where, in your code?

                  • 6. Re: Bring objects to front
                    henry_ford Level 1

                    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;
                               
                            }
                        }
                    }

                    • 7. Re: Bring objects to front
                      kglad Adobe Community Professional & MVP

                      can you highlight the function where you want your card to be moved so i don't have to go through all that code?

                      • 8. Re: Bring objects to front
                        henry_ford Level 1

                        i think it's this...  im still new to AS3

                         

                                     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);
                                   
                                   
                                }

                         

                        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();
                                }

                        • 9. Re: Bring objects to front
                          kglad Adobe Community Professional & MVP

                          assuming side0, side1 are cards, use:

                           


                           

                                       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);
                                     
                                     
                                  }

                           

                          private function side0Over(e:MouseEvent):void {
                                      side0.parent.addChild(side0);
                                      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 {

                          side1.parent.addChild(side1)
                                     
                                      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();
                                  }

                          • 10. Re: Bring objects to front
                            henry_ford Level 1

                            i'm not at the computer where my fla is, its at work... but i'll try that on monday and let you know how it goes. side 0 and side1 refers to the back (side0) and the front(side1) of the cards.

                            • 11. Re: Bring objects to front
                              kglad Adobe Community Professional & MVP

                              are those the objects you want moved to the top of the display list?

                              • 12. Re: Bring objects to front
                                henry_ford Level 1

                                Sorry for the late reply. I was not near the computer where my Flash is. So, I tried adding the code to the location where you

                                bolded but the cards still flip under their neighbours.


                                • 13. Re: Bring objects to front
                                  kglad Adobe Community Professional & MVP

                                  someone will need to correct your file(s) for you.

                                  • 14. Re: Bring objects to front
                                    henry_ford Level 1

                                    hey if I used this, could it bring the objects to the front?

                                     


                                    function SwapDepths(e:MouseEvent):void {
                                        var target=e.target;
                                        this.setChildIndex(target, (this.numChildren - 1));

                                    }
                                    this.addEventListener(MouseEvent.MOUSE_OVER, SwapDepths);

                                     

                                    After appling this code into the script after "setCardsPosAndProps(); I got error:

                                     

                                    ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
                                        at flash.display::DisplayObjectContainer/setChildIndex()
                                        at conflict_fla::MainTimeline/SwapDepths()

                                    • 15. Re: Bring objects to front
                                      kglad Adobe Community Professional & MVP

                                      no, use:

                                       



                                      function SwapDepths(e:MouseEvent):void {
                                         MovieClip(e.currentTarget).parent.addChild(e.currentTarget);

                                      }
                                      this.addEventListener(MouseEvent.MOUSE_OVER, SwapDepths);

                                       


                                      • 16. Re: Bring objects to front
                                        henry_ford Level 1

                                        Where would I put that code? I placed it just before the line "setCardsPosAndProps();" but got error 1118.

                                        • 17. Re: Bring objects to front
                                          kglad Adobe Community Professional & MVP

                                          you'll need someone to fix your problem for you.

                                          • 18. Re: Bring objects to front
                                            henry_ford Level 1

                                            i know that this is a long shot, but if i email you my fla file could you look at it and help me out?

                                            • 19. Re: Bring objects to front
                                              kglad Adobe Community Professional & MVP

                                              i only download and correct files if i'm hired.

                                              • 20. Re: Bring objects to front
                                                henry_ford Level 1

                                                so I got it working, the was the action script was loading the images was backwards so 8-1 and starting from 8 to 1 it will have the images flip under. once i reversed the way the images were being called in, the images now flip on top of each other.