Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 6 of 6

Thread: [AS3] XML class problems

  1. #1

    [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:
    Code:
    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);  
      }
     
     }
    }
    And my flash look like
    Code:
    import classes.xmlClass;
    var xml:xmlClass = new xmlClass("xml/main.xml");
    But i cant get it to work :S

    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

  2. #2
    did you try importing the events classes?

    Code:
    import flash.events.*;

  3. #3
    Hi, pear!

    no i havent. and it handle my first output.

    But it still dosnt work.

    My class is made right ?

    /cheers

  4. #4
    OMG dude.

    i forgot the
    import flash.net.URLRequest;

    sry. thank you for open my eyes!

  5. #5

  6. #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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012