gpt4 book ai didi

flash - 将对象置于前面,在 Flash AS3 中

转载 作者:行者123 更新时间:2023-12-02 05:27:37 24 4
gpt4 key购买 nike

我有下面的代码,它基本上是在屏幕上动画对象,当翻转发生时它暂停动画,并显示一些信息。一切正常,但当它暂停时,我希望当前对象位于“顶部”,以便其他项目落后。

我看过 setChildIndex,但运气不佳。

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

欢迎任何帮助

最佳答案

只需在该特定实例上使用 addChild() 即可。它将被放置到“顶部”

来自帮助文件:

Adds a child DisplayObject instance to this DisplayObjectContainer instance. The child is added to the front (top) of all other children in this DisplayObjectContainer instance.

是的,即使对象已经在显示列表中,它也能正常工作。

关于flash - 将对象置于前面,在 Flash AS3 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2736745/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com