Skip to main content
Participating Frequently
November 30, 2006
Question

How do you do anything with XML in OO?

  • November 30, 2006
  • 2 replies
  • 192 views
I have below in my class

myxml.onLoad = function() {
//reference the XML text here
//can't refence any variables in my class from this inline function, you can only access clips on the stage/root
//what the hell am I suppose to do
//why can't this function be made synchronous without some major hack
}
This topic has been closed for replies.

2 replies

Inspiring
December 1, 2006
Inside callback handlers the class members are out of scope. You can solve this in several ways. One of them is using a local reference to the class:

var thisObj=this;
myxml.onLoad = function() {
thisObj.yourclassmember....

Another one is using the Delegate Class (hit F1 in Flash and search for Delegate). And you can use the events of a class in a much more easier way by just defining methods with the same name. Just look at how you use a listener.

Now, first of all, you can do a whole lot of things with XML in Flash. Secondly, Flash doesn't suck. But some people seem to hate books and help-files and just ventilate their frustrations on forums. Grow up.

Inspiring
December 1, 2006
That isn’t just a function. It’s an event handler. You need to reference your clips one wave up (its parent mc). Try adding one of the following as a prefix to what you are trying to connect to;

this._parent
this._parent._parent

But you shouldn’t be having any problems accessing ‘myxml’ properties inside this event handler. Post more code.