XML to ArrayCollection

What is the most elegant way to populate an ArrayCollection
with XML content?
I would do that with a for loop that would go through all XML
nodes, create an object for each node and add this object into an
ArrayCollection object, but is this the best solution?
Any help would be fantastic!
Thank you!
EDIT: Or is there an elegant way to populate an
ArrayCollection from a String containing XML formated
content?

Why do you want to do that? There is very rarely a good
reason for this.
Tracy

Similar Messages

  • How do I create a line chart direct from xml or convert xml to ArrayCollection

    The xml is simple:
    <data>
    <row name="Q1">
    <expenses>64</expenses>
    <revenue>98</revenue>
    <profit>34</profit>
    </row>
    <row name="Q2">
    <expenses>44</expenses>
    <revenue>28</revenue>
    <profit>64</profit>
    </row>
    <row name="Q3">
    <expenses>14</expenses>
    <revenue>58</revenue>
    <profit>54</profit>
    </row>
    </data>
    it's dynamically generated as a string so could be created in xml format, or ArrayCollection, or any other format that works. However I can't find a example of using xml as the datasource that works. I've tried to convert it to an ArrayCollection first but that didn't work either.
    Alternatively I could store the data as a string "Month: "May", Profit: 2400, Expenses: 575, Amount: 456", then:
    expensesAC2.addItem({Month: "May", Profit: 2400, Expenses: 575, Amount: 456 });
    works but:
    var settings:String = resultXML.row[0];
    expensesAC2.addItem({settings});
    doesn't work. Any suggestions, or links to a tutorial that works would be really appreciated?

    Hi all,
    This issue was resolved off-line, however, I wanted to note a few points that were shared with me.
    Learnings from Forum discussion:
    Best practice is to use a combination of INDEX and MATCH functions instead of Vlookups.  Using the VLOOKUP function can result in a very slow dashboard if using a lot of data. 
    Also, when using the Filter Component note the destination field as the filter component does not copy the first filter value at all so you have to adjust by one column to accommodate for this (two columns if you have 3 filters etc).

  • HTTP Service XML to ArrayCollection

    Hi,
    How do I convert the results from a remote XML List file
    called using the HTTPService method into an arrayCollection for
    sorting filtering etc. ??? (I assume it is the arrayCollection
    please feel free to suggest a better method)
    I have this working by calling the XML as a model that
    compiles at runtime, it'd be nice to have this work dynamically
    Thanks
    Rich

    If your data is in XML format, you may want to read it in as
    XML, and use an XMLList (or XMLListCollection wrapping the XMLList)
    to do the management of it.
    In terms of how to read it in at runtime (I assume that's
    what you're asking?) try something along these lines:
    internal var myXMLList:XMLList;
    internal function loadData() : void
    var XML_URL:String = "myData.xml";
    var myXMLURL:URLRequest = new URLRequest(XML_URL);
    var myLoader:URLLoader = new URLLoader();
    myLoader.addEventListener("complete", dataLoaded);
    try
    myLoader.load(myXMLURL);
    } catch(error:Error)
    trace("Failed to load Data");
    internal function dataLoaded(evtObj:Event) : void
    var myLoader:URLLoader = URLLoader(evtObj.target);
    var myXML:XML = XML(myLoader.data);
    myXMLList = myXML.ListedElement;
    }

  • HTTPService XML: force ArrayCollections?

    I'm loading an XML document with HTTPService.  It has an annoying behavior.  If the source XML looks like:
    <one>
      <two>thing</two>
    </one>
    then one.two will be a String ("thing").
    If the XML is:
    <one>
       <two>thing</two>
       <two>another thing</two>
    </one>
    then one.two will be an ArrayCollection.
    Is there a way to force the first case to also generate an ArrayCollection?  Right now I have to manually check everywhere if two is an ArrayCollection, if it isn't, make a new one, etc... Seems like Flex should take care of this automatically.
    -jsd-

    Hi,
    Checkout the below code...this will ensure that you will get only ArrayCollection in both the cases...and also you need to check only once whether it is arrycollection or not and at other places you can avoid the check as you are converting it to ArrayCollection so you can directly use the arraycollection..
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="loadXMLData();" layout="absolute">
    <mx:Script>
      <![CDATA[
       import mx.collections.ArrayCollection;
       import mx.rpc.xml.SimpleXMLDecoder;
       private var arrayCollection:ArrayCollection = new ArrayCollection();
       private function loadXMLData():void
        var xml:XML = new XML(myXml.toString());
        var xmlDoc:XMLDocument = new XMLDocument(xml);
        var decoder:SimpleXMLDecoder = new SimpleXMLDecoder(true);
        var resultObj:Object = decoder.decodeXML(xmlDoc);
        if(resultObj != null)
         if(resultObj.one.two is ArrayCollection)
          arrayCollection = resultObj.one.two as ArrayCollection;
         else if(resultObj.one.two is String)
          arrayCollection.addItem(resultObj.one.two);
      ]]>
    </mx:Script>
    <mx:XML id="myXml" xmlns="">
      <one>
        <two>thing</two>
      </one>
    </mx:XML>
    </mx:Application>
    If this post answers your question or helps, please kindly mark it as such.
    Thanks,
    Bhasker Chari

  • Passing data from an XML object to an itemRenderer

    I'm trying to color the background of a column in a datagrid and have found a sample file that illustrate the concept. However, the sample has data stored in an arrayCollection whereas mine is in an XML object. The problem is that the data in the sample file is apparently automatically passed to the itemRenderer (shown below: note the trace statement). My XML object does not appear to automatically pass data to the itemRenderer. So my questions are:
    1. Is there a simple way to pass data stored in an XML object to an itemRenderer
    or
    2. Should I convert my XML to an arrayCollection? If so, what's the best way to do this-- I've tried the following, but without success:
    <mx:Model id="xmldata" source="example3.xml"/>
      <mx:ArrayCollection id="myAC" source="{ArrayUtil.toArray(xmldata.Example1)}" />
    Here's what the xml looks like:
    <TABLE>
       <EXAMPLE1>
          <difficulty> 0.5 </difficulty>
          <discrimination> 0.7 </discrimination>
          <item> 3 </item>
       </EXAMPLE1>
    </TABLE>  
    Here's the itemRenderer:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Label xmlns:mx="http://www.adobe.com/2006/mxml">
        <!--
            This item renderer simply extends Label and overrides the updateDisplayList function to
            draw a gradient-filled rectangle. The colors in the gradient are determined from the
            data.
        -->
        <mx:Script>
        <![CDATA[
            import flash.geom.Matrix;
            import flash.display.GradientType;
            import flash.display.Graphics;
            override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
                super.updateDisplayList(unscaledWidth,unscaledHeight);
                var m:Matrix = new Matrix();
                m.createGradientBox(unscaledWidth,unscaledHeight);
                var g:Graphics = graphics;
                            trace("data.col3="+data.col3)
                var colors:Array = (data.col3 < 2000 ? [0x0000CC,0x0000FF] : [0x00CC00,0x00FF00]);
                g.clear();
                g.beginGradientFill(GradientType.LINEAR, colors, [0.2,0.6], [0,255], m);
                // the rectangle is drawn a little high and a little tall to compensate for the gap
                // the DataGrid introduces between rows.
                g.drawRect(0, -2, unscaledWidth, unscaledHeight+4 );
                g.endFill();
        ]]>
        </mx:Script>
    </mx:Label>

    This sample code should answer your question of how to bring data into the renderer automatically. It comes in via the DataGrid dataProvider and then you refer to it in the renderer as data.XYZ, where XYZ is the field in the XML with the data. See FB 3 help sys on e4x syntax.
    ------------------ mainapp.mxml --------------------
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
      creationComplete="srvc.send();">
      <mx:Script>
        <![CDATA[
          import mx.rpc.events.ResultEvent;
          import mx.collections.XMLListCollection;
          [Bindable] private var xlc:XMLListCollection;
          private function dataHandler(evt:ResultEvent):void{
            xlc = new XMLListCollection(evt.result..EXAMPLE1 as XMLList);
        ]]>
      </mx:Script>
      <mx:HTTPService id="srvc" url="data2.xml" result="dataHandler(event)"
        resultFormat="e4x"/>
      <mx:DataGrid dataProvider="{xlc}">
        <mx:columns>
          <mx:DataGridColumn headerText="Difficulty" dataField="difficulty"/>
          <mx:DataGridColumn headerText="Discrimination" dataField="discrimination"/>
          <mx:DataGridColumn headerText="Item" itemRenderer="MyLabel"/>
        </mx:columns>
      </mx:DataGrid>
    </mx:Application>
    ----------- MyLabel.mxml --------------
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Label xmlns:mx="http://www.adobe.com/2006/mxml">
      <mx:Script>
        <![CDATA[
          import flash.geom.Matrix;
          import flash.display.GradientType;
          import flash.display.Graphics;
          override protected function updateDisplayList(unscaledWidth:Number,
            unscaledHeight:Number):void{
            super.updateDisplayList(unscaledWidth,unscaledHeight);
            this.text = data.col3;
            var m:Matrix = new Matrix();
            m.createGradientBox(unscaledWidth,unscaledHeight);
            var g:Graphics = graphics;
            var colors:Array = (data.col3 < 2000 ? [0x0000CC,0x0000FF] : [0x00CC00,0x00FF00]);
            g.clear();
            g.beginGradientFill(GradientType.LINEAR, colors, [0.2,0.6], [0,255], m);
            g.drawRect(0, -2, unscaledWidth, unscaledHeight+4 );
            g.endFill();
        ]]>
      </mx:Script>
    </mx:Label>
    ------------ data2.xml ----------------
    <?xml version="1.0" encoding="utf8"?>
    <TABLE>
       <EXAMPLE1>
          <difficulty> 0.5 </difficulty>
          <discrimination> 0.7 </discrimination>
          <col3> 3 </col3>
       </EXAMPLE1>
    </TABLE>

  • How to create Bar chart  from existing XML file

    Hi all,
    i'm new to flex, i need your help to develop a flex for
    dashboard app. we have sample.xml file. by using this i need to
    create a bar diagram or piechart.
    Please help me out
    The XMl looks like this.....
    <?xml version="1.0" encoding="utf-8"?>
    <user id="123412343">
    <fullName>
    <lastName>Telles</lastName>
    <firstName>vijay</firstName>
    </fullName>
    <preferences>
    <modWidth>235</modWidth>
    <modHeight>250</modHeight>
    <totalWidth>1650</totalWidth>
    <totalHeight>1650</totalHeight>
    <modsX>4</modsX>
    <modsY>2</modsY>
    </preferences>
    <module id="Status2">
    <windowOpen>true</windowOpen>
    <pointsToShow>
    <p label="Proposed"/>
    <p label="Draft"/>
    <p label="DEP Adpt"/>
    <p label="EPA Adpt"/>
    </pointsToShow>
    <dataSetsToShow>
    <label>2006</label>
    <label>2007</label>
    </dataSetsToShow>
    </module>
    </user>

    convert this xml to ArrayCollection called chartData
    var charOption:String = "totalHeight"; /Use this to set the
    yField property...
    <mx:ColumnChart showDataTips="true" id="barChart"
    width="100%" height="100%" dataProvider="{chartData}"
    color="0xffffff">
    <mx:horizontalAxis>
    <mx:CategoryAxis
    dataProvider="{chartData}"
    categoryField="hour" />
    </mx:horizontalAxis>
    <mx:verticalAxis>
    <mx:LinearAxis labelFunction="addDollarSign"/>
    </mx:verticalAxis>
    <mx:series>
    <mx:ColumnSeries yField="{chartOption}"
    showDataEffect="interpolate"
    creationCompleteEffect="interpolate"/>
    </mx:series>
    </mx:ColumnChart>

  • DataGrid and XML

    Can anyone spot a problem with the following code:
    <mx:Model id="readingData" source="reading.xml"/>
        <mx:ArrayCollection id="readingAC" source="{readingData.row}"/>
    <mx:DataGrid id="readingGrid" dataProvider="{readingAC}" x="10" y="40" rowCount="4" width="675" color="#000000">
        <mx:columns>
        <mx:DataGridColumn dataField="title" headerText="Title" width="200"/>
        <mx:DataGridColumn dataField="author" headerText="Author" width="200"/>
        <mx:DataGridColumn dataField="isbn" headerText="ISBN" width="200"/>
        </mx:columns>
    </mx:DataGrid>
    The error message I get is:
    Problem parsing external XML: C:\Documents and Settings\Ian\My Documents\RIA\src\reading.xml - (line 41) The entity name must immediately follow the '&' in the entity reference.    RIA_Prototype/src    Prototype.mxml  
    I have another DataGrid in the app. which works just fine but this one won't - and I don't understand the error message.
    Ian

    Hi Alexander the xml file:
    <?xml version="1.0"?>
    <reading>
        <row>
            <contactid>1</contactid>
            <title>My Sisters Keeper</title>
            <author>Jodi Picoult</author>
            <isbn>978-1-439-15726-8</isbn>
        </row>
        <row>
            <contactid>2</contactid>
            <title>Fearless Fourteen</title>
            <author>Janet Evanovich</author>
            <isbn>978-0-312-34952-3</isbn>
        </row>
        <row>
            <contactid>3</contactid>
            <title>Dead Until Dark</title>
            <author>Charlaine Harris</author>
            <isbn>9780441016990</isbn>
        </row>
        <row>
            <contactid>4</contactid>
            <title>From Dead to Worse</title>
            <author>Charlaine Harris</author>
            <isbn>978-0-441-01701-0</isbn>
        </row>
        <row>
            <contactid>5</contactid>
            <title>Wed Him Before You Bed Him</title>
            <author>Sabrina Jeffries</author>
            <isbn>978-1-416-56082-1</isbn>
            </row>
        <row>
            <contactid>6</contactid>
            <title>Sail</title>
            <author>James Patterson</author>
            <isbn>9780446536103</isbn>
        </row>
        <row>
            <contactid>7</contactid>
            <title>The Last Oracle</title>
            <author>James Rollins</author>
            <isbn>978-0-06-123095-0</isbn>
        </row>
        <row>
            <contactid>8</contactid>
            <title>Angels & Demons</title>
            <author>Dan Brown</author>
            <isbn>9781416524878</isbn>
        </row>
        <row>
            <contactid>9</contactid>
            <title>Sundays at Tiffany’s</title>
            <author>James Patterson</author>
            <isbn>978-0-446-53631-8</isbn>
        </row>
        <row>
            <contactid>10</contactid>
            <title>Living Dead in Dallas</title>
            <author>Charlaine Harris</author>
            <isbn>978-0-441-01824-6</isbn>
        </row>
        <row>
            <contactid>11</contactid>
            <title>The Last Patriot</title>
            <author>Brad Thor</author>
            <isbn>978-1-416-54384-8</isbn>
        </row>
        <row>
            <contactid>12</contactid>
            <title>Rogue</title>
            <author>Danielle Steel</author>
            <isbn>978-0-440-24329-8</isbn>
        </row>
        <row>
            <contactid>13</contactid>
            <title>Club Dead</title>
            <author>Charlaine Harris</author>
            <isbn>9780441010516</isbn>
        </row>
        <row>
            <contactid>14</contactid>
            <title>Dead to the World</title>
            <author>Charlaine Harris</author>
            <isbn>978-0-441-01218-3</isbn>
        </row>
    </reading>

  • Videophone example, XML result into a list?

    In the video phone application, the reg.cgi appears to ouput a list of 'friends' in xml format
    (from regcgi)
    for f in friends:
        print "\t<friend>\n\t\t<user>%s</user>" % (xml.sax.saxutils.escape(f), )
        c = db.cursor()
        c.execute("select m_username, m_identity from registrations where m_username = ? and m_updatetime > datetime('now', '-1 hour')", (f, ))
        for result in c.fetchall():
            eachIdent = result[1]
            if not eachIdent:
                eachIdent = ""
            print "\t\t<identity>%s</identity>" % (xml.sax.saxutils.escape(eachIdent), )
            if f != result[0]:
                print "\t\t<registered>%s</registered>" % (xml.sax.saxutils.escape(result[0]), )
        print "\t</friend>"
    and the flash app appears to get the results as follows
    (from httpmanager)
    else if (result.result.hasOwnProperty("friend"))
                        // party query response
                        remote = result.result.friend as Object;
                        if (remote.hasOwnProperty("user") && remote.hasOwnProperty("identity"))
                            var identityString:String = remote.identity
                            var userString:String = remote.user;
                            var r:IdManagerEvent = new IdManagerEvent("lookupSuccess", userString, identityString);
                            dispatchEvent(r);
    and it places a call to one of the 'friends' as follows
    (from the videophone app file)
    else if (e.type == "lookupSuccess")
                        // party query response
                        var i:IdManagerEvent = e as IdManagerEvent;
                        placeCall(i.user, i.id);   
    My query is, how would I take the full list that was returned as XML, and for example, populate a list with that data?
    How do you iterate through the list, extracting the required values and put them into a list?
    Im new to flash, and trying to get my head around how to do these simple things...
    Can anyone shed any light, as Im learning loads, but keep hitting struggling points like this as I dont have a clue how flash does these things, and dont know what to investigate... Once a pointer in the right direction is given,  a small example like this is shown, I can take it from there, and investigate/learn more.
    t

    Hi ken_from_uk,
    you can convert your xml to an array collection and you can easily iterate using for loop and access the values in the list ...You can see the code below how to convert xml to ArrayCollection...
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="convertXMLtoArrayCollection()">
    <mx:Script>
      <![CDATA[
       import mx.collections.ArrayCollection;
       import mx.rpc.xml.SimpleXMLDecoder;
       private var arrayCollection:ArrayCollection = new ArrayCollection();
       private function convertXMLtoArrayCollection():void
        var xml:XML = new XML(xmlStates.toString());
        var xmlDoc:XMLDocument = new XMLDocument(xml);
        var decoder:SimpleXMLDecoder = new SimpleXMLDecoder(true);
        var resultObj:Object = decoder.decodeXML(xmlDoc);
        if(resultObj.states.state is ArrayCollection)
         arrayCollection = resultObj.states.state as ArrayCollection;
        else if(resultObj.states.state is Object)
         arrayCollection.addItem(resultObj.states.state);
      ]]>
    </mx:Script>
    <mx:XML xmlns="" id="xmlStates">
      <states>
          <state>
              <name_state>State x:</name_state>
              <code_state>X</code_state>
              <cities>
                  <city>
                      <name_city>City One</name_city>
                      <population_city>20000</population_city>
                  </city>
                  <city>
                      <name_city>City Two</name_city>
                      <population_city>10000</population_city>
                  </city>
                  <city>
                      <name_city>City Three</name_city>
                      <population_city>80000</population_city>
                  </city>
              </cities>
          </state>
          <state>
              <name_state>State y:</name_state>
              <code_state>X</code_state>
              <cities>
                  <city>
                      <name_city>City Four</name_city>
                      <population_city>50000</population_city>
                  </city>
                  <city>
                      <name_city>City Five</name_city>
                      <population_city>40000</population_city>
                  </city>
                  <city>
                      <name_city>City Six</name_city>
                      <population_city>70000</population_city>
                  </city>
              </cities>
          </state>
      </states>
    </mx:XML>
    </mx:Application>
    Thanks,
    Bhasker Chari

  • Can't get transitions to execute

    Hi folks,
    I'm building my first Flex app, which is a typical simple quiz. Intro state, string of questions, then a result.
    I'm stuck right now in that my transitions are not running. I suspect it has something to do with the fact that I extended the Application class and typed my main application mxml file to that class so that I could keep Actionscript separate from MXML in two separate files. The app will switch states successfully but it won't run the transition effects on a state change, and so my endEffect event is not firing...
    It may be that I have something else wrong altogether.
    Here is the application MXML file:
    <?xml version="1.0" encoding="utf-8"?>
    <classes:QuizApplication
        xmlns:local="*"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        xmlns:classes="classes.*"
        layout="absolute"
        currentState="landingState"
        >
        <mx:HTTPService id="questions" url="./data/questions.xml" />
        <classes:states>
            <mx:State name="landingState"/>
            <mx:State name="landingStateOut" basedOn="landingState"/>
            <mx:State name="question">
                <mx:RemoveChild target="{text1}"/>
                <mx:RemoveChild target="{startButton}"/>
                <mx:AddChild relativeTo="{vbox1}" position="lastChild">
                    <local:FormHolderVBox id="formHolder" applicationVO="{applicationVO}" width="348" height="248" />
                </mx:AddChild>
            </mx:State>
            <mx:State name="resultState"/>
            <mx:State name="betweenQuestions1" basedOn="question">
                <mx:RemoveChild target="{formHolder}"/>
                <mx:RemoveChild target="{vbox1}"/>
            </mx:State>
        </classes:states>
        <classes:transitions>
            <mx:Transition id="advanceTransition0" fromState="landingState" toState="landingStateOut">
                <mx:Fade
                    duration="2000"
                    id="fadeToBetween"
                    alphaFrom="1"
                    alphaTo="0"
                    effectEnd="continueAdvance();"
                />    
            </mx:Transition>        
            <mx:Transition id="advanceTransition1" fromState="question" toState="betweenQuestions" effect="{fadeToBetween}" />        
            <mx:Transition id="advanceTransition2" fromState="question" toState="betweenQuestions">
                <mx:Fade
                    id="fadeToQuestion"
                    alphaFrom="0"
                    alphaTo="1"
                />    
            </mx:Transition>        
        </classes:transitions>
        <mx:Canvas x="45" y="41" width="392" height="361" id="canvas">
            <mx:VBox x="21" y="47" height="291" width="348" id="vbox1">
                <mx:Text text="Take this quick quiz to find out what type of shopper you are!" width="347" height="40" fontSize="12" id="text1"/>
                <mx:Button label="Start the Quiz" id="startButton"/>
            </mx:VBox>
        </mx:Canvas>
        <mx:Text text="What kind of shopper are you?"  fontSize="21" fontWeight="bold" fontFamily="Arial" x="45" y="41"/>
    </classes:QuizApplication>
    And here is the associated Actionscript:
    package classes
        import classes.events.AdvanceEvent;
        import flash.events.MouseEvent;
        import mx.collections.ArrayCollection;
        import mx.containers.Canvas;
        import mx.controls.Button;
        import mx.core.Application;
        import mx.events.FlexEvent;
        import mx.events.EffectEvent;
        import mx.rpc.events.ResultEvent;
        import mx.rpc.http.mxml.HTTPService;
        public class QuizApplication extends Application
            [Bindable]
            public var startButton:Button;
            public var canvas:Canvas;
            public var questions:HTTPService;
            //[Bindable] ?
            public var questionVOs:ArrayCollection;
            [Bindable]
            public var applicationVO:ApplicationVO;
            //CONSTRUCTOR
            public function QuizApplication()
                super();
                this.addEventListener(FlexEvent.APPLICATION_COMPLETE, init);
                // go ahead and create singleton of DataClass to store globals
                applicationVO = new ApplicationVO();
            //METHODS
            private function init(e:FlexEvent):void
                startButton.addEventListener(MouseEvent.MOUSE_UP, handleStartQuiz);
                questions.addEventListener(ResultEvent.RESULT, handleQuestionData);
                questions.send();
                // set up listeners for app business
                canvas.addEventListener(AdvanceEvent.FORWARD, advanceToQuestion);
                //canvas.addEventListener(AdvanceEvent.BACKWARD, advanceToQuestion);
            //    canvas.addEventListener(AdvanceEvent.CONTINUE, continueAdvance);
                // set to start with question 1
                applicationVO.currentQuestion = 0;
            // EVENT HANDLERS
            private function handleStartQuiz(e:MouseEvent): void
            //currentState = "question"; // states hard-coded in mxml
            trace("should set state to landingStateOut");
            trace("currentState now is "+currentState);
            currentState = "landingStateOut";
            trace("currentState now is "+currentState);        
            private function handleQuestionData(e:ResultEvent): void
                applicationVO.questionVOs = new ArrayCollection();
                // loop through XML's ArrayCollections and create an ArrayCollection of QuestionVO's, one for each question in XML
                 for each (var question:Object in e.result.questions.question)
                    var newVO:QuestionVO = new QuestionVO();
                    newVO.questionID = question.id;
                //    trace("question.id is "+question.id);
                    newVO.questionText = question.text;
                //    trace("question.text is "+question.text);
                    newVO.answers = new ArrayCollection();
                    for each (var answer:Object in question.answers.answer)
                        newVO.answers.addItem(answer);
                    //    trace("answer is "+answer);
                    applicationVO.questionVOs.addItem(newVO);
            private function advanceToQuestion(e:AdvanceEvent):void
                trace("should transition to next question now");
                e.stopImmediatePropagation();    
                if (e.type == "forward")
                    //somehow call the transition AdvanceTransition
                    applicationVO.currentQuestion++;
                    currentState = "betweenQuestions1";
                else
                    applicationVO.currentQuestion--;
                    currentState = "betweenQuestions1";
            public function continueAdvance():void
                trace("should transition now from betweenQuestions2 to question state");
                //currentState = "question";
    Can anyone point out what I've got wrong that could cause the Transitions not to work? I thought they were simply supposed to execute on a state change from A to B, for which you've indicated set up a Transition from state A to B.
    Many thanks!

    Ok, I finally figured out what was wrong.  I was missing the concept that you had to specify a target element in the effect definition in your transition upon which the transition would play.  Transition plays now.

  • Flex Remoting

    when I am in development, my remoting calls have to go over flex.messaging.endpoints.AMFEndpoint, but in production it has to go over flex.messaging.endpoints.SecureAMFEndpoint.
    My RemoteObject destination is "rubyamf," and my services-config.xml looks like this:
    <services>
         <service id="rubyamf-flashremoting-service" class="flex.messaging.services.RemotingService"
             messageTypes="flex.messaging.messages.RemotingMessage"
             >
             <destination id="rubyamf">
                  <channels>
                       <channel ref="channel-rubyamf" />
                       <channel ref="channel-rubyamf-secure" />
                  </channels>
                  <properties>
                       <source>*</source>
                  </properties>
             </destination>
        </service>
    </services>
    <channels>
       <!-- RUBY AMF -->  
      <channel-definition id="channel-rubyamf" class="mx.messaging.channels.AMFChannel">
       <endpoint uri="/app/rubyamf/gateway" class="flex.messaging.endpoints.AMFEndpoint" />
       <properties>
       <polling-enabled>true</polling-enabled>
       </properties>
       </channel-definition>
       <!-- SECURE RUBY AMF -->
       <channel-definition id="channel-rubyamf-secure" class="mx.messaging.channels.SecureAMFChannel">
       <endpoint uri="/app/rubyamf/gateway" class="flex.messaging.endpoints.SecureAMFEndpoint" />
       </channel-definition>
    </channels>
    If I use this, will it work for my development and production environments? I don't like having to have to recompile the app each time I want to launch it for production.

    "drenner1" <[email protected]> wrote in
    message
    news:gf9j2f$901$[email protected]..
    >i have a current app .... it uses a web service to pull
    data .... returns
    >the
    > data as XML and then the data is converted to an
    arraycollection for use
    > in
    > various datagrid dataproviders ..... bottleneck in app
    appears to be
    > converting all data from xml to arraycollection ....
    approx 5 minutes to
    > process 3000 rows before data appears in app .... so
    want to use remoting
    > to
    > improve app performance ...
    >
    > my question is: when I use remoting and return data to
    client via
    > remoting,
    > can I use the data immediately without having to do a
    'conversion' step as
    > the
    > app is currently doing ??? can the data returned via
    remoting immediately
    > be
    > processed as an array (for example, looping over array
    elements) so it can
    > be
    > 'partitioned' for use for the various datagrids?? or do
    I still have to do
    > some
    > sort of conversion like I am currently doing ??? if I
    can immediately
    > 'use' the
    > data returned from the remote object without having to
    do a conversion
    > step, I
    > am thinking this will increase performace dramatically
    Try using an XMLListCollection.

  • Detect Column on mx:Datagrid drop event

    I've been searching for a way to detect the column index when I drop on an mx:datagrid using Flex 4.  I can find the way to get the row index, but not the column.   Is the only way to define an itemeditor for each column, or is there something better (cleaner).
    If it must be an itemeditor, is there an example of one that handles the dropevent out there somewhere?
    I'm reluctant to try the AdvancedDatagrid after seeing all the posting about bugs and poor code quality.

    if it's not necessary for the user to resize the column widths, i'd say use a single column with an itemRenderer, and handle what gets shown inside that.
    if you must use multiple columns, then probably you're going to blaze the trail on performance testing.
    but it sounds like you are asking if you should limit the data to only 10 <items>.
    if so, probably convert the xml to ArrayCollection.  Large XML can freeze an app when the XML is updated.
    then, if you need more optimization after that, you can disclude <items> when converting to arrayCollection

  • Slow Appication Response for Simple Events like Click, Focus, button Click

    Hi,
       I have a problem, my flex application reponds slowly after i bind data to a datagrid.
      On initial load i make a httpRequest which gives me a result as xml and i convert xml to ArrayCollection and bind it to datagrid.
    If i dont bind the data, application responds fine, but when i bind the data the application responds slowly i mean approx by 5-7 sec delay in events like when i click on textinput, or popup a titlewindow, or close an alert box..etc. dont understand wats the problem.
    any solutions are welcome. if anybody facing similar problem let me know, so that wat we have done in common.
    Regards,
    Kris

    Hi Krishnamraj,
    How many records are you gettnig from server..?? Are they very huge..??
    Thanks,
    Bhasker

  • Updating ArrayCollections from XML Files

    I am developing a game and I have a grid where I display all
    the users with their current states(wins, losses and balance). I
    retrieve the states of the players from an XML file every 10
    seconds. The XML file does not retrun the states of all the players
    every time I call it, it only returns information about the players
    that have changes in their states (won or lost).
    The problem is that when I upload the file every 10 seconds
    all the data is lost an only the uploaded data remains. I have beed
    searching for a way to only update the (ArrayCollection) that I am
    using but with no Luck.
    the following is a snapshot of some of the basic code that I
    am using
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application
    xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="350" height="550"
    creationComplete="uSend();"
    >
    <mx:Script>
    <![CDATA[
    import mx.rpc.events.ResultEvent;
    import mx.collections.ArrayCollection;
    [Bindable]
    private var usersCol:ArrayCollection;
    var load_Interval:uint;
    private function uResultHandler(event:ResultEvent):void {
    usersCol = event.result.users.user;
    function uSend():void {
    clearInterval(load_Interval);
    u.send();
    load_Interval = setInterval(uSend, 10*1000);
    ]]>
    </mx:Script>
    <!-- Service to load in XML -->
    <mx:HTTPService
    id="u"
    url="gamers.xml"
    result="uResultHandler(event);" />
    <mx:Panel title="Top Gamers" width="100%">
    <mx:DataGrid
    id="usersGrid" width="100%" rowCount="20"
    dataProvider="{usersCol}">
    <mx:columns>
    <mx:DataGridColumn dataField="name"
    headerText="Name"/>
    <mx:DataGridColumn dataField="loss" headerText="Games
    Lost"/>
    <mx:DataGridColumn dataField="won" headerText="Games
    Won"/>
    <mx:DataGridColumn dataField="totalCash"
    headerText="Total Cash"/>
    </mx:columns>
    </mx:DataGrid>
    </mx:Panel>
    </mx:Application>
    and the following is the games.xml file format:
    <users>
    <user>
    <name>player 3</name>
    <loss>1</loss>
    <won>9</won>
    <totalCash>6,825</totalCash>
    </user>
    <user>
    <name>Player 10</name>
    <loss>12</loss>
    <won>7</won>
    <totalCash>2,075</totalCash>
    </user>
    </users>
    What is the best method to resolve this issue without
    performing so much array search?
    Many thanks

    Thanks for the Advice. I have tried both ways using an
    IViewCursor and e4x XML resultFormat, and I found the IViewCursor
    More Convient.
    The following is the code the code that I came up with
    private var userCursor:IViewCursor;
    private var tempCol:ArrayCollection;
    var ap_initialized:Boolean = false;
    private function bsResultHandler(event:ResultEvent):void {
    tempCol = event.result.users.user;
    // Initialization for the first time
    if (!ap_initialized){
    usersCol = tempCol;
    var sort:Sort = new Sort();
    sort.fields = [new SortField("name", true)];
    usersCol.sort = sort;
    usersCol.refresh();
    ap_initialized = true;
    // Disable Auto Update till all the changes are made to the
    ArrayCollection
    usersCol.disableAutoUpdate();
    userCursor = usersCol.createCursor();
    for (var i=0; i < tempCol.length; i++) {
    //Check if the item already exists
    if (userCursor.findAny({name:tempCol
    .name})){
    var tmpIndex = usersCol.getItemIndex(userCursor.current);
    usersCol.setItemAt(tempCol[ i ],tmpIndex);
    } else {
    // New Item to be Added
    usersCol.addItem(tempCol[ i ]);
    } // End For
    usersCol.enableAutoUpdate();
    load_Interval = setInterval(uSend, 2*1000);
    I don't think the above the optimal solution. Furthermore,
    there is a problem with grid; if you have 15 items in the grid, and
    you scroll to the middle of the grid, it keeps scrolling downwards
    with each new update. Something really wierd !!!

  • ArrayCollection/Single XML Node problem

    I've encountered a very frustrating situation that I would
    LOVE some help with. I am getting xml back from an HTTPService that
    I'm casting as an ArrayCollection. Very simple code:
    [Bindable]
    private var queueCol:ArrayCollection;
    queueCol = event.result.Response.CallQueue.QueueItem;
    This works great as long as there are multiple "QueueItem"
    nodes. once the sml gets down to ONE QueueItem Flex throws an ugly
    error. I have found this in other areas as well. It seems Flex
    cannot reconcile xml of only single child nodes.
    Has anyone else encountered this? Is there a
    workaround/different approach to get around this?

    You might try something like:
    queueCol = new
    ArrayCollection(event.result.Response.CallQueue.QueueItem is
    Array?event.result.Response.CallQueue.QueueItem:[event.result.Response.CallQueue.QueueIte m]);
    The SimpleXMLDecoder starts of converting a child node to a
    property, but if there's already something there, it converts it to
    an array. So flex doesn't have any problem reconciling xml with
    single child node - it is making a best guess in the absence of an
    xml schema. You can write your own decoder if you like (this is
    what I have done), and hand it to the HTTPService to use in place
    of the default. Then you can make it read a schema (if you have
    one).

  • Processing ArrayCollection or XML in PHP from Flex

    I know this is a Flex forum, but after I use HTTPService with
    POST and an ArrayCollection or XML object as the parameter, anybody
    have the PHP code I would use to grab the parameter on the server
    side?
    Once I have grabbed it and put it in a PHP variable I can
    figure out the rest.
    Thanks!

    One caveat for POST ing XML from AIR is that there is a bug
    and it submits as GET instead. Work-around I had to use was to
    upload XML file instead and then parse it.... otherwise from FLEX
    If you POST the XML as a parameter like so
    var params:Object = new Object()
    params.postText = myXML
    myHTTPService.send(params)
    and your XML is something like.....
    <root>
    <record><data>mydata</data></record>
    </root>
    then the PHP script looks something like.........
    foreach($_POST AS $key => $value) { ${$key} = $value; }
    if(isset($postText)){
    //echo $postText;
    $xml = new SimpleXMLElement($postText, LIBXML_NOCDATA);
    $record = $xml->record;
    // use first record to capture column names into array
    foreach($record[0]->record->children() as $col){
    $colNames[] = $col->getName();
    // then for each column , record get the values
    foreach($record->record as $row){
    foreach($colNames as $column){
    $values[] = $row->$column;
    //do something with the record
    else{
    exit;
    //get record level element name;
    $act = $xml->act;
    $table = $xml->table;
    $record = $xml->records;
    // get column names

Maybe you are looking for

  • I have purchased an adobe product and now I cannot access it?

    I had adobe installed on my computer and now I cannot access it.  Every time I try it asks me to buy the pro program

  • BOE-XI 3.1 Client Tools (SP4) Error

    BOE-XI 3.1 Client Tools (SP3) are installed OK on a Workstation... Business View Manager = 12.3.0.601 Designer = 12.3.0.601 WebIntelligence Rich Client = 12.3.0.601 I have downloaded the "SBOP Enterprise Client Tools XI 3.1 ServicePack 4" files from

  • Inconsistencies betwen balance and line items

    Hello masters! I found some inconsistencies betwen balance and line items. I tried to solve the problem using FAGLF03 and RFINDEX (when executing SAP retrieved: "New GL is active. GLT0 can not be adjusted") but both did not work. We have never gone t

  • Searching for phrases in Acrobat Professional 7.0

    Hi folks, I would like to search for a phrase like "ethic issue" in many single pdf-documents with Index-Searching (Catalog). Can anyone give me a little tip, whether and how is this possible in Acrobat Professional 7.0? That would be great! With kin

  • FCC..how to remove first row

    Hello experts, I have configured a end to end sccenario fo csv files, Im using fcc for the sender file adapter The first row has all the field names such as name,number and the rest of the rows have the values. when I run the scenario the xml being f