Use braces... see if this works:

<mx:Panel title="{data.day[0].name}">

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Merrill,
Jason
Sent: Thursday, October 20, 2005 10:27 AM
To: Flashcoders mailing list
Subject: RE: [Flashcoders] Help with Flexbuilder 2 and XML loading

Mike, thanks.  So right, I know about the new specs for accesing XML,
sorry I wasn't clear, what I meant was, how do I access the node value
WITHIN the mxml?

So if my XML file is:

<data>
     <day>
          <name>Monday</name> //(repeating node)
          etc.

And I have first loaded it in using the script you sent, then I would
expect I would access it like this:

data.day[0].name

But if I do:
<mx:Panel title=data.day[0].name>

I get a compiler error saying that quotes are expected for the title
attribute.

So if I put in the quotes:
<mx:Panel title="data.day[0].name">

Then it doesn't evaluate, it treats it as a string and appears literally
in the .swf as data.day[0].name

I can't seem to find any examples in the docs bridging the  loading XML
and then using it in mxml - there seem to be examples of the new syntax
to traverse the tree, and also examples of loading XML, but nothing
combining the two and referring to the node in mxml.  At least, I
couldn't find any.    

Thanks for any help or examples.


Jason Merrill   |   E-Learning Solutions   |  icfconsulting.com










