Go Back   kirupaForum > Flash > ActionScript 1.0/2.0

Reply
 
Thread Tools Display Modes
Old 11-26-2009, 01:40 PM   #1
ricosushi
Registered User
Issue when loading XML in as2 class

Hi

i am developing a AS2 class that loads a XML but i cant call a function from inside the onLoad function.


Heres the code:
Code:
// CONSTRUCTOR
	public function Curso(target:MovieClip, path:String){
		
		// set vars
		this.path = path;
		this.targetMC = target;
				
		loadXML(path);
		
		
	}// constructor
	
	
	public function loadXML(file:String):Void{
		
		//trace("loadXML" + file);
		
		// load xml
		var myXML:XML = new XML();
		myXML.ignoreWhite = true;		
		
		myXML.load(path);
		
		myXML.onLoad = function(success:Boolean){
			// if not errors while loading...
			if(success){
			
				// create the list
				list = myXML.childNodes[0].childNodes;
			
				// read the list array
                                // CAN CALL THIS FUNCTION IS NOT SHOWING THE list var
				readList();
				
			}else{
				trace("ERROR LOADING THE XML");
			}
		}
	}


       public function readList():Void{
		
		trace('readList ' + list);
	}

HERES THE COMPLETE CLASS
Code:
class Curso{
	
	
	// PROPIEDADES //////////////////////
	
	public var path:String;	
	public var list:Array;
	private var targetMC:MovieClip;
	
	
	// depths
	private var holderDepth:Number = 10;
	
	private var holder:MovieClip;
	
	
	
	// METODOS //////////////////////
	
	// CONSTRUCTOR
	public function Curso(target:MovieClip, path:String){
		
		// set vars
		this.path = path;
		this.targetMC = target;
				
		loadXML(path);
		
		
	}// constructor
	
	
	public function loadXML(file:String):Void{
		
		//trace("loadXML" + file);
		
		// load xml
		var myXML:XML = new XML();
		myXML.ignoreWhite = true;		
		
		myXML.load(path);
		
		myXML.onLoad = function(success:Boolean){
			// if not errors while loading...
			if(success){
			
				// create the list
				list = myXML.childNodes[0].childNodes;
			
				// read the list array
				readList();
				
			}else{
				trace("ERROR LOADING THE XML");
			}
		}
	}
	

	public function readList():Void{
		
		trace('readList ' + list);
	}
	
	// Comienza la aplicacion
	public function startCursos():Void{
		
		// pon holder
		creaHolder();
		
		
	
	}
		
		
	
	// Creates holder
	private function creaHolder():Void{
		// crea holder
		holder = targetMC.createEmptyMovieClip("holder_MC", holderDepth);
	}
	
	
	// pon items 
	private function ponItems():Void{
		
	}
	
	
}
ricosushi is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 11-26-2009, 02:16 PM   #2
ricosushi
Registered User
Nevermind.

found the solution workaround heres the link to the solution:

http://www.actionscript.org/forums/s...751#post945751
ricosushi is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:15 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com