Any idea where I’m going wrong? Not quite sure how to dynamically create functions in AS3. Should I just create a trail class, instead of having this in the class of the moving object?
1120: Access of undefined property trailFunction.
// My attempt
//Create trail
var Trail = new MovieClip();
Trail.name = this.name + "Trail" + tC;
++tC;
Trail.moveTo(x-xV, y-yV);
Trail.lineStyle(3, 0xFFFFFF, 100, false, "none", "none");
Trail.lineTo(x, y);
Trail.trailControl = new Timer(50);
Trail.trailControl.addEventListener(TimerEvent.TIMER, trailFunction);
Trail.trailControl.start();
Trail.trailFunction = function() {
alpha -= .1;
if (this._alpha <= .1) {
Trail.trailControl.stop();
Trail.trailControl.removeEventListener(TimerEvent.TIMER, trailFunction);
}
};
parent.addChild(Trail);
//Old AS2 Script
this.Trail = Trails.createEmptyMovieClip("Trail"+_root.trailDepth, _root.trailDepth);
_root.trailDepth++;
if (_root.trailDepth>=16999) {
_root.trailDepth = 15010;
}
this.Trail.moveTo(this._x-xvel, this._y-yvel);
this.Trail.lineStyle(3, 0xFFFFFF, 100, false, "none", "none");
this.Trail.lineTo(this._x, this._y);
this.Trail.fadeSpeed = trailFadeRate;
this.Trail.onEnterFrame = function() {
this._x += _root.scrollVel;
this._alpha -= this.fadeSpeed;
if (this._alpha<=0) {
removeMovieClip(this);
}
};
}