I’m making a dynamic speedometer in Flash8 - AS2.0, using XML as my datasource. I get to load the XML doc just fine, manipulate the data and so on, but for some reason I cannot get my XML function to call another function. :stunned:
I’ve added a GIF explaining what I’m trying to do. Please have a look at it as it also holds the code as a whole.
Any ideas why this doesn’t work? I can call the calcDegree function (or any other functions for that matter) from every other function or from the constructor function.
Any clues?
Because the scope is not getXML class… the time you execute this
xmlData.onLoad = xmlLoad;
when executed on this event scope in xmlLoad function will be xmlData because that function is assigned to the event of xmlData object…
you will have to use Delegate to make xmlLoad in the scope of your own class (getXML)
ActionScript Code:
[FONT=Courier New][LEFT]xmlData.[COLOR=#0000FF]onLoad[/COLOR] = Delegate.[COLOR=#000080]create[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]this[/COLOR], xmlLoad[COLOR=#000000])[/COLOR];
[/LEFT]
[/FONT]
Because the scope is not getXML class… the time you execute this
xmlData.onLoad = xmlLoad;
scope in xmlLoad function will be xmlData because that function is assigned to the event of xmlData object…
you will have to use Delegate to make xmlLoad in the scope of your own class (getXML)
xmlData.onLoad = Delegate.create(this, xmlLoad);
Thanks a million times!! :p:
Kirupa actually has a read up on this subject too: http://www.kirupa.com/web/xml/XMLspecificIssues3.htm
Anyway! Thanks again. Works like a charm now!
Have a good day.
Welcome
great to hear that…