如何解决变量定义重复的错误?每个定义都必须有单独的名称空间和用途,但我就是看不到这一点。
代码
这不是我写的,但我一直在尝试解压它并更改类,但似乎破坏了它。我想用它来对我的电影回放进行时间缩放,这里有一个很酷的数学模型。
//time-scaling script
import flash.display.*;
import flash.events.Event.*;
var _time_scale:Number = .25;
var _frames_elapsed:int = 0;
var _clip:MovieClip;
function Main():void {
_clip = new SomeClip;
addEventListener(Event.ENTER_FRAME, handleEnterFrame);
//integer??
function handleEnterFrame(e:Event):void {
_frames_elapsed ++;
}
// we multiply the "real" time with our timescale to get the scaled time
// we also need to make sure we give an integer as a parameter, so we use Math.round() to round the value off
_clip.gotoAndStop(Math.round(_clip.totalFrames * _frames_elapsed * _time_scale ));
}
var myTimer:Timer = new Timer(10);
myTimer.addEventListener(TimerEvent.TIMER, timerListener);
function timerListener (e:TimerEvent):void{
ball1.rotationY += 5;/////////replace function///////////
}
myTimer.start();错误
**3596**
Warning: Duplicate variable definition.
**1151**
A conflict exists with definition _clip in namespace internal备注
整数,非嵌套循环
发布于 2010-01-29 10:05:40
这是因为在这一行之后,你遗漏了构造器的结尾"}“:
addEventListener(Event.ENTER_FRAME, handleEnterFrame);下面这两行可能应该在构造函数中,而不仅仅是在类声明中:
var myTimer:Timer = new Timer(10);
myTimer.addEventListener(TimerEvent.TIMER, timerListener);如果使用Timer和TimerEvent类,则应导入它们:
import flash.utils.Timer;
import flash.events.TimerEvent;此外,您不需要在事件导入的末尾使用.*。
另一个“也”。你应该在你的成员上有访问修饰符。变量和函数。所以你真的应该说:
private var _clip:MovieClip;在我看来,您需要了解一下AS3的基础知识。这是一个非常好的起点:http://www.actionscript.org/resources/articles/611/1/Getting-started-with-Actionscript-3/Page1.html
发布于 2010-01-29 07:20:55
_clip是一个保留关键字,您必须使用其他关键字。
https://stackoverflow.com/questions/2158622
复制相似问题