简体   繁体   中英

Flex how to create a <mx:XML in actionscript

I guys and thanks to all in advance.

I have found a way to create a scrollable charts at this page: http://www.connectedpixel.com/pubfiles/srcview/scrollchart/index.html

It is a great solution and all works fine but now I have a problem with dataProvider: in the page example the data provider is embedded directly in the .mxml page:

 <mx:XML xmlns="" id="myData">
    <items>
        <item year="1960" rain="92" />
        <item year="1961" rain="192" />
        <item year="1962" rain="32" />
        <item year="1963" rain="52" />
        <item year="1964" rain="112" />
   </items>
 </mx:XML>

Obviously I need to create it dinamically and I can't find a way to do this... I have tried with:

 var xmlObject:XML = <items></items>;
 xmlObject.appendChild(<item year="1960" rain="92" />);
 ...

And other similar but no one works. With the above way if try to put the result in a:

<mx:TextArea text="{xmlObject.children()}" />

it appears blank even if the

trace(xmlObject.children()) 

inside the .as works.

I guys, I take a look to the code I downloaded from the site where I found the example. I can set even an ArrayCollection of generic Object as dataProvider for my columnChart but if I build it directly in my .mxml all works fine... if I build it dinamycally in my init() method of my .as the charts display the column but not the scrollbar, even if the object are more than the viewport can display.. And I realize that this is a bug of the code because if I resize the page the scroll bar appear!! Are there someone who have used that example and understand why the app works this way??

Thanks a lot

Thanks a lot AmigaAbattoir for your reply.. I debug the plugin I downloaded from the website I have posted on my question and I realize that I can declare even an ArrayCollection of Generic Object (for Example:

 <mx:ArrayCollection id="myData">
    <mx:Object y1="3" y2="2" x="1" />
    <mx:Object y1="4" y2="2" x="2" />
    <mx:Object y1="5" y2="3" x="3" />
 </mx:ArrayCollection>

) as a dataProvider for the charts.. The problem is that within the class that creates the scrollbar component there is a method that, before the .mxml is loaded, execute this instructions:

 IList list = _chart.dataProvider as IList;

And:

  • If I declare the ArrayCollection (or the XML Object) in the .mxml, list is enhanced

  • If I declare the ArrayCollection (or the XML Object) in the .as (even if I build the object in initialize() method or in creationComplete() method or even if I put add an eventListener to the ArrayCollection list is not enhanced

If list is not enhanced list.size() is 0, maxVisibileColumns is 8 (default) and scrollBar component is not added..

Than there are many solutions to solve this (triggering the Resize.Event, call the updateDisplayList(x:Number,y:Number) method or modifing the plugin code..

I hope this can save time for those who will have the same problem. Bye

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM