all groups > flash data integration > august 2006 >
You're in the

flash data integration

group:

XML loads properly in .SWF but not in .AS


Re: XML loads properly in .SWF but not in .AS Raymond Basque
8/23/2006 11:26:31 AM
flash data integration:
contentXML is out of scope from the XML object;
Here are a few ways to deal with scope:

public function loadXML(myURL:String):Void {

var xmlOwner = this;
contentXML._OWNERREF = this;
contentXML.onLoad = function(success:Boolean):Void {
if (success) {
trace ("yay");
trace(this); // <===
trace(xmlOwner.contentXML); // <=====
trace(this._OWNERREF.contentXML); // <=========
} else { trace ("yay"); }
};


contentXML.load(myURL);
}


XML loads properly in .SWF but not in .AS maija_g
8/23/2006 2:56:37 PM
I have the following script which works jim-dandy when implimented as a frame
script in my .swf, but I don't want it there, I want it in a class I've created
called FigureItem. I've stripped the script down to just the part that loads
the XML. When the script is inside the .swf (without the class constructor,
obviously) 'trace(contentXML)' correctly returns the formatted XML. Inside the
..as 'trace(contentXML)' returns 'undefined'. SOMETHING is loading becase
'trace("yay")' returns 'yay'. (loadXML gets called by the FiguireItem movie
clip inside the .swf).

class FigureItem extends MovieClip {
var rollBox:MovieClip;
var contentXML:XML;
//
public function FigureItem() {
contentXML = new XML();

}
public function loadXML(myURL:String):Void {


contentXML.onLoad = function(success:Boolean):Void {
if (success) {
trace ("yay");
trace(contentXML);
} else {
trace ("yay");
}
};
contentXML.load(myURL);
}
}
Re: XML loads properly in .SWF but not in .AS maija_g
8/23/2006 3:55:36 PM
Thanks, but that doesn't seem to work. I copied and pasted and immediately got
a pile of errors. I commented out all the stuff you added in until there were
no errors and then started uncommenting until I got an error. Below is the
first one.

class FigureItem extends MovieClip {
var contentXML:XML;
//
public function FigureItem() {
contentXML = new XML();
contentXML.onLoad = function(success:Boolean):Void {
if (success) {
trace ("yay");
//trace(this); // <===
//trace(xmlOwner.contentXML); // <=====
//trace(this._OWNERREF.contentXML); // <=========
} else {
trace ("booooo");
}
};

contentXML.load(myURL);
}
}



/**Error** blah/blah/blah/FigureItem.as: Line 11: There is no property with
the name '_OWNERREF'.
contentXML._OWNERREF = this;
*/
Re: XML loads properly in .SWF but not in .AS maija_g
8/23/2006 4:00:14 PM
AddThis Social Bookmark Button