>>-----Original Message-----
>>From: [EMAIL PROTECTED] [mailto:flashcoders-
>>[EMAIL PROTECTED] On Behalf Of Mike Chambers
>>Sent: Wednesday, October 19, 2005 3:33 PM
>>To: Flashcoders mailing list
>>Subject: Re: [Flashcoders] Help with Flexbuilder 2 and XML loading
>>
>>With E4X:
>>
>>http://labs.macromedia.com/wiki/index.php/ActionScript_3:resources:api
s:E4X
>>
>>mike chambers
>>
>>[EMAIL PROTECTED]
>>
>>Merrill, Jason wrote:
>>> Cool, thanks.  That didn't throw any errors.  Now how would I
traverse
>>> that XML data in my mxml?
>>>
>>> Jason Merrill   |   E-Learning Solutions   |  icfconsulting.com
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>>>-----Original Message-----
>>>>>From: [EMAIL PROTECTED]
[mailto:flashcoders-
>>>>>[EMAIL PROTECTED] On Behalf Of Mike Chambers
>>>>>Sent: Wednesday, October 19, 2005 3:08 PM
>>>>>To: Flashcoders mailing list
>>>>>Subject: Re: [Flashcoders] Help with Flexbuilder 2 and XML loading
>>>>>
>>>>>Try this (tested and works here);
>>>>>
>>>>>I think the main issue was that you were not importing the classes.
I
>>>>>changed a few other things also. Let me know if this doesn't run,
or
>>>
>>> if
>>>
>>>>>you have questions.
>>>>>
>>>>>------
>>>>><?xml version="1.0"?>
>>>>><mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml";
>>>>>   creationComplete="onCreationComplete()">
>>>>>
>>>>>     <mx:Script><![CDATA[
>>>>>         import mx.formatters.*;
>>>>>         import flash.net.URLRequest;
>>>>>         import flash.net.URLLoader;
>>>>>
>>>>>   var myXML:XML;
>>>>>   var myXMLURL:URLRequest;
>>>>>
>>>>>   private function onCreationComplete():Void
>>>>>   {
>>>>>           myXML = new XML();
>>>>>
>>>>>           myXMLURL = new URLRequest("data.xml");
>>>>>           var myLoader:URLLoader = new URLLoader(myXMLURL);
>>>>>           myLoader.addEventListener("complete", xmlLoaded);
>>>>>   }
>>>>>
>>>>>   private function xmlLoaded(evtObj:Event) {
>>>>>             myXML = XML(evtObj.target.data);
>>>>>             trace("Data loaded.");
>>>>>   }
>>>>>        ]]>
>>>>>    </mx:Script>
>>>>></mx:Application>
>>>>>----------
>>>>>
>>>>>mike chambers
>>>>>
>>>>>[EMAIL PROTECTED]
>>>>>
>>>>>Merrill, Jason wrote:
>>>>>
>>>>>>Thanks Mike, but I tried your script and got the exact same
compiler
>>>>>>errors.  Ultimately what I am trying to do is bind some XML data
>>>
>>> into a
>>>
>>>>>>pie chart.  I have the pie chart working fine, but the data is
just
>>>
>>> hard
>>>
>>>>>>coded into an Actionscript object, and I would like to use XML
>>>
>>> instead.
>>>
>>>>>>Any ideas?
>>>>>>
>>>>>>So, the data.xml and the mmxl file are in the same folder, and the
>>>
>>> XML
>>>
>>>>>>file is called data.xml - and just contains 3-4 simple XML nodes.
>>>>>>
>>>>>>Jason Merrill   |   E-Learning Solutions   |  icfconsulting.com
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>>>-----Original Message-----
>>>>>>>>From: [EMAIL PROTECTED]
>>>
>>> [mailto:flashcoders-
>>>
>>>>>>>>[EMAIL PROTECTED] On Behalf Of Mike Chambers
>>>>>>>>Sent: Wednesday, October 19, 2005 2:02 PM
>>>>>>>>To: Flashcoders mailing list
>>>>>>>>Subject: Re: [Flashcoders] Help with Flexbuilder 2 and XML
loading
>>>>>>>>
>>>>>>>>This should work (havent compiled, so might have a typo or two).
>>>>>>>>
>>>>>>>><?xml version="1.0"?>
>>>>>>>><mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml";
>>>>>>>>        creationComplete="onCreationComplete()">
>>>>>>>>
>>>>>>>>   <mx:Script><![CDATA[
>>>>>>>>       import mx.formatters.*;
>>>>>>>>       [Bindable]
>>>>>>>>
>>>>>>>>        var myXML:XML;
>>>>>>>>        var XML_URL:String
>>>>>>>>
>>>>>>>>        private function onCreationComplete():Void
>>>>>>>>        {
>>>>>>>>                myXML = new XML();
>>>>>>>>                XML_URL = "data.xml";
>>>>>>>>                myXMLURL = new URLRequest(XML_URL);
>>>>>>>>                var myLoader:URLLoader = new
URLLoader(myXMLURL);
>>>>>>>>                myLoader.addEventListener("complete",
xmlLoaded);
>>>>>>>>        }
>>>>>>>>
>>>>>>>>        function xmlLoaded(evtObj:Event) {
>>>>>>>>          myXML = XML(myLoader.data);
>>>>>>>>          trace("Data loaded.");
>>>>>>>>        }
>>>>>>>>      ]]>
>>>>>>>>  </mx:Script>
>>>>>>>></mx:Application>
>>>>>>>>
>>>>>>>>mike chambers
>>>>>>>>
>>>>>>>>[EMAIL PROTECTED]
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>Merrill, Jason wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>>I'm trying to load in an XML file in Flexbuilder 2, but I get
>>>>>>
>>>>>>errors.
>>>>>>
>>>>>>
>>>>>>>>>My file "data.xml" is in the same folder as "test1.mxml".
>>>>>>>>>
>>>>>>>>>The errors are:
>>>>>>>>>
>>>>>>>>>Access of undefined property myLoader  test1.mxml      test1
>>>>>>
>>>>>>line 11
>>>>>>
>>>>>>
>>>>>>>>>Access of undefined property xmlLoaded test1.mxml      test1
line 12
>>>>>>>>>
>>>>>>>>>Here is the script test1.mxml:
>>>>>>>>>
>>>>>>>>><?xml version="1.0"?>
>>>>>>>>><mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml";>
>>>>>>>>>
>>>>>>>>>   <mx:Script><![CDATA[
>>>>>>>>>       import mx.formatters.*;
>>>>>>>>>       [Bindable]
>>>>>>>>>
>>>>>>>>>       var myXML:XML = new XML();
>>>>>>>>>       var XML_URL:String = "data.xml";
>>>>>>>>>       var myXMLURL:URLRequest = new URLRequest(XML_URL);
>>>>>>>>>       var myLoader:URLLoader = new URLLoader(myXMLURL);
>>>>>>>>>       myLoader.addEventListener("complete", xmlLoaded);
>>>>>>>>>
>>>>>>>>>       function xmlLoaded(evtObj:Event) {
>>>>>>>>>         myXML = XML(myLoader.data);
>>>>>>>>>         trace("Data loaded.");
>>>>>>>>>       }
>>>>>>>>>      ]]>
>>>>>>>>>  </mx:Script>
>>>>>>>>></mx:Application>
>>>>>>>>>
>>>>>>>>>Any idea what I am doing wrong?  I followed the examples in the
>>>>>>
>>>>>>docs.
>>>>>>
>>>>>>
>>>>>>>>>Thanks.
>>>>>>>>>
>>>>>>>>>Jason Merrill   |   E-Learning Solutions   |  icfconsulting.com
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>NOTICE:
>>>>>>>>>This message is for the designated recipient only and may
contain
>>>>>>
>>>>>>privileged or
>>>>>>
>>>>>>
>>>>>>>>confidential information. If you have received it in error,
please
>>>>>>
>>>>>>notify the sender
>>>>>>
>>>>>>
>>>>>>>>immediately and delete the original. Any other use of this
e-mail
>>>
>>> by
>>>
>>>>>>you is
>>>>>>
>>>>>>
>>>>>>>>prohibited.
>>>>>>>>
>>>>>>>>
>>>>>>>>>_______________________________________________
>>>>>>>>>Flashcoders mailing list
>>>>>>>>>[email protected]
>>>>>>>>>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>>>>>>>
>>>>>>>>
>>>>>>>>_______________________________________________
>>>>>>>>Flashcoders mailing list
>>>>>>>>[email protected]
>>>>>>>>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>>>>
>>>>>>_______________________________________________
>>>>>>Flashcoders mailing list
>>>>>>[email protected]
>>>>>>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>>>>
>>>>>
>>>>>_______________________________________________
>>>>>Flashcoders mailing list
>>>>>[email protected]
>>>>>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>
>>> _______________________________________________
>>> Flashcoders mailing list
>>> [email protected]
>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>
>>
>>_______________________________________________
>>Flashcoders mailing list
>>[email protected]
>>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to