PHP gevorderde |
|
Beste,
Ik ben bezig met OOP. Nu heb ik een XML Loader geschreven:
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class LoadXML extends Sprite
{
private var Url:String;
private var XML_Url:URLRequest;
private var XML_Loader:URLLoader;
public static var XML_Data:XML;
public function LoadXML(Url:String)
{
this.Url = Url;
XML_Laden();
}
private function XML_Laden():void
{
XML_Url = new URLRequest(Url);
XML_Loader = new URLLoader(XML_Url);
XML_Loader.addEventListener(Event.COMPLETE,XML_Lezen);
}
public function XML_Lezen(e:Event):void
{
XML_Data = new XML(e.target.data);
//trace(XML_Data); <-- Dit werkt hier
}
}
}
package { import flash.display.Sprite; import flash.events.Event; import flash.net.URLLoader; import flash.net.URLRequest; public class LoadXML extends Sprite { private var Url:String; private var XML_Url:URLRequest; private var XML_Loader:URLLoader; public static var XML_Data :XML ; public function LoadXML(Url:String) { this.Url = Url; XML_Laden(); } private function XML_Laden():void { XML_Url = new URLRequest(Url); XML_Loader = new URLLoader(XML_Url); XML_Loader.addEventListener(Event.COMPLETE,XML_Lezen); } public function XML_Lezen(e:Event):void { XML_Data = new XML(e.target.data); //trace(XML_Data); <-- Dit werkt hier } } }
en me beginklasse waar ik het wil oproepen
package {
import flash.display.Sprite;
public class ImageGallery extends Sprite
{
public function ImageGallery()
{
var bla:LoadXML = new LoadXML("albums.xml");
trace(LoadXML.XML_Data);
}
}
}
package { import flash.display.Sprite; public class ImageGallery extends Sprite { public function ImageGallery() { var bla:LoadXML = new LoadXML("albums.xml"); trace(LoadXML.XML_Data); } } }
De xml word ingeladen via die klasse. Alleen hoe kan ik nu in de beginklasse die gegevens ophalen??
|