I’m making a little movie where, when a button is clicked, a swf file is loaded into a movie clip using the MovieClipLoader object, and on the onLoadInit event, the clip’s alpha and _x are both eased using custom prototype methods. When I first test the movie, it works fine - it fades/moves in correctly. If I click the button while it’s still easing, it again reloads and looks fine - but for some reason, once I wait for it to fully ease in, when I click the button, it first loads, then the Alpha eases up to 100, and THEN it eases to the _x… I can’t figure out why this is happening this way. Any ideas? Thanks!
My AS for the button is:
button.onRelease = function() {
tip2._alpha = 0;
tip2._rotation = 90;
tip2._x = 700;
tlistener = new Object ();
tlistener.onLoadInit = function () {
tip2.easeX(565, .5);
tip2.AlphaUp(5, 100);
}
tip2_mcl = new MovieClipLoader ();
tip2_mcl.addListener (tlistener);
tip2_mcl.loadClip ("---url----", tip2.tip2swf);
}
And the easing functions are from the Easing AS tutorial on this site:
MovieClip.prototype.AlphaUp = function(speed:Number, top:Number) {
var _this:MovieClip = this;
var aux:MovieClip = _this.createEmptyMovieClip( "alphaUp_aux" , 1221 );
aux.onEnterFrame = function(){
if (_this._alpha < top) {
_this._alpha += speed;
}
}
}
MovieClip.prototype.easeX = function( to:Number , speed:Number , endF:Function , endO , endP:Array ){
var _this:MovieClip = this;
var aux:MovieClip = _this.createEmptyMovieClip( "easeX_aux" , 1223 );
var previousPosition:Number = this._x;
if( isNaN(speed) || speed == undefined || speed == '' || speed <= 1 ) speed = 1.2;
if( _this._x != to ){
aux.onEnterFrame = function(){
_this._x = to - ( to - _this._x ) / speed;
if( _this._x == previousPosition ){
_this._x = to;
this.removeMovieClip();
if( endF ) endF.apply( endO , endP );
}
previousPosition = _this._x;
}
} else {
if( endF ) endF.apply( endO , endP );
}
}