Ask a Question related to Macromedia Flash, Design and Development.
-
Woutert #1
losing this pointer in onLoad callback
Hi There,
I am having trouble with object pointers when i am loading an external XML
file. I create a new XML object within a movieclip.
On the onLoad of the XML object i call a function (method) cb_onLoadXML of
the movieclip. When the callback function is called,
i seem to have lost the this pointer of the movieclip.
I am using Flash 5 for this particular project (customer does not have the
budget for updating the application :-))
Does anyone have any idea why this is and how i can prevent it?
To make things easier to understand i have included some code:
// movieclip mcSendResults
function doSend() {
this.anyvar = 5;
this.objXML = new XML();
this.objXML = ignoreWhite = true;
this.objXML.onLoad = cb_onLoadXML;
this.objXML.load(path);
}
function cb_onLoadXML(succes) {
nodeRoot = this.objXML;
if (this.anyvar < 10) {
do xml parsing
}
}
My problem is that the nodeRoot is empty. I think because the method is
called in a callback structure of the XL object.
The movieclip this pointer is lost.
thanx for any hints or tips.
Woutert Guest
-
Need help: Problems with XML.onLoad()
:confused; Need some help with a problem i have in variable scoping. I was twidling around with one of Macromedia's sample files --- the... -
onload validation
i want an error message THAT LOOKS LIKE THE FLASH FORM ERROR MESSAGES to appear as soon as a form loads. I wrote this but it doesnt work <cfform... -
Mouse pointer flickers between hand and pointer
I have created a menu. On the menu options for some reason my mouse pointer flickers between a hand and pointer. Did anyone have this problem and... -
What is a callback?
Hello everyone, I've seen the word "callback" used in a few Changelogs for a few modules saying that a few callbacks were fixed in the module. I... -
onload/onopen
once i updated to office 2000 sp3 and windows 2000 sp4, access will no longer fire up the onload and onopen. -
Ciaran #2
Re: losing this pointer in onLoad callback
The callbacks are called without the context you have in mind. I normally do
this by stashing a handle in the XML object. This works in MX, don't know
about 5.
x = new XML();
x.context = callingThis; // or whatever
x.onLoad = function(status) {
this.context.onLoad(status); // relay to instigating object
}
callingThis.onLoad = function(status) { ... what you want to do
x.load(someUrl); ....
It would have been nice if they had bothered to mention the callback
context, but they like people to guess .....
Ciaran
"Woutert" <no.spam@12move.nl> wrote in message
news:3f968d33$0$58709$e4fe514c@news.xs4all.nl...> Hi There,
>
> I am having trouble with object pointers when i am loading an external XML
> file. I create a new XML object within a movieclip.
> On the onLoad of the XML object i call a function (method) cb_onLoadXML of
> the movieclip. When the callback function is called,
> i seem to have lost the this pointer of the movieclip.
> I am using Flash 5 for this particular project (customer does not have the
> budget for updating the application :-))
>
> Does anyone have any idea why this is and how i can prevent it?
>
> To make things easier to understand i have included some code:
>
> // movieclip mcSendResults
> function doSend() {
> this.anyvar = 5;
>
> this.objXML = new XML();
> this.objXML = ignoreWhite = true;
> this.objXML.onLoad = cb_onLoadXML;
> this.objXML.load(path);
> }
>
> function cb_onLoadXML(succes) {
> nodeRoot = this.objXML;
>
> if (this.anyvar < 10) {
> do xml parsing
> }
> }
>
> My problem is that the nodeRoot is empty. I think because the method is
> called in a callback structure of the XL object.
> The movieclip this pointer is lost.
>
> thanx for any hints or tips.
>
>
>
Ciaran Guest



Reply With Quote

