Jump to content
Search Community

AS2 - using delayedCall problem [SOLVED]

larryfroot test
Moderator Tag

Recommended Posts

Hi, I have a newbie problem, (and the miracle for me with greensock tweening is that I don't have a lot more of them). In order to avoid loadmovie and a tween from causing unwanted things happening, I put my loadMovie in a function that uses delayedCall - this is AS2, btw -

 

one_mc.onRelease=function(){

 

 

TweenMax.to(_root.band_mc,0.3,{_height:0.25, yoyo:1, overwrite:1});

 

TweenMax.to.delayedCall(1.0, loadOne);

 

function loadOne():Void {

_root.loader_mc.loadMovie("one.swf");

}

};

 

The tweens (there are a series of these clips on the page) work brilliantly. Unfortunately the loadMovies aren't loading any swf's. They all load via a single empty mc, if that has any bearing.

 

If anyone can help me on this I would be very very grateful. I would make a concerted effort to search deeper rather than ask here, but I promised my girlfriend that I wouldn't work this evening, and I need to make a flying start to tomorrow as a result of not working this evening. * Thank you* all very much for your kindness and your time.

Link to comment
Share on other sites

the problem is that you're using a nested function. Don't do that :) Nested functions are deleted in Flash as soon as the parent function finishes running. So by the time your delayedCall tries to call that function, it's gone. Put the function outside the other one (don't nest it) and you should be fine.

Link to comment
Share on other sites

Thank you for your time, and also thank you very much for getting back to me in my previous question. If its any consolation, I am learning quickly - and if it wasn't for the fact that I really like to construct my site using loadMovie then this would not be so critical for me to get right. I anticipate once I get this, then happy days and I will never be stuck at this point again; nor will anyone else in the future if this exchange becomes a swift reference point for such questions re loadMovie.

 

I understand the logic of flash - the syntax often escapes me, but I am learning by doing.

 

So I separated the functions (at least I hoped I had):

 

 

var pause_one_loading:TweenMax = new TweenMax.to.delayedCall(10.0,load_one);
function load_one():Void {
   _root.loader_mc.loadMovie("pages/one.swf");
}

 

and then I call it from:

 

one_mc.onRelease=function(){

TweenMax.to(_root.band_mc,0.3,{_height:0.25, yoyo:1, overwrite:1});
load_one.play();
}

 

But that may well, strictly speaking, be a nested function of sorts, so next I tried to assign two clearly separate functions to the same event:

 

one_mc.onRelease=function(){

load_one.play();

}
one_mc.onRelease=function(){

 _root.loader_mc.loadMovie("pages/one.swf");

}

 

Both times I get the same error, "there is no method with the name 'play'"

 

I know you have enough of a drain on your time to refer questions about loadMovie and tween clashes elsewhere, but perhaps this exchange can be quickly referred to in future questions regarding delaying a loadMovie call? I had no idea that delayed.Call existed, and it is a godsend. I have skimmed the documentation but my eye was geared towards tweening rather than anything else. Best regards, LF

Link to comment
Share on other sites

I noticed two problems for sure:

 

1) wrong syntax. You either call "new TweenMax(...)" or "TweenMax.to(...)" or "TweenMax.delayedCall(...)" but you tried combining them all.

 

BAD: var pause_one_loading:TweenMax = new TweenMax.to.delayedCall(10.0,load_one);

GOOD: TweenMax.delayedCall(10, load_one);

 

2) You have a "load_one" function, and then you're trying to call a method ("play()") on that function. You cannot call a method on a method. If you want to run the load_one function just do load_one(), not load_one.play().

Link to comment
Share on other sites

Thank You! I have removed my dunces cap and now have delayed.Calls coming out of my earholes. Thank you very much for your patience with me, appreciated.

 

PS Am looking for the way to mark this thread as solved, but can't seem to find the doo dah to make it happen...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...