这可能是一个愚蠢的问题,因为我是flash专业版的新手,并且不知道太多。 所以我有一个框架与一些行动脚本(AS3)和这个脚本运行不断一旦开始。我想要的是一种停止脚本并继续播放电影的方法。例如,脚本只能在50-100帧之间运行。这怎么可能?闪光灯 - 设置帧数后停止AS3
var sw = 496;
var sh = 445;
var lightRadius:Number;
var frontLight:Sprite;
var backLight:Sprite;
var blur:BlurFilter;
var textClip:mcText;
var textClipMask:mcText;
var textClipShadow:mcText;
var offsetX:Number;
var offsetY:Number;
var angle:Number;
var scaleFactor:Number;
var blackRectangle:Sprite;
var lightAndDark:Sprite;
var textAndLightHolder:Sprite;
var spotWidth:Number;
var spotHeight:Number;
var ambientShade:uint;
var lightOnBackWallColor:uint;
var oscillationAmplitude:Number;
init();
function init():void {
lightRadius = 50;
spotWidth = 80;
spotHeight = 80;
offsetX = 0;
offsetY = -25;
scaleFactor = 1.25;
/*
We define colors below.
The ambientShade is best set to a gray value. By multiplication of color values, it
controls how dark the text will be when it is not illuminated by the spotlight.
Setting ambientShade to 0x000000 (black) will cause the text to be completely invisible
when not illuminated.
The wall in the background can appear to have its own color,
by setting lightOnBackWallColor. If lightOnBackWallColor is set to a dull gray as
we have done below, the effect is of a diffused light.
*/
ambientShade = 0x111111;
lightOnBackWallColor = 0x444444;
textClip = new mcText();
textClip.x = sw/2;
textClip.y = sh/2;
textClipMask = new mcText();
textClipMask.x = sw/2;
textClipMask.y = sh/2;
textClipShadow = new mcText();
textClipShadow.scaleX = textClipShadow.scaleY = scaleFactor;
textClipShadow.transform.colorTransform = new ColorTransform(0,0,0,1);
var shadowBlur:BlurFilter = new BlurFilter(6,6);
shadowBlur.quality = BitmapFilterQuality.HIGH;
textClipShadow.filters = [shadowBlur];
textClipShadow.x = textClip.x + offsetX;
textClipShadow.y = textClip.y + offsetY;
var matrix:Matrix = new Matrix();
matrix.createGradientBox(2*spotWidth,2*spotHeight,0,-spotWidth,-spotHeight);
frontLight = new Sprite();
frontLight.graphics.beginGradientFill("radial",[0xFFFFFF,ambientShade],[1,1],[64,255],matrix);
frontLight.graphics.drawEllipse(-spotWidth,-spotHeight,2*spotWidth,2*spotHeight);
frontLight.graphics.endFill();
matrix = new Matrix();
matrix.createGradientBox(2*scaleFactor*spotWidth,2*scaleFactor*spotHeight,0,-scaleFactor*spotWidth,-scaleFactor*spotHeight);
backLight = new Sprite();
backLight.graphics.beginGradientFill("radial",[lightOnBackWallColor,0x000000],[1,1],[32,255],matrix);
backLight.graphics.drawEllipse(-scaleFactor*spotWidth,-scaleFactor*spotHeight,2*scaleFactor*spotWidth,2*scaleFactor*spotHeight);
backLight.graphics.endFill();
frontLight.x = sw/2;
frontLight.y = sh/2;
backLight.x = frontLight.x + offsetX;
backLight.y = frontLight.y + offsetY;
blackRectangle = new Sprite();
blackRectangle.graphics.beginFill(ambientShade);
var rect = textClip.getBounds(textClip);
blackRectangle.graphics.drawRect(rect.left-2, rect.top-2, rect.width+4, rect.height+4);
blackRectangle.graphics.endFill();
blackRectangle.x = sw/2;
blackRectangle.y = sh/2;
lightAndDark = new Sprite();
lightAndDark.addChild(blackRectangle);
lightAndDark.addChild(frontLight);
lightAndDark.blendMode = BlendMode.MULTIPLY;
textAndLightHolder = new Sprite();
this.addChild(backLight);
this.addChild(textClipShadow);
this.addChild(textAndLightHolder);
textAndLightHolder.addChild(textClip);
textAndLightHolder.addChild(lightAndDark);
this.addChild(textClipMask);
textAndLightHolder.mask = textClipMask;
oscillationAmplitude = (sw/2 - backLight.width/2)/scaleFactor - 2;
this.addEventListener(Event.ENTER_FRAME, onEnter);
}
function onEnter(evt:Event):void {
frontLight.x = 0.5*sw - oscillationAmplitude*Math.cos(getTimer()*0.0005);
backLight.x = 0.5*sw - scaleFactor*(0.5*sw-frontLight.x) + offsetX;
}
什么是脚本做什么呢?你在谈论一个输入帧监听器(每帧功能更新)吗? – 2013-04-30 15:32:31
感谢您的回复。它做了一些我不明白的东西,我从http://www.flashandmath.com/intermediate/spot/index.html – user1130820 2013-04-30 15:49:29
得到它显示你的代码。你可以在你的输入框架句柄的顶部做什么,就像'if(currentFrame <50 && currentFrame> 100)return;'。如果你不在50和100之间的帧上,则该行退出函数 – BadFeelingAboutThis 2013-04-30 15:55:13