Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 当我点击";时,小圆的闪烁位置不断变化;简历;_Actionscript 3_Flash - Fatal编程技术网

Actionscript 3 当我点击";时,小圆的闪烁位置不断变化;简历;

Actionscript 3 当我点击";时,小圆的闪烁位置不断变化;简历;,actionscript-3,flash,Actionscript 3,Flash,我试着让小圆圈在一个大圆圈内移动,并且有暂停、恢复和反转的按钮。但当我暂停并恢复时,它会改变小圆圈的位置,但我希望它保持在原始位置。有什么办法吗?还有一种方法可以在我点击时反转方向吗?(例如,当我点击“反转”时,开始是cw,它将变成反cw,当我再次点击“反转”时,它将变成cw) 这是我的动作层代码: var Rec:Number=1; stage.addEventListener(Event.ENTER_FRAME,EntFrame); function EntFrame(e:Event):v

我试着让小圆圈在一个大圆圈内移动,并且有暂停、恢复和反转的按钮。但当我暂停并恢复时,它会改变小圆圈的位置,但我希望它保持在原始位置。有什么办法吗?还有一种方法可以在我点击时反转方向吗?(例如,当我点击“反转”时,开始是cw,它将变成反cw,当我再次点击“反转”时,它将变成cw)

这是我的动作层代码:

var Rec:Number=1;

stage.addEventListener(Event.ENTER_FRAME,EntFrame);
function EntFrame(e:Event):void
{
if (Rec >= 1)
{
    CircleL.rotation-= 2;
}
else if(Rec <= -1)
{
    CircleL.rotation+=2;
}
}

var twoPI = 2 * Math.PI;
var circleSNum1:Number = Math.random();
var circleSNum2:Number = Math.random();
var circleSNum3:Number = Math.random();
var circleSNum4:Number = Math.random();
var circleSNum5:Number = Math.random();
function randomRange(minNum:Number, maxNum:Number):Number 
{
return (Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum);
}


var radius = randomRange(10, 90);

function move(event:Event):void{


CircleL.CircleS1.x = Math.cos(circleSNum1 * twoPI) * radius;
CircleL.CircleS1.y = Math.sin(circleSNum1 * twoPI) * radius;

CircleL.CircleS2.x = Math.cos(circleSNum2 * twoPI) * radius;
CircleL.CircleS2.y = Math.sin(circleSNum2 * twoPI) * radius;

CircleL.CircleS3.x = Math.cos(circleSNum3 * twoPI) * radius;
CircleL.CircleS3.y = Math.sin(circleSNum3 * twoPI) * radius;

CircleL.CircleS4.x = Math.cos(circleSNum4 * twoPI) * radius;
CircleL.CircleS4.y = Math.sin(circleSNum4 * twoPI) * radius;

CircleL.CircleS5.x = Math.cos(circleSNum5 * twoPI) * radius;
CircleL.CircleS5.y = Math.sin(circleSNum5 * twoPI) * radius;
}
addEventListener(Event.ENTER_FRAME,move);

Pause.addEventListener(MouseEvent.CLICK, clickPause);
function clickPause(Event:MouseEvent):void{
gotoAndStop("Pause");
Rec=0
}

Resume.addEventListener(MouseEvent.CLICK, clickResume);
function clickResume(Event:MouseEvent):void{
gotoAndStop("Resume");
Rec=1
}

Reverse.addEventListener(MouseEvent.CLICK, clickReverse);
function clickReverse(Event:MouseEvent):void{
gotoAndStop("Reverse");
Rec=-1
}
var Rec:Number=1;
stage.addEventListener(事件。输入_FRAME,EntFrame);
函数EntFrame(e:事件):void
{
如果(记录>=1)
{
圆周旋转-=2;
}

else if(Rec尝试在需要暂停时删除Enter Frame事件侦听器,并在需要继续时将其添加回。即使调用stop();(在本例中为gotoAndStop),Enter Frame事件仍会触发。因此,即使您跳到另一帧而看不到,圆仍会移动。当您返回到它时(resume)它看起来会移动,但从未停止过

Pause.addEventListener(MouseEvent.CLICK, clickPause);
function clickPause(Event:MouseEvent):void{
//remove event listener 
stage.removeEventListener(Event.ENTER_FRAME,EntFrame);
gotoAndStop("Pause");
Rec=0
}

Resume.addEventListener(MouseEvent.CLICK, clickResume);
function clickResume(Event:MouseEvent):void{
//add event listener 
stage.addEventListener(Event.ENTER_FRAME,EntFrame);
gotoAndStop("Resume");
Rec=1
}
此外,尝试在外部文件中编写ActionScript,并将其从时间线中删除,同时使用类……这并不难,最终会使您成为一名更好的开发人员