-
Multiple onEnterFrame functions Stall - LIL HELP?
Hey All,
I've searched this quite a bit and can't seem to find an alternative.
I'm trying to run multiple onEnterFrame functions by using and "if" conditional in one to trigger the next.
Something like.....
onEnterFrame = function () {
various tween like actionscript statements;
if(some condition in the middle of this animation){
someNewFunction();
}
}
function someNewFunction() {
onEnterFrame = function () {
various tween like actionscript statements;
}
}
The result is that when someNewFunction() is called based on conditions met in the first onEnterFrame a second onEnterFrame function [within someNewFunction()] is called and they both stall.
I have created a work around in which all the statements I was going to run in the second onEnterFrame [within someNewFunction()] now fall in the "if" statement of the first.
But I'm thinking there is a better way.
Any help would be Greatly Appreciated!!!!!
jub
-
first i'd suggest attaching the enterframes to objects, ie: this.onEnterFrame, and anotherclip.onEnterFrame
and delete them when they are not needed, ie: delete this.onEnterFrame
gparis
-
Hey jparis,
Thanks for the reply. I see what your saying although I have yet to get it to function. Here's the code. Any help is MUCH appreciated!!!!
init();
function init() {
attachMovie("mcLogIn", "mcLogIn", 0);
mcLogIn._x = 497.5;
mcLogIn._y = 200;
}
mcLogIn.mcLogInYes.onPress = function() {
logInOut(true);
}
function logInOut(logInYes:Boolean) {
if(logInYes == true) {
var easing:Number = 0.3;
var targetXscale:Number = 10;
var targetYscale:Number = 10;
var targetAlpha:Number = 0;
this.onEnterFrame = function () {
var al:Number = (targetAlpha - mcLogIn._alpha) * easing;
var xs:Number = (targetXscale - mcLogIn._xscale) * easing;
var ys:Number = (targetYscale - mcLogIn._yscale) * easing;
mcLogIn._xscale += xs;
mcLogIn._yscale += ys;
mcLogIn._alpha += al;
if(mcLogIn._alpha <= 3) {
homeToFront();
}
}
}
}
function homeToFront() {
attachMovie("mcHomeScreen", "mcHomeScreen", 10);
mcHomeScreen._x = 650;
mcHomeScreen._y = 300;
mcHomeScreen._xscale = 10;
mcHomeScreen._yscale = 10;
mcHomeScreen._alpha = 0;
var easing:Number = 0.5;
var targetXscale:Number = 100;
var targetYscale:Number = 100;
var targetAlpha:Number = 100;
this.onEnterFrame = function () {
var al:Number = (targetAlpha - mcHomeScreen._alpha) * easing;
var xs:Number = (targetXscale - mcHomeScreen._xscale) * easing;
var ys:Number = (targetYscale - mcHomeScreen._yscale) * easing;
mcHomeScreen._xscale += xs;
mcHomeScreen._yscale += ys;
mcHomeScreen._alpha += al;
if(mcHomeScreen._alpha >= 65) {
mainNavToFront();
if(mcHomeScreen._alpha >= 99.5) {
delete this.onEnterFrame;
trace("deleted");
}
}
}
}
function mainNavToFront() {
attachMovie("mcNav", "mcNav", 12);
mcNav._alpha = 20;
var targetAlpha:Number = 100;
var easing:Number = 0.5;
this.onEnterFrame = function() {
var al:Number = (targetAlpha - mcNav._alpha) * easing;
this._alpha += al;
}
}
RIGHT WHEN.....
if(mcHomeScreen._alpha >= 65) {
mainNavToFront();
BECOMES "TRUE" mainNavToFront(); FUNCTIONS
BUT homeToFront(); STOPS NEVER REACHING THE NEXT NESTED "IF" CONDITIONAL.
IT WORKS FROM logInOut() TO homeToFront(); AS ONE IS COMPLETE AND THE NEXT STARTS. ALTHOUGH I SEE NOW I NEVER DO DELETE THE EVENT[S].
jub
-
Got It!!!
Thanks for the insight jparis!
jub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|