我會通過一些AS3的訓練,但我發現了一個奇怪的錯誤...1180:調用可能未定義的方法的addEventListener
我試圖將事件偵聽器添加到的結束在AS中的補間動畫。
我創建了一個補間,突出顯示框架,右鍵單擊並將補間複製爲AS並將其粘貼到影片剪輯中(我認爲還有更好的方法可以做到這一點,但我不確定它是什麼...)
當我嘗試將偵聽器添加到該代碼的末尾時,出現錯誤。這是我的代碼。
import fl.motion.AnimatorFactory;
import fl.motion.MotionBase;
import fl.motion.Motion;
import flash.filters.*;
import flash.geom.Point;
import fl.motion.MotionEvent;
import fl.events.*;
var __motion_Enemy_3:MotionBase;
if(__motion_Enemy_3 == null) {
__motion_Enemy_3 = new Motion();
__motion_Enemy_3.duration = 30;
// Call overrideTargetTransform to prevent the scale, skew,
// or rotation values from being made relative to the target
// object's original transform.
// __motion_Enemy_3.overrideTargetTransform();
// The following calls to addPropertyArray assign data values
// for each tweened property. There is one value in the Array
// for every frame in the tween, or fewer if the last value
// remains the same for the rest of the frames.
__motion_Enemy_3.addPropertyArray("x", [0]);
__motion_Enemy_3.addPropertyArray("y", [0]);
__motion_Enemy_3.addPropertyArray("scaleX", [1.000000,1.048712,1.097424,1.146136,1.194847,1.243559,1.292271,1.340983,1.389695,1.438407,1.487118,1.535830,1.584542,1.633254,1.681966,1.730678,1.779389,1.828101,1.876813,1.925525,1.974237,2.022949,2.071661,2.120372,2.169084,2.217796,2.266508,2.315220,2.363932,2.412643]);
__motion_Enemy_3.addPropertyArray("scaleY", [1.000000,1.048712,1.097424,1.146136,1.194847,1.243559,1.292271,1.340983,1.389695,1.438407,1.487118,1.535830,1.584542,1.633254,1.681966,1.730678,1.779389,1.828101,1.876813,1.925525,1.974237,2.022949,2.071661,2.120372,2.169084,2.217796,2.266508,2.315220,2.363932,2.412643]);
__motion_Enemy_3.addPropertyArray("skewX", [0]);
__motion_Enemy_3.addPropertyArray("skewY", [0]);
__motion_Enemy_3.addPropertyArray("rotationConcat", [0]);
__motion_Enemy_3.addPropertyArray("blendMode", ["normal"]);
__motion_Enemy_3.addPropertyArray("cacheAsBitmap", [false]);
__motion_Enemy_3.addEventListener(MotionEvent.MOTION_END, hurtPlayer);
// Create an AnimatorFactory instance, which will manage
// targets for its corresponding Motion.
var __animFactory_Enemy_3:AnimatorFactory = new AnimatorFactory(__motion_Enemy_3);
__animFactory_Enemy_3.transformationPoint = new Point(0.499558, 0.500000);
// Call the addTarget function on the AnimatorFactory
// instance to target a DisplayObject with this Motion.
// The second parameter is the number of times the animation
// will play - the default value of 0 means it will loop.
// __animFactory_Enemy_3.addTarget(<instance name goes here>, 0);
}
function hurtPlayer(event:MotionEvent):void {
this.parent.removeChild(this);
}
我試過它的幾個地方,既與animFactory_Enemy_3變量和motion_Enemy_3變量 - 得到相同的錯誤兩次。
Heyya,那怎樣?運氣好的話? – robertp 2011-01-12 20:03:06