在我的主FLA文件库中,我有一个名为ProgressBar的movieclip,AS链接也被定义为ProgressBar。
然后我创建了ProgressBar.as文件。见下文。当我使用这个类时,我收到错误ProgressBar.as, Line 17 1061: Call to a possibly undefined method goToAndStop through a reference with static type ProgressBar.
USAGE:
var PBar:ProgressBar = new ProgressBar();
addChild(PBar);
PBar.setProgress(10); // gives Error
ProgressBar.as
package
{
import flash.display.MovieClip;
public class ProgressBar extends MovieClip
{
private var movie:MovieClip;
public function ProgressBar() {
//set initial position
setPosition(400,400);
}
public function setPosition(X:Number,Y:Number):void{
this.x=X;
this.y=Y;
}
public function setProgress(value:Number):void{
var progress = Math.round(value);
this.goToAndStop(5);
}
}
}
答案 0 :(得分:1)
这是因为goto
必须全部为小写,即gotoAndStop()
而不是goToAndStop()
。