Correct the sequence of events for the loading of XML

I have a complex object in Actionscript that I managed test and loading on a local computer. However, when I publish on the web, different network conditions cause the application trying to access the properties of the complex object before the XML file that defines it is finished processing. So I get null reference errors.

I'm trying to understand the correct event system to notify my application I want only to access the properties of my complex once the XML file has been finished read to and populated my complex object properties. Any suggestions on what to do?

I really wish that these forums have a tag formatting code or something so it's horrible, but in general this is what I have:

package {}

import flash.events.Event;
import flash.events.IEventDispatcher;
import flash.net.URLLoader;
import flash.net.URLRequest;

public class {ComplexObject
private var xmlDoc:XML;
private var request: URLRequest;
private var loader: URLLoader;

private var property1:String;
private var property2:Number;
etc.
Supposed getter and setter functions
}
public void loadData() {}
This.Request = new URLRequest ("config.xml");
This.loader = new URLLoader (this.request);
this.loader.addEventListener (Event.COMPLETE, xmlLoaded);
}
private void xmlloaded(evt:Event) {}
this.xmlDoc = XML (this.loader.data);
fill the object with the elements read from XML file
This.Property1 = xmlDoc.property1
etc.
}
}

I can import and instantiate an object of this class in the main MXML file and call the function loadData fine locally. When there are network issues involved (IE on the web) I want the XML processing to occur independently and complete before doing anything else. What is the correct order of events management? My question may be too complex, but any tips or pointers to resources would be appreciated.

I see nothing obviously 'wrong' with what you do; the complete event should not be distributed until the data has been loaded. I don't see where you apply the actual load.

However, I use this technique to load XML data. There are easier ways. I would like to use HTTPService with resultFormat = "e4x". The HTTPService result event will be triggered when completely loaded data. You can do either in MXML or ActionScript.

Tags: Flex

