在 Flex 中向 CoverFlow 添加组件
我正在使用 Doug McCune 的 CoverFlow 库 。
在包含的示例中,他在 CoverFlowContainer
内创建了一些面板。 还有其他示例,显示他从上面链接的页面上的 RSS 提要填充封面流,但他没有包含这些源:(
我最终将从 Web 服务检索数据以添加到封面流,但我开始通过这个简单的示例:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" horizontalAlign="center" verticalAlign="middle" xmlns:containers="com.dougmccune.containers.*" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.controls.TextArea;
public var articlePanel:Panel = new Panel();
public var articleTextArea:TextArea = new TextArea();
private function init() : void
{
articlePanel.addChild(articleTextArea);
articlePanel.title = "test tile"
articleTextArea.text = "article1" + "\n" + "www.article.com" + "\n" + "hello this is article 1";
coverflow2.addChild(articlePanel);
}
]]>
</mx:Script>
<mx:VBox id="box" verticalGap="0" height="306" width="100%" maxWidth="600" maxHeight="300" >
<containers:CoverFlowContainer id="coverflow2" width="100%" height="244"
horizontalGap="40" borderStyle="inset" backgroundColor="0x000000"
segments="6" reflectionEnabled="true">
<mx:Panel id="testpanel" width="200" height="200" title="Mxml title">
<mx:DataGrid width="100%" height="100%">
<mx:columns>
<mx:DataGridColumn headerText="Column 1" dataField="col1"/>
<mx:DataGridColumn headerText="Column 2" dataField="col2"/>
<mx:DataGridColumn headerText="Column 3" dataField="col3"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
<mx:Panel id="buttonpanel" width="200" height="200" title="Mxml title">
<mx:Button id="myButton" label="Change title" click="buttonpanel.title = ('hello') "/>
</mx:Panel>
</containers:CoverFlowContainer>
</mx:VBox>
</mx:Application>
将我在 ActionScript 中创建的新面板添加到 CoverFlow 容器中。
我在 mxml 中定义了一些面板并设置了 creationComplete=init()
,以便在启动时 该应用程序显示两个预定义的面板,但不是我在 ActionScript 中创建的面板
有更好的方法吗?
I'm working with the CoverFlow library by Doug McCune.
In the example included, he has created some panels inside a CoverFlowContainer
. There are other examples of him populating the coverflow from an RSS feed on the page linked above but he doesn't include the source for these :(
I will eventually be retrieving data from a web service to add to the coverflow however I'm starting with this simple example:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" horizontalAlign="center" verticalAlign="middle" xmlns:containers="com.dougmccune.containers.*" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.controls.TextArea;
public var articlePanel:Panel = new Panel();
public var articleTextArea:TextArea = new TextArea();
private function init() : void
{
articlePanel.addChild(articleTextArea);
articlePanel.title = "test tile"
articleTextArea.text = "article1" + "\n" + "www.article.com" + "\n" + "hello this is article 1";
coverflow2.addChild(articlePanel);
}
]]>
</mx:Script>
<mx:VBox id="box" verticalGap="0" height="306" width="100%" maxWidth="600" maxHeight="300" >
<containers:CoverFlowContainer id="coverflow2" width="100%" height="244"
horizontalGap="40" borderStyle="inset" backgroundColor="0x000000"
segments="6" reflectionEnabled="true">
<mx:Panel id="testpanel" width="200" height="200" title="Mxml title">
<mx:DataGrid width="100%" height="100%">
<mx:columns>
<mx:DataGridColumn headerText="Column 1" dataField="col1"/>
<mx:DataGridColumn headerText="Column 2" dataField="col2"/>
<mx:DataGridColumn headerText="Column 3" dataField="col3"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
<mx:Panel id="buttonpanel" width="200" height="200" title="Mxml title">
<mx:Button id="myButton" label="Change title" click="buttonpanel.title = ('hello') "/>
</mx:Panel>
</containers:CoverFlowContainer>
</mx:VBox>
</mx:Application>
I've defined some panels in the mxml and set creationComplete=init()
so that the new panel I've created in ActionScript will be added to the CoverFlow container.
When I launch the application it displays the two predefined panels but not the one I have created in ActionScript.
Any ideas? Is there a better way of doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以尝试 mx:Repeater 组件
you can try mx:Repeater component
通过首先定义其中没有任何内容的 coverflow 容器来修复此问题:
在操作脚本部分中,我从 Web 服务检索一个数组,并为数组中的每个项目创建一个面板。 为每个面板指定宽度和高度非常重要,否则它只会在封面流中显示一个元素或根本不显示任何元素:
Fixed this by first defining the coverflow container with nothing in it:
In the actionscript section I retrieve an array from a web service and for each item in the array I create a panel. It is important to give each panel a width and height otherwise it will only show one element in the coverflow or no elements at all: