Bring object to the front, in Flash AS3

Posted by jimbo on Stack Overflow See other posts from Stack Overflow or by jimbo
Published on 2010-04-29T11:07:08Z Indexed on 2010/04/29 11:17 UTC
Read the original article Hit count: 353

Filed under:
|

Hi All,

i have the below code, which is basically animating object across the screen, when roll-over happens it pauses the anim, and displays some information. Everything works fine, but when its paused, i wold like that current object to be 'on top' so other items run behind.

I have looked at setChildIndex, but didn't have much luck.

package {

import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.events.KeyboardEvent;
import flash.events.*;
import caurina.transitions.Tweener;
import fl.motion.Color;

public class carpurchase extends Sprite {

    public function carpurchase() {

        var carX = 570;


        //Set cars
        var car1:fullCar = new fullCar();
        car1.info.alpha = 0;
        //var c:Color = new Color();
        //c.setTint(0xff0000, 0.8);
        //car2.car.transform.colorTransform=c;
        car1.x = carX;
        car1.y = 280;
        car1.info.title.text = "test";
        car1.info.desc.text = "test";
        addChild(car1);
        car1.addEventListener(MouseEvent.ROLL_OVER, carPause);
        car1.addEventListener(MouseEvent.ROLL_OUT, carContinue);
        function car1Reset():void {
            Tweener.addTween(car1, {x:carX, time:0, onComplete:car1Tween});
        }
        function car1Tween():void {
            Tweener.addTween(car1, {x:-120, time:2, delay:3, transition:"linear", onComplete:car1Reset});
        }
        car1Tween();


        var car2:fullCar = new fullCar();
        car2.info.alpha = 0;
        var c:Color = new Color();
        c.setTint(0xff0000, 0.8);
        car2.car.transform.colorTransform=c;
        car1.x = carX;
        car2.y = 175;
        car2.info.title.text = "test";
        car2.info.desc.text = "test";
        addChild(car2);
        car2.addEventListener(MouseEvent.ROLL_OVER, carPause);
        car2.addEventListener(MouseEvent.ROLL_OUT, carContinue);
        function car2Reset():void {
            Tweener.addTween(car2, {x:carX, time:0, onComplete:car2Tween});
        }
        function car2Tween():void {
            Tweener.addTween(car2, {x:-120, time:3, delay:0, transition:"linear", onComplete:car2Reset});
        }
        car2Tween();



        function carPause(e:MouseEvent):void {
            Tweener.pauseTweens(e.target);
            Tweener.addTween(e.target.info, {y:-150, alpha:1, time:.5, transition:"easeout"});
        }   
        function carContinue(e:MouseEvent):void {
            Tweener.addTween(e.target.info, {y:10, alpha:0, time:.5, transition:"easeout"});
            Tweener.resumeTweens(e.target); 
        }
    }
}

Any help welcome

© Stack Overflow or respective owner

Related posts about as3

Related posts about flash