Similar Questions

  • Problem with the loading of XML and xmlns

    I'm having a problem with loading an XML file that was created by Filemaker.  FileMaker will display an XML file by using one of two different grammars.  A poster of a standard form for the most that I can use with a glitch.  Flash CS4 AS3 seems to have a problem with the xmlns in one of the nodes.

    More precisely:

    " < FMPDSORESULT xmlns =" http://www.FileMaker.com/fmpdsoresult "> "

    ' If I remove the xmlns = " http://www.FileMaker.com/fmpdsoresult 'the file is loaded properly and I can access the different fields without problem.  However, when I go the xmlns =..., it will trace the XML properly but I can't access the fields by using the code below.  It drives me crazy!

    With part xmlns in the XML file, I get the following error when attempting to load the thumbnails files:

    TypeError: Error #1010: a term is undefined and has no properties.

    I need it so that the user can enter/change the data and simply output the XML file of Filemaker and then the Flash load the XML file not corrupted and displays the information requested by the user.  That is to say I might have the user open the XML file in a word processing application and have remove them the xmlns..., but it is rather heavy and not very user-friendly.

    I tried all the xml.ignore functions I could find, but it does not help.  I hope someone out there can help you

    Thank you

    -Brand-

    _____________________________________________________________________________________

    Partial XML:

    XML to export Filemaker:

    <? XML version = "1.0" encoding = "UTF-8"? >
    <! - this grammar has been deprecated - use the FMPXMLRESULT instead.
    " < FMPDSORESULT xmlns =" http://www.FileMaker.com/fmpdsoresult "> "
    < ERRORCODE > 0 < / ERRORCODE >
    Sport.FP7 < DATABASE > < / DATA >
    < LAYOUT > < / PAGE layout >
    < LINE MODID = '1' RECORDID = "1" >
    Brand of < FirstName > < / name >
    Fowle < name > < / LastName >
    Veil of < sport > < / Sport >
    Medal of <>no < / medal >
    Design of < CourseOfStudy > < / CourseOfStudy >
    < year > 1976-1978 < / year >
    California < HomeState > < / HomeState >
    < ImageName > 93 < / ImageName >
    < / ROW >

    ...

    < / FMPDSORESULT >

    __________________________________________________________________________________

    AS3 code:

    Import fl.containers.UILoader;
    var aPhoto: Array = new Array(ldPhoto_0,ldPhoto_1,ldPhoto_2,ldPhoto_3,ldPhoto_4,ldPhoto_5);
    var toSet:int = 10; time to time delay
    var toTime:int = place;
    var photoPerPage:int = 6;
    var fromPos:int = photoPerPage;
    var imgNum:Number;

    var subjectURL:URLRequest = new URLRequest ("testData_FM8.xml");
    var subjectURL:URLRequest = new URLRequest ("Sports.xml");
    var xmlLoader:URLLoader = new URLLoader (subjectURL);
    xmlLoader.addEventListener (Event.COMPLETE, xmlLoaded);
    var subjectXML:XML = new XML();
    subjectXML.ignoreWhitespace = true;
    subjectXML.ignoreComments = true;
    subjectXML.ignoreProcessingInstructions = true;

    function xmlLoaded(evt:Event):void {}
    subjectXML = XML (xmlLoader.data);

    If {(root.loaderInfo.bytesTotal is root.loaderInfo.bytesLoaded)
    removeEventListener (Event.ENTER_FRAME, xmlLoaded);
    trace ("data XML file loaded");
    trace (subjectXML);
    } else {}
    trace ("file not found");
    }
    imgNum=2;//subjectXML.ROW.length;
    trace (subjectXML);
    loadThumb (0);
    }
    function loadThumb(startPos:int):void {}
    var count:Number = aPhoto.length;
    trace (subjectXML.Database);
    for (var i = 0; i < count; i ++) {}
    try {}
    aPhoto[i].source="images/"+subjectXML.ROW[startPos+i]. ImageName + "_main.jpg";
    } catch (error) {}
    trace (e);
    }
    aPhoto [i] .mouseChildren = false;
    aPhoto [i] .addEventListener (MouseEvent.MOUSE_DOWN, onThumbClick);
    }
    trace ("current mem:" + System.totalMemory);
    ldAttract.visible = false;

    }
    function unloadThumb (): void {}
    var count:Number = aPhoto.length;
    for (var i = 0; i < count; i ++) {}
    aPhoto [i] .unload ();
    aPhoto [i] .removeEventListener (MouseEvent.MOUSE_DOWN, onThumbClick);
    }
    trace ("current mem:" + System.totalMemory);

    }

    function onThumbClick(evt:MouseEvent) {}
    var i: Number;
    trace ("Thumbnail clicked" + evt.target.name);
    i = findPos (evt. Target.Name);
    ldLrgPhoto.source="images/"+subjectXML.ROW[i+fromPos]. LOCAL_OBJECT_ID + "_main.jpg";
    ldLrgPhoto.visible = true;
    btnPrev.visible = false;
    btnNext.visible = false;

    gotoAndStop ("showPhoto");
    }
    function findPos(thumb:String):Number {}
    var pos:Number;
    var count:Number = aPhoto.length;
    for (var i: Number = 0; i < count; i ++) {}
    If (thumb == aPhoto [i] .name) {}
    POS = i;
    }
    }
    return pos;
    }

    Mark,

    The ':' is what we call a scope resolution operator. Using namespace allows you to potentially have two or more nodes that have the same name but a namespace 'different '. "These are normally specified in xml in the form xmlns:mynamespace ="http://myuniqueURI.com/etc"

    Normally, you would use the mynamespace:node by naming your xml nodes that are specific to this namespace.

    But the best is that namespace by default, when there is no real Prefixeespacenom: in the name of node as:

    That's how it is specified in your xml file, that is to say all the nodes without a prefix belong to the filemaker namespace.

    In actionscript, you navigate by using the scope-resolution operator and the variable that represents the namespace does not necessarily resemble the part "mynamespace" above. In your case the namespace used was the one by default (no), but a value has been assigned.

    To the question of the length, you must use the length() method, otherwise the e4x filtering seeks nodes named 'length' and creating a XMLList with no entry in there (because it's not). It is a common thing with other "Properties" that are expressed in the form of methods like children() and often take me when I started with the model XML as3.

  • Using the event Script to load the Excel model data for users

    Hello

    Whoever did this in the FDM 11.1.2.1.

    We want to exploit the event Script to load the data validated MDF for a standard template so that users can make some adjustments and then load the same data through the FDM? Is there a better alternative. Basically, trying to avoid making adjs data forms in HFM in view of the number of columns that we have and validations for each line required with adjustments.

    Thank you

    PM

    Hello

    google + Administrator's Guide.

    It's just a matter of thought in the solution:

    -Runs a SQL query to export data from table (TDATASEG). You can filter the query by LOADID

    -Write csv file records

  • What is the event for a region/jsff loading?

    I need to do something after a Jsff or region has been charged, which is the event for her?

    Thank you.

    Hello

    Easier is to use a hidden on the first page JSFF user interface component and bind its value property to a managed bean. When this value is requested, you know that the region is charged. To make sure that it fires only once, set a flag in the pageFlowScope. Altrenatively, you can use a dynamic region and add your custom code to the Get accessor method in the managed bean that is called to provide the benchmark for the region.

    Frank

  • your user profile was not loaded correctly! you have been logged on with a temporary profile. Changes to this profile will be lost when you log out. Please, check your log of events for more information or contact your administrator

    Desperately need help.  I'm supposed to use my computer to type a HUGE Affidavit today and its buggered! Oh no.! Get started with my kids have been playing on my computer and install different games.  So I thought that I do the big thing non-technical MOM and start cleaning up the programs!  Well I accidently deleted NIVIDA and probably something else (I think) and totally messed up my computer!  I have re-uploaded NIVIDA and now my computer "looks like" back to normal, but it throws this error message

    "your user profile was not loaded correctly! you have been logged on with a temporary profile. Changes to this profile will be lost when you log out. Please, check your log of events for more information or contact your administrator"

    and now I can't save anything or find my pictures that I'm desperate for! Can someone please give me a helping hand.  Not technically minded, to take me on as a challenge!  Thanks bunch :) Sarah

    Desperately need help.  I'm supposed to use my computer to type a HUGE Affidavit today and its buggered! Oh no.! Get started with my kids have been playing on my computer and install different games.  So I thought that I do the big thing non-technical MOM and start cleaning up the programs!  Well I accidently deleted NIVIDA and probably something else (I think) and totally messed up my computer!  I have re-uploaded NIVIDA and now my computer "looks like" back to normal, but it throws this error message

    "your user profile was not loaded correctly! you have been logged on with a temporary profile. Changes to this profile will be lost when you log out. Please, check your log of events for more information or contact your administrator"

    and now I can't save anything or find my pictures that I'm desperate for! Can someone please give me a helping hand.  Not technically minded, to take me on as a challenge!  Thanks bunch :) Sarah

    Here is the tutorial to solve this problem. It is very involving. Please read the step by step.
    http://www.Vistax64.com/tutorials/135858-user-profile-error-logged-temporary-profile.html

    t-4-2

  • Canvas, click events for the child objects

    I am trying to record an event for each child object.
    and I use the following code

    http://livedocs.Adobe.com/Flex/3/HTML/Help.HTML?content=events_08.html
    in the part of the examples (second example)

    However, I am dynamically add custom Image objects extended and when click on a displayed Image and check for its type if its correct type, it would just return false.
    Alert.Show ((event.target_est_dans_MyAClass).toString ());

    When clicking on one of the children is opposed and display the event.target.name and it's just also displays a silly 'FlexLoader74' or whatever number. Somehow, it loses its properties or the type of the object.

    Is there something that I am missing?

    The loaded image, you click on IS what would return with event.target. It is added to your image class extended as a child of this class. So it's probably that you want to do:

    Alert.Show ((event.target.parent_est_dans_MyAClass).toString ());

    Keep in mind that if EMBED you your images in your image personalized instead compile-time class, then you can check for this as you did before:

    Alert.Show ((event.target_est_dans_MyAClass).toString ());

    TS

  • is it safe to use a view control of sequence to display the sequence file both for execution

    I have a Teststand UI written in Labview 2012.  It has a single control of sequence, and I use the ConnectSequenceView method to switch between the display just the loading sequence file and the running.  Allow me to reiterate.  When a file sequence is running, the control is connected to the execution Manager.  Otherwise, it is connected to sequenceFileView Manager.

    I begin to suspect that I have questions related to this control, when I do the following.

    1. load a movie file

    2 run Single Pass

    3. the execution ends

    4. unloading and Release sequence file

    5 load a different sequence file

    6. run single-pass

    7 Labview crashes

    Am I missing a step?

    Thank you

    Kevin

    So it seems the crash of Labview, I mentioned in the original post is unrelated to the joint use of display of the sequence control.  However during my troubleshooting, I noticed that I was missing cut from a point of view of control stage before connecting the other view.

    And for the record, I think that there are many things wrong with the architecture used in the complete example, but there also many too many features for what to.  Just need a simple "press a button" and "run a test" for operators.  Everyone uses the sequence editor.

    All right.  Thanks for the comments.

    Kevin

  • How to 'Allow smoothing' for the loaded XML .jpg?

    I have a thumb wheel image that loads a bunch of jpg. They are be enlarged rollover in 1,05.

    I've seen pixelated at scale 1 x 1 as well as expanded.

    I'm happy prettey how Flash renders the images with "Allow smoothing" on.

    How would I do it for the loaded xml jpg? Would it be as a script in the main folder or in the xml file?

    Here's how to load images in AS3:

    function completeHandler_AppPopUps(e:Event):void{
              //trace("thumbnail complete "+e.target.loader.parent.parent.name)//tells us when the loading is complete
    
              //size image into scroller (need only if I will have images at different sizes)
              resizeMe(e.target.loader.parent, 60, 90, true, true, false);
    
              TweenMax.to(e.target.loader.parent.parent, .5, {alpha:.7});//makes all thumb images at alpha=.7 after they are fully loaded
              //Tweener.addTween(e.target.loader.parent.parent, { alpha:1, time: .5 } );//caurina version
    
              TweenMax.to(e.target.loader.parent.parent, .5, {colorMatrixFilter:{contrast:1.1, brightness: .7, saturation: .5}});//makes all thumb images at brightness:0.5 after they are fully loaded
    
    
    }
    
    

    I don't want to complicate things more than necessary, but just in case it's needed here is the complete code for the edification of the wheel section:

    /////Parse XML
    //build scroller from xml
    function buildScroller(imageList:XMLList):void{
              trace("build Scroller");
    
              for (var item:uint = 0; item<imageList.length();item++) {
                        var thisOne:MovieClip = new MovieClip();
    
                        //outline
                         var blackBox:Sprite = new Sprite();
                        blackBox.graphics.beginFill(0xFFFFFF);
                        blackBox.graphics.drawRect(-1, -1, 62, 92);//-1,-1 places rectangle 1px left and up.62, 92 draws rectangle 1px wider on all sides of placed image dimenstions of 60x90
                        blackBox.alpha = thumbFadeOut;//setting Border Tweens
                        thisOne.addChild(blackBox);
                        thisOne.blackBox = blackBox;//setting Border Tweens
    
                          thisOne.x = thisOne.myx = (60 + padding) *item;//replaces the line above for scale tweenw roll over calculation. "myx" is a made up term which defines the position. 61 is the width of the thumb
                        thisOne.itemNum = item;
                        thisOne.title = imageList[item].attribute("title");
                        thisOne.link = imageList[item].attribute("url");
                        thisOne.src = imageList[item].attribute("src");
                        thisOne.alpha = 0;//makes all thumb images at alpha=0 before they are fully loaded
    
                        //Loading and Adding the Images
                        //image container
                        var thisThumb:MovieClip = new MovieClip();
                        //add image
                        var ldr:Loader = new Loader();
                        //var url:String = imageList[item].attribute("src");
                        var urlReq:URLRequest = new URLRequest(thisOne.src);
                        trace("loading thumbnail "+item+" into Scroller: " + thisOne.src);//url
                        ldr.load(urlReq);
                        //assign event listeners for Loader
                        ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler_AppPopUps);//tells us when the loading is complete
                        ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler_AppPopUps);//tells us if there are any typo errors when the loading is complete
                        thisThumb.addChild(ldr);
                        thisOne.addChild(thisThumb);
    
                        //create listeners for this thumb
                        thisOne.buttonMode = true;//makes boxes act as buttons
                        thisOne.addEventListener(MouseEvent.CLICK, clickScrollerItem_AppPopUps);//makes boxes act as buttons
                        thisOne.addEventListener(MouseEvent.MOUSE_OVER, overScrollerItem_AppPopUps);//traces the title when the mouse is over the bounding box in the Output Panel
                        thisOne.addEventListener(MouseEvent.MOUSE_OUT, outScrollerItem_AppPopUps);//traces the title when the mouse is out the bounding box in the Output Panel
    
    
    
                        //add item
                        scroller.addChild(thisOne);
              }
              scroller.addEventListener(Event.ENTER_FRAME, moveScrollerThumbs);//adding movement on mouse position
              trace("termination of build scroller");
    
    }
    
    
    

    in your listener to full charge, enable the property smoothing to the content of your charger (expressed as a bitmap).

    function completeHandler_AppPopUps(e:Event):void{

    Bitmap(e.currentTarget.loader.content).smoothing=true;
              //trace("thumbnail complete "+e.target.loader.parent.parent.name)//tells us when the loading is complete

    //size image into scroller (need only if I will have images at different sizes)
              resizeMe(e.target.loader.parent, 60, 90, true, true, false);

    TweenMax.to(e.target.loader.parent.parent, .5, {alpha:.7});//makes all thumb images at alpha=.7 after they are fully loaded
              //Tweener.addTween(e.target.loader.parent.parent, { alpha:1, time: .5 } );//caurina version

    TweenMax.to(e.target.loader.parent.parent, .5, {colorMatrixFilter:{contrast:1.1, brightness: .7, saturation: .5}});//makes all thumb images at brightness:0.5 after they are fully loaded

    }

  • Controls the main scenario for swf loaded.

    Hello

    I use a textfield for debug information.

    I am loading a swf in the main timeline and I show the status in the textfield of debugging.

    function swfLoaderCompleteHandler(event:Event)

    {

    Debug.Text += "Swf loaded.";

    }

    This works.

    But,

    I am loading a png file in the loaded swf file. I'm showing the State of the png file that I showed the status of the swf file.

    function pngLoaderCompleteHandler(event:Event)

    {

    MovieClip (parent). Debug.Text += "Png loaded.";

    }

    I can't control the main swf from inside the loaded swf file. Same Stop or a function call does not work.

    I need to add something when I load the swf file, it's a MovieClip or something?

    Here is also a fla. http://flashfocus.nl/Forum/attachment.php?attachmentid=9885 & d = 1282509233

    You are welcome.

    Please mark this thread as answered, if you can.

  • what these events during the loading of the dictionary?

    There are events mentioned loading the dictionary... in the ASDocs, but I couldn't find in the actual classes?

    is there perhaps a new version coming soon that triggers these events?

    just a question

    Phil

    At present there is only a single event (Event.COMPLETE) raised by the SpellingDictionary::load() method to indicate the load succeeded.

    I think this one works very well and all of our examples are using it.

    In the event of an error in loading, he must draw an IOErrorEvent, however, is not at the present time. It has been reported and followed here.

    http://forums.Adobe.com/thread/506860?TSTART=0

    This should be fixed in a new version.

    Thanks for the comments and thanks for sharing the NON-INTERFACE Flex, it's great :-)

  • Can I use my iPhone for the load

    Can I use my iPhone for the load?

    Yes

  • After upgrade FF I couldn't watch the video on Youtube. Event I down load Adobe flash player as required. I can still see Adobe flash plugin in FF.

    After upgrade FF I couldn't watch the video on Youtube. Event I down load Adobe flash player as required. I can still see Adobe flash plugin in FF.

    This screenshot shows all of these plugins as being (disabled) and "grey" - click on the button Activate on the right side.

  • Download windows 8.1 update to correct the problem with compablity with discs for WP - 4540 printer.

    HP Pavilion TouchSmart 23All all-in-one, Windows 8.1. After you download the Windows 8.1 update, the problem is the computer will not Unzip.exec program to fix my problem.

    Yes, once you have downloaded the latest version 8.1 of windows it fixed compatibility with readers for the printer Epson WP-4540. It seems that you need to download windows 8.1 whenever Microsoft updates windows 8.1. Microsoft adds new software for the devices and programs. My Hp computer has windows 8 and I had to upgrade to 8.1 windows. Then I had to download the latest version of windows 8.1. And this corrected the problem.

  • Lock the front until the end of the matter of events for this event

    A filtered event is a dynamic event? This is why "lock the front until the end of the matter of events for this event" does not appear on the dialog box edit the window tΓche? I use dynamic events so I can Subvi the structure of the event.

    I need stop my app does engage the FP, whenever the user double-clicks the (value of digital painting<-- the="" fp="" freezes="" the="" mouse="" and="" renders="" it="" useless)="" and="" stops="" the="" value="" from="" ever="" being="" changed.="" this="" event="" is="" registered="" for="" value="" change="" (not="" mouse="" up="" or="" down)="" and="" i="" get="" a="" locked="" mouse.="" as="" yet="" in="" the="" ui, no="" value="" changed="" occurs="" but i="" get="" a="" locked="" mouse.="" a="" lv="">

    Trying to FUCK, I can see this solve this by moving ONLY the event changes its value to the top-level VI instead of a dynamic event recorded in a sub - VI. This will give me the possibility of NOT 'façade blocking until the end of the matter of events for this event ".

    For dynamic events, you must click on the node for event registration (when the event is actually registered) and choose to not block the FP.

    Yes its not easy but its there.

    Ben

  • Need to disable the service manager for down load adobe

    Need to disable the Service Manager for down load adobe

    Original title: program compatibility Application Applications App Apps GaGames Legacy Crash crashes hang hangs
    Moved from feedback
    Internet Explorer version unspecified - unspecified BONES

    Hello

    What Adobe program you are trying to download?

    Flash Player
    http://helpx.Adobe.com/Flash-Player/KB/installation-problems-Flash-Player-Windows.html

    Adobe Reader
    http://helpx.Adobe.com/Acrobat/KB/quick-fix-install-download-reader.html

    Don

Maybe you are looking for

  • When runnig windows update of xp professional edition SP3· Error: 0 x 80244019

    [Number of error: 0 x 80244019] El sitio doesn't web ha sown a problema y no worm can show page Quebec filedThe web site find a problen and cannot display the page you are trying to viewThis is the message I get when I run windows update. I have XP P

  • A lot of problems

    I love this mp3, but sometimes I wish I would have went with another. I have so many problems with it. I didn't put each problem in a lot of different post, so here's the list of what is wrong. Any help is appreciated. 1 music plays but does not appe

  • Cannot get computer to launch

    I have a compaq laptop with vista. It won't normally load upward, it will charge the safe mode and safe mode with network but if I select start windows normally just is there and does nothing, the only way I could get out and restart had to pull him

  • What is the d3dx9_33dll?

    What is d3dx9_33dill? and how do I fix it?

  • BlackBerry Smartphones Bluetooth Bold 9700 OS6 latest Dead

    Can someone help me pls on this... I m not able to activate bluetooth on my laptop... If I can get the bluetooth OFF / ONE tab when I tab the OFF button ON the screen freezes for a while (as if a process is turned on) & and then back to OFF position.