简体   繁体   English

Flex如何创建一个

[英]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 我在此页面上找到了一种创建可滚动图表的方法: 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: 这是一个很好的解决方案,并且一切正常,但现在dataProvider存在问题:在页面示例中,数据提供程序直接嵌入在.mxml页面中:

 <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. 在.as内部。

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!! 我甚至可以将通用对象的ArrayCollection设置为我的columnChart的dataProvider,但是如果直接在.mxml中构建它,则一切正常...如果我在.it的init()方法中以动态方式构建它,则图表显示该列但是滚动条却不行,即使对象超出了视口可以显示的范围。我也意识到这是代码的错误,因为如果我调整页面大小,则会出现滚动条! 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: 非常感谢AmigaAbattoir的回复。.我调试了从发布在问题网站上的网站下载的插件,并且意识到甚至可以声明通用对象的ArrayCollection(例如:

 <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: )作为图表的dataProvider。问题是,在创建滚动条组件的类中,存在一种方法,该方法在加载.mxml之前执行以下指令:

 IList list = _chart.dataProvider as IList;

And: 和:

  • If I declare the ArrayCollection (or the XML Object) in the .mxml, list is enhanced 如果我在.mxml中声明ArrayCollection(或XML对象),则list会得到增强

  • 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 如果我在.as中声明ArrayCollection(或XML对象)(即使我在initialize()方法或creationComplete()方法中构建对象,或者即使我将eventListener添加到ArrayCollection列表中也不会得到增强)

If list is not enhanced list.size() is 0, maxVisibileColumns is 8 (default) and scrollBar component is not added.. 如果list不增强list.size()为0,则maxVisibileColumns为8(默认值),并且不添加scrollBar组件。

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.. 有很多解决方案可以解决此问题(触发Resize.Event,调用updateDisplayList(x:Number,y:Number)方法或修改插件代码。)

I hope this can save time for those who will have the same problem. 我希望这可以为那些有同样问题的人节省时间。 Bye 再见

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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