A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Trying to create a dynamic AS that output a XML document.

  1. #1
    Senior Member
    Join Date
    Nov 2004
    Posts
    100

    Trying to create a dynamic AS that output a XML document.

    I am trying for first time actionscript as package document.

    And I am trying to make run a Doc class that load an XML file and output the results on trace.

    I don't know where are my errors:

    Code:
    package
    {
    	import flash.display.MovieClip;
    	import flash.events.*;
    	import flash.net.*;
    	import flash.xml.*;
    	
    	
    	public class MenuExpander extends MovieClip
    	{	
    		public function MenuExpander() {}
    		
    		private var xmlLoader:URLLoader = new URLLoader();
    		private var xmlData:XML = new XML();
    	
    		xmlLoader.load(new URLRequest("links.xml"));
    		xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
    	
    		private function LoadXML(event:Event):void
    		{
    			xmlData = new XML(event.target.data);
    			trace(xmlData);
    		}
    	}	
    }
    when I try to run the flash, it gives me error:
    1120: Access of undefined property xmlLoader.
    1120: Access of undefined property LoadXML.


    What can be my problem?

    tia
    HELP!

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Try this;
    Code:
    package 
    {
    	import flash.display.MovieClip;
            import flash.display.URLLoader;
    	import flash.events.Event;
    	import flash.net.URLRequest;
    	public class MenuExpander extends MovieClip
    	{
    		private var xmlLoader:URLLoader = new URLLoader  ;
    		private var xmlData:XML;
    		public function MenuExpander ()
    		{
    			xmlLoader.load (new URLRequest("links.xml"));
    			xmlLoader.addEventListener (Event.COMPLETE,LoadXML);
    		}
    		private function LoadXML (event:Event):void
    		{
    			xmlData = new XML(event.target.data);
    			trace (xmlData);
    		}
    	}
    }
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    Senior Member
    Join Date
    Nov 2004
    Posts
    100
    oh wow. It worked.

    I saw what you did, I guess I got a bad understanding of how constructor functions works.


    Thanks
    HELP!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center