我已经停止了一个关键帧,但脚本仍在继续,并且不会通过yahoo接受
我也尝试过stop()但它没有用,它用来重复一个符号并将其破解
import mx.transitions.Tween;
import mx.transitions.easing.*;
var maxXPosition:Number = Stage.width/2;
var maxYPosition:Number = Stage.height/2;
var starCount:Number = 0;
var starIndex:Number = 0;
var starCreatorInterval:Number = null;
//Minimum and Maximum speeds.
//The speed defines the direction too, so the "minSpeed" must be negative.
var minSpeed = -3;
var maxSpeed = 12;
//Maximum number of stars on the screen at the same time.
var maxStarsOnScreen:Number = 500;
//Star creation speed (in miliseconds).
//For small movies, set a faster creation speed, so you will have more stars.
var creationSpeed = 10;
initStarfield();
/**
* Space Warp Functions
*/
function initStarfield():Void {
starCreatorInterval = setInterval(this, "generateStar", creationSpeed);
}
function generateStar():Void {
updateMaximus();
if (starCount < maxStarsOnScreen) {
var xSpeed:Number = getRandom(minSpeed, maxSpeed);
var ySpeed:Number = getRandom(minSpeed, maxSpeed);
var mcStar:MovieClip = this.attachMovie("mcStar", "mcStar" + starIndex, starIndex, {_x: xSpeed * 5, _y: ySpeed * 5});
mcStar.xSpeed = xSpeed;
mcStar.ySpeed = ySpeed;
mcStar._xscale = mcStar._yscale = 10;
mcStar.onEnterFrame = function():Void { updateStar(this); }
//Update control vars
starCount++;
starIndex++;
if (starIndex > 500) starIndex = 500;
}
}
function updateStar(mcStar:MovieClip):Void {
if (mcStar._x > maxXPosition || mcStar._y > maxYPosition ||
mcStar._x < -maxXPosition || mcStar._y < -maxYPosition ||
mcStar._alpha < 5) {
removeMovieClip(mcStar);
starCount--;
}
else {
mcStar._x += mcStar.xSpeed;
mcStar._y += mcStar.ySpeed;
if (mcStar._xscale < 100) mcStar._xscale = mcStar._yscale += 0.5;
else mcStar._alpha -= 2;
}
}
function updateMaximus():Void {
maxXPosition = Stage.width/1;
maxYPosition = Stage.height/1;
}
function getRandom(min:Number, max:Number):Number {
var now:Date = new Date();
var rand:Number = Math.random() * now.getMilliseconds() * 1000;
var randReturn:Number = 0;
randReturn = (rand % max) + min;
if ((Math.floor(Math.random() * 1000) % 2) == 0) randReturn *= -1;
return randReturn;
stop();
}
任何帮助将不胜感激
答案 0 :(得分:0)
可爱的动画。这段代码能满足你吗?
_root.onMouseDown = function() {
clearInterval(starCreatorInterval) ;
};
将其添加到脚本的末尾并尝试使用它。通过单击舞台,将删除间隔变量。