Results 1 to 6 of 6
Thread: [AS3] XML class problems
-
August 20th, 2008, 04:07 AM #17Registered User
posts[AS3] XML class problems
Hi All
Im working on my first AS3 class, but are stocked with a problem.
My idea is to make a xml class, where i gave the url for the xml doc in the flash files.
my class right now look like:
And my flash look likeCode:package classes { public class xmlClass { public var xmlMenu:XML; public var xmlContent:XML; public var url:String; public function xmlClass(url:String=""){ var xmlLoader:URLLoader = new URLLoader(); xmlLoader.addEventListener(Event.COMPLETE, showXML); xmlLoader.load(new URLRequest(url)); } public function showXML(e:Event):void { trace("XML Loaded"); XML.ignoreWhitespace = true; var xmlMenu:XML = new XML(event.target.data); var xmlContent:XML = new XML(event.target.data); } } }
But i cant get it to work :SCode:import classes.xmlClass; var xml:xmlClass = new xmlClass("xml/main.xml");
i get the output:
1046: Type was not found or was not a compile-time constant: Event.
I really hope somebody can help!
cheers!
/rosenberg
-
August 20th, 2008, 04:20 AM #2
did you try importing the events classes?
Code:import flash.events.*;
-
August 20th, 2008, 04:52 AM #37Registered User
postsHi, pear!
no i havent. and it handle my first output.
But it still dosnt work.
My class is made right ?
/cheers
-
August 20th, 2008, 05:00 AM #47Registered User
postsOMG dude.
i forgot the
import flash.net.URLRequest;
sry. thank you for open my eyes!
-
August 20th, 2008, 05:02 AM #5
-
August 20th, 2008, 03:57 PM #6
You dont need to put ingnorewhitespace anymore I believe. Also you don't need to redeclare a variable if you already did it at the top of the class.
Check out my XML Loader Class

Reply With Quote




Bookmarks