Jitze.Pieter
%Europe/Berlin %692 %2010, 16:37
Hallo allemaal,
Ik gebruik op het moment 2 classes: Main en LoadImages.
De main class doet nog niet zo veel die vult alleen een array met de data die wordt opgehaald door LoadImages uit een extern xml file.
Ik Krijg alleen de array niet terug terwijl hij wel de gehele code uitvoert van LoadImages.
Waarom kent hij de array niet waar hij hem moet returnen?
Hoop dat iemand mij kan helpen? alvast bedankt.
Code
package src
{
import flash.display.MovieClip;
public class Main extends MovieClip
{
public var loadImages:LoadImages = new LoadImages();
public var imageArray:Array = new Array();
public function Main()
{
this.imageArray = this.loadImages.getImages();
trace(this.imageArray);
}
}
}
Loadimages:
package src
{
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class LoadImages
{
public var loader:URLLoader = new URLLoader();
public var urlRequest:URLRequest = new URLRequest("xml/images.xml");
private var _imgList:XML;//holds the content of the loaded xml file
public var sourceArray:Array = new Array();//array to hold all the source locations from the xml file
//constructor
public function LoadImages()
{
trace(" hello from constructor LoadImages ");// hij komt hier
/*this.loader.load(this.urlRequest);
this.loader.addEventListener(Event.COMPLETE, onCompleteHandler);*/
}
public function getImages():Array
{
trace(" hello from function getImages ");// hij komt hier
this.loader.load(this.urlRequest);
this.loader.addEventListener(Event.COMPLETE, onCompleteHandler);
trace(sourceArray);
return(sourceArray);
}
private function onCompleteHandler(event:Event):void
{
trace(" hello from function onCompleteHandler ");// hij komt hier
_imgList = new XML(event.target.data);// _imgList contains all the xml data from the xml file
// loop to push all the source locations from the xml file into an array
for (var i:int = 0; i < _imgList.image.source.length(); i++)
{
sourceArray.push(_imgList.image.source[i]);
}
}
}
}
Ik gebruik op het moment 2 classes: Main en LoadImages.
De main class doet nog niet zo veel die vult alleen een array met de data die wordt opgehaald door LoadImages uit een extern xml file.
Ik Krijg alleen de array niet terug terwijl hij wel de gehele code uitvoert van LoadImages.
Waarom kent hij de array niet waar hij hem moet returnen?
Hoop dat iemand mij kan helpen? alvast bedankt.
Code
package src
{
import flash.display.MovieClip;
public class Main extends MovieClip
{
public var loadImages:LoadImages = new LoadImages();
public var imageArray:Array = new Array();
public function Main()
{
this.imageArray = this.loadImages.getImages();
trace(this.imageArray);
}
}
}
Loadimages:
package src
{
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class LoadImages
{
public var loader:URLLoader = new URLLoader();
public var urlRequest:URLRequest = new URLRequest("xml/images.xml");
private var _imgList:XML;//holds the content of the loaded xml file
public var sourceArray:Array = new Array();//array to hold all the source locations from the xml file
//constructor
public function LoadImages()
{
trace(" hello from constructor LoadImages ");// hij komt hier
/*this.loader.load(this.urlRequest);
this.loader.addEventListener(Event.COMPLETE, onCompleteHandler);*/
}
public function getImages():Array
{
trace(" hello from function getImages ");// hij komt hier
this.loader.load(this.urlRequest);
this.loader.addEventListener(Event.COMPLETE, onCompleteHandler);
trace(sourceArray);
return(sourceArray);
}
private function onCompleteHandler(event:Event):void
{
trace(" hello from function onCompleteHandler ");// hij komt hier
_imgList = new XML(event.target.data);// _imgList contains all the xml data from the xml file
// loop to push all the source locations from the xml file into an array
for (var i:int = 0; i < _imgList.image.source.length(); i++)
{
sourceArray.push(_imgList.image.source[i]);
}
}
}
}