我正在尝试通过更改其不透明度来使自定义光标缓慢发光。问题是我可以看到它工作的唯一方法是制作 a while
,这会创建一个无限循环。有没有办法让我的光标从 0 不透明度变为 1 不透明度并上下移动。这是我目前的代码......我正在尝试寻找另一种方法来继续,但我真的没有看到任何其他方法。
public var Alpha:Number = 1;
public var sense:String = "down";
private function thisMouseOver(e:MouseEvent):void{
Mouse.hide();
//draws the cursor
drawCursor();
//Animates cursor
if(!this.animationStarted)
{
this.animationStarted = true;
animateCursor();
}
}
private function animateCursor():void{
while(this.animationStarted)
{
if(this.Alpha==1)
{
this.sense = "down";
}
else if(this.Alpha == 0)
{
this.sense = "up";
}
if(this.sense == "up")
this.Alpha += 0.1;
else
this.Alpha -= 0.1;
this.graphics.beginFill(0x333333);
this.graphics.drawRect(0,0,25,25);
this.graphics.endFill();
drawCursor();
}
}
private function drawCursor():void{
this.graphics.beginFill(0x00BFFF,this.Alpha);
//top left
this.graphics.drawRect(0,0,6,2);
//bottom left
this.graphics.drawRect(0,23,6,2);
//left top
this.graphics.drawRect(0,0,2,6);
//left bottom
this.graphics.drawRect(0,19,2,6);
//top righ
this.graphics.drawRect(19,0,6,2);
//right top
this.graphics.drawRect(23,0,2,6);
//bottom right
this.graphics.drawRect(19,23,6,2);
//right bottom
this.graphics.drawRect(23,19,2,6);
this.graphics.endFill();
}