Loading and viewing XML when a class object is created..Help Please

Hello,
I have writing a simple class which has a method that gets invoke when the object of the class is created. I am able to view the loaded XML content when I trace it with in my class method, but cannot assign the content to a instance variable using the mutator method. So the process goes like this:
Class object is instantiated
Class construtor then calls the loadXML method which laods the XML
And then assigns the XML to a class instance variable.
So now if I would like to access the loaded XML through class object, I should be able to see the loaded xml content which I am not able to see. I have spent over few hours and cannot get the class object to display the loaded XML content. I would highly appreciate it if someone can help in the right direction, please.
[code]
package com.as3.app
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;
    import flash.net.*;
    public class Cars extends MovieClip {
           public var _CarList:Object;
           public function Quiz()
              super();
              loadCars();
// ===========================================================
//           CARS GETTER SETTER
// ===========================================================
        public function set Cars(val:XML):void
            this._CarList = val;
        public function get Cars():XML
            return this._CarList;
// ===========================================================
//            LOAD QUESTIONS FROM XML
// ===========================================================
        public function loadcars()
            var myXML:XML;
            var myLoader:URLLoader = new URLLoader();
            myLoader.load(new URLRequest("xml/cars.xml"));
            myLoader.addEventListener(Event.COMPLETE, processXML);
            function processXML(e:Event):void
                myXML = new XML(e.target.data);  
                Cars = myXML;                 // Assigning the loaded xml data via mutator method to the _CarList;
//=============================================================  
                              INSTANTIATING THE CLASS OBJECT
//=============================================================
package com.as3.app
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;
    import flash.net.*;
    import com.as3.app.*;
    public class DocumentClass extends MovieClip {
        public var c:Car;
        public function DocumentClass()
            super();
            c = new Cars();  
            trace(c.Cars);
[/code

where you have:
            super();
            c = new Cars();  
            trace(c.Cars);
c.Cars will not trace as the loaded xml, because it will not have loaded in time. After some time it should presumably have the correct value.
loading operations in actionscript are asynchronous, so your nested function which is acting as the listener ( function processXML(e:Event):void) only ever executes when the raw xml data has loaded and that is (I believe, not 100% sure) always at least one frame subsequent to the current one.
In general I would consider it bad practise to use nested functions like that, but I don't think its contributing to your issues here. I think its just a timing issue given how things work in flash....
Additional observation:
your Cars constructor calls loadCars() and your loadCars method is defined as:
public function loadcars()
I assume its just a typo in the forum that the uppercase is missing in the function name....

Similar Messages

  • Safari is having problem loading messages in gmail. When using other browsers, there is no problem loading and viewing the messages. What is going on? please help!

    safari is having problem loading messages in gmail. When using other browsers, there is no problem loading and viewing the messages. What is going on? please help!

    I should have explained further. The game opens in a new window over to the upper left of my screen, leaving the original page underneath. I tried minimizing it so that I could get to my toolbar and did the View > Zoom > Reset. This has no effect. The lower portion of the game is still not showing. Using other browsers the window or frame of the game is much larger, therefore everything shows.

  • Problem with  whitespace  then loading and saving xml

    i do not know how to handle this problem. i modifed a texteditor to send XML to a server and load XML back to the container.
    but then i do changes to the Textlayout it shows up like this --->
    Text in Container not modifed
    Text in Container modifed ---> with space beween the colorchanged string
    Text inContainersend and loaded ---> i think this has something to to with the
    TextFilter.export(_textFlow,TextFilter.TEXT_LAYOUT_FORMAT,ConversionType.XML_TYPE)
    can someone give me a hint...

    Hi,
    the link is --->
    http://www.horstmann-architekten.de/contentmanagment/SimpleEditor.html
    its a modified example of the texteditor provided by Adobe. You can send a xml to the server. and also read it from the server. You just use the xml identifer to give the xml a name.
    Try it out:
    1.  change the text and
    2.  give a XML-Identifer
         and then send it to the server. --> send to server
    3.  type in the XML-Identifer you have used and
    4.   load it from the server ---> Load from Server Button
    evering works ok exept the columns formating.
    I Think the colums Formating is not embeded in the XML as it should be. I attached the Files. (Newbie programmer)
    With best regards
    Michael Sprinzl
    --- robin.briggs <[email protected]> schrieb am Do, 17.9.2009:
    Von: robin.briggs <[email protected]>
    Betreff: Problem with  whitespace  then loading and saving xml
    An: "Michael sprinzl" <[email protected]>
    Datum: Donnerstag, 17. September 2009, 2:12
    Sounds like you have two different issues going on: (1) inline graphics aren't coming out correctly when you use the TextLineFactory, and (2) columns aren't working correctly. It's difficult for me to tell by looking at the application you link what is going wrong. One of the examples does seem to have columns working -- can you be more specific about what you're doing, and what results you are seeing? As for the inline graphics, there is a timing issue involved with using URLs, due to the asynchronous loading. See this comment in the docs for TextFlowTextLineFactory:
    Note: When using inline graphics, the source property of the InlineGraphicElement object   must either be an instance of a DisplayObject or a Class object representing an embedded asset.   URLRequest objects cannot be used. The width and height of the inline graphic at the time the line   is created is used to compose the flow.
    - robin

  • How can I load and save text using FileReference class

    Let me start by saying I have no intention of using php and I can't wait until flash cs5 comes out with its new read/write capabilities
    I want to load and save XML files (stored on my local hard-drive) in AS3.
    I am using the FileReference class.
    Firstly I have noticed that when using FileReference.save if you replace an existing file instead of writing over the file data is appended to the end of the file. Can I make it so the file is overwritten (as it should be) or make it impossible for the user to save in such a situation.
    Secondly I want to load in text from an external file using FileReference.load I know that somehow you use FileReference.browse first to get it to work but I want to know exactly how to do it.
    I have looked for a tutorial about loading text in this manner and have not found one.
    Any help would be much appreciated especially if you could point me in the direction of a relevant tutorial
    Thanks

    the filereference class is for downloading and uploading files.
    if you want to load xml, use the xml class.
    and, if you want to write to an xml file and don't want to use server-side code, wait.

  • Firefox is slow to load and view pages and repeated "Firefox is not responding" message

    Firefox is quite slow to load and view pages with and I keep getting the "Firefox is not responding" message.
    I have the latest version, plus the latest Adobe Flash Player, Shockwave Player, etc.

    Note that Firefox 36 has been released officially.
    *https://www.mozilla.org/en-US/firefox/36.0/releasenotes/
    It is possible that your security software (firewall, anti-virus) blocks or restricts Firefox or the plugin-container process without informing you, possibly after detecting changes (update) to the Firefox program.
    Remove all rules for Firefox and the plugin-container from the permissions list in the firewall and let your firewall ask again for permission to get full, unrestricted, access to install for Firefox and the plugin-container process and the updater process.
    See:
    *https://support.mozilla.org/kb/Server+not+found
    *https://support.mozilla.org/kb/Firewalls
    *https://support.mozilla.org/kb/fix-problems-connecting-websites-after-updating

  • Camera takes along time to load and freeze's when taking video or picture

    When it freeze's it dont let me go to the home screen.... it takes a while to load and i have never done anything to it. Someone please help.!!!!

    Try a reset. It cures many ills and nothing is lost.
    Reset iPod touch:  Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.

  • Load and view into blobs in table outside of Apex installation

    Is it possible to use APEX to load and view blob types(pds, docs etc) into a table with a blob type
    where the table is in a separate database and instance then where Apex is installed? So would Apex be able to access
    this table thru a db link?

    Hi Kenn,
    You are probably better off posting this request in this forum User Interface Development in ABAP as you are more likely to get a response.
    Cheers,
    Neil.

  • Having upgraded from iPhoto 11 to iPhoto 2.0 (531) it now loads but crashes after a minute or so and none of the buttons work. Can anyone help please.

    Having upgraded from iPhoto 11 to iPhoto 2.0 (531) it now loads but crashes after a minute or so and none of the buttons work. Can anyone help please.

    Hey Ian
    That would be correct. because of the nature of your issue, you may find more information by using another one of Apple's support resources.
    Contact Apple Support
    https://getsupport.apple.com/GetproductgroupList.action
    Thank you for using the Apple Support Community.
    -Norm G.

  • HT1725 I downloaded two albums yesterday and only half of each of the songs have downloaded when I play them. There is nothing to say it is waiting for the rest to download and I have checked for available downloads...help please!

    I downloaded two albums yesterday and only half of each of the songs have downloaded when I play them. There is nothing to say it is waiting for the rest to download and I have checked for available downloads...help please!

    no, i had to leave so i logged out and when i opened itunes on my mac and went into the downloads tab it only had one paused download listed. i resumed the download for the one movie listed and the other one never showed up. its been about two weeks since i initially bought the two movies so i figured something was wrong.

  • How can I create a Face Time account.  I have an Apple ID and password.  When I Google how to create an account all I get is what I need for the system

    I have a 13" MacPro.  How can I create a Face Time account.  I have an Apple ID and password.  When I Google how to create an account all I get is what I need for the system

    You don't need to create an account.   Your use your Apple ID to log into Facetime.
    If you haven't already you will need to download the Facetime App from the Mac App Store.
    https://itunes.apple.com/us/app/facetime/id414307850?mt=12&ls=1
    FaceTime for Mac: Troubleshooting FaceTime - Apple Support

  • I have a HD video clip (MPEG 4), able to watch in VLC in my Mac-book-pro, but not in Quicktime player and FCP X - just seen as full green. Help please to view in FCP X by changing the format or what ever thats required.

    I have a HD video clip (MPEG 4), able to watch in VLC in my Mac-book-pro, but not in Quicktime player and FCP X - just seen as full green. Help please to view in FCP X by changing the format or what ever thats required.  Thank you.

    Thanks for your reply. This video was recorded by my own professional camera, Sony PMW EX 3, two years back. But I am neither a professional cameraman nor an editor. I am just like a beginner in both.  I didnt have space in my storage device, so I just copied all my clips, thinking I can edit it latter, without recompressing or editing or whatever I should have done it at that point of time.  Now I need to edit it and use it in my profession. I am very upset.  Please help me in going step by step to get it in FCP X for editing.  Also I would like to know, do I need to buy the Compressor 4 for any reason. I dont mind in buying, if you think it is going to be useful for some reason.  Thank you very much in anticipation for any kind of proper guidance.

  • Hi i am from india and i am using iphone 5 but i have problem with charging last 20 % suddenly my phone switched off every day and som heating when i am using internate pls help me where i can check whether my phone waranty is valid on expire

    hi i am from india and i am using iphone 5 but i have problem with charging last 20 % suddenly my phone switched off every day and som heating when i am using internate pls help me where i can check whether my phone waranty is valid on expire

    https://selfsolve.apple.com/agreementWarrantyDynamic.do

  • Whenever i open any tab on the app store such as games or entertainment or travel its starts loading and all i see is a blank page...Please HELP!!!

    whenever i open any tab on the app store such as games or entertainment or travel its starts loading and all i see is a blank page...Please HELP!!!

    Try updating to iTunes 10.4.1 -> http://www.apple.com/itunes/download/
    If that doesn't work, try resetting Winsock. It looks like that worked for quite a few people in this thread -> With iTunes 10.4 I can access iTunes store.
    MTG68 wrote - In windows 7, click on your start menu, go to accessories, right click on the command prompt icon and choose "run as administrator".  Once it opens, type in the following command...
    netsh winsock reset
    hit enter and it should say something like winsock reset successful now reboot your computer.

  • Unsatisfied link when callind dll from run method Help Please?

    Hi,
    I get an unsatisfied link error while trying to calling a dll at a certain time period in a run method. The same dll works fine called in another setup and even called in a loop.
    Can anyone help please?
    import java.util.Timer;
    import java.util.TimerTask;
    * Schedule a task that executes once every second.
    public class TimeRetrieve {
        Timer timer;
        public TimeRetrieve() {
                 timer = new Timer();
            timer.schedule(new RemindTask(),
                        0,        //initial delay
                        1*1000);  //subsequent rate
        class RemindTask extends TimerTask
           String string_A;
           double d1;
         double d2;
         double d3;
         double d4;
         double d5;
         double d6;
         double d7;
         double d8;
         int numIter = 3;
         int start = 1;
            public void run()
                  if (numIter > 0) {
                  cinterface(start, string_A, d1, d2, d3, d4, d5, d6, d7, d8 );
              System.out.println("In Java action performed start button, after call to dll  \n");
              System.out.println("   string_A =  :" +string_A );
              System.out.println("doubles , \t  d1  \t d2  \t  d3  \t d4 \t d5 \t d6 \t d7 \t d8");
              System.out.println(d1 +"\t" +d2+"\t"+d3+"\t"+d4+"\t"+d5+"\t"+d6+"\t"+d7+"\t"+d8);
              numIter--;
                 } else
                 System.out.println("End Looping!");
                    System.exit
                 System.exit(0);  
        public static void main(String args[]) {
                   System.out.println("Starting Data Retrieval.");
                 new TimeRetrieve();
    // Load shared library which contains implementation of native methods
                    public native void cinterface(int start, String string_A, double d1, double d2, double d3, double d4,
                    double d5, double d6, double d7, double d8 );
                    static
                          try
                               System.out.println ("load cinterface"); //unsatisfied link
                               System.loadLibrary("cinterface");
                          catch (UnsatisfiedLinkError ee)
                               System.out.println
                                    ("Caught unsatisfied link error for dlls" );
                               System.out.println
                                    ("get local msg = " + ee.getLocalizedMessage() );
                               System.out.println ("getMessage " + ee.getMessage() );
                                   // System.out.println ("print Stack Trace " +ee.printStackTrace() );

    My mistake! I found it. Had some wrong names.

  • Premiere Pro crashes when i start it up. Help please :-)

    Premiere Pro crashes when i start it up. Help please :-)

    Go to Adobe Premiere Pro CC error on start and answer all the questions I posted in reply #1

Maybe you are looking for