0

我正在使用Doug McCune 的 CoverFlow 库

在包含的示例中,他在CoverFlowContainer. 还有其他例子,他从上面链接的页面上的 RSS 提要填充封面流,但他不包括这些的来源:(

我最终将从 Web 服务中检索数据以添加到 Coverflow,但是我从这个简单的示例开始:

<?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>

我在 mxml 中定义了一些面板并进行了设置creationComplete=init(),以便将我在 ActionScript 中创建的新面板添加到 CoverFlow 容器中。

当我启动应用程序时,它会显示两个预定义面板,但不是我在 ActionScript 中创建的那个。

有任何想法吗?有没有更好的方法来做到这一点?

4

2 回答 2

2

你可以试试 mx:Repeater 组件

<mx:HTTPService id="srv" url="pics.xml"/>
<ns2:CarouselContainer id="cf" width="100%" height="303" horizontalGap="40"
                       segments="6" reflectionEnabled="true" angle="10" >

    <mx:Repeater id="r" dataProvider="{srv.lastResult.images.image}">
        <mx:Canvas width="200" height="200">
            <mx:Image source="{r.currentItem.src}"/>
        </mx:Canvas>
    </mx:Repeater>

</ns2:CarouselContainer>
于 2009-10-22T13:59:53.370 回答
0

通过首先定义其中没有任何内容的coverflow容器来解决此问题:

<containers:CoverFlowContainer id="coverflow" width="100%" height="244" 
                horizontalGap="40" borderStyle="inset" backgroundColor="0x000000"
                reflectionEnabled="true"/>

在 actionscript 部分,我从 Web 服务中检索一个数组,并为数组中的每个项目创建一个面板。为每个面板指定宽度和高度很重要,否则它将仅显示封面流中的一个元素或根本不显示任何元素:

articlePanel.width = 200;
articlePanel.height = 200;
于 2009-07-06T13:33:39.000 回答