all groups > flash actionscript > january 2005 >
You're in the

flash actionscript

group:

scope within classes


scope within classes adamjbrown
1/19/2005 11:11:41 PM
flash actionscript:
Im having problems with scope from within a class and was wondering if anyone
could help. I have a class that loads an array of external mp3s. I was having
trouble with the Sound.onLoad method working correctly so I instead am using a
function to check the progress of the Sound that is loading. When the file is
loaded then it calls a function to load the next. This works fine when not
inside a class. Problem is thats where i need it. When its built in a class
it will not call the function. Heres an example of the code.

private function checkProgress(the_sound:Sound):Void
{
if(the_sound.getBytesLoaded() >= the_sound.getBytesTotal())
{
loadNext();
}
}

public function loadNext()
{
code that creates sound object and setsInterval to call
checkProgress
}

If tried using a reference to the class similar to refObj.loadNext() and it
still doesn't work. Does anyone know how to get the function to call correctly
from within the if statement?
Re: scope within classes Popeye the Sailorman
8/30/2005 12:00:00 AM
I have similar problems and noticed that if a reference to the class (refObj)
is defined as a local variable in the constructor rather than a property
(defined on class level) it does work (for my example). May be you could try
that.
AddThis Social Bookmark Button