• Flex中的Repeater组件出错(二)


    1、源码如下

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
    			   xmlns:s="library://ns.adobe.com/flex/spark" 
    			   xmlns:mx="library://ns.adobe.com/flex/mx"
    			   width="100%" height="100%">
    	<s:layout>
    		<s:BasicLayout/>
    	</s:layout>
    	<fx:Declarations>
    		<!-- 将非可视元素(例如服务、值对象)放在此处 -->
    	</fx:Declarations>
    	<fx:Script>
    		<![CDATA[
    			private var myArray:Array = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16];
    		]]>
    	</fx:Script>
    	
    	<s:ArrayCollection id="ac" source="{myArray}"/>
    	<mx:Repeater dataProvider="{ac}" startingIndex="2" count="4">
    		<mx:HBox>
    			<s:Button label="查询" click="myText[event.target.instanceIndices].text=
    					  event.target.instanceIndices.toString();"/>
    			<s:TextInput id="myText"/>
    		</mx:HBox>
    	</mx:Repeater>
    </s:Application>
    

    2、错误如下



    3、解决方法

    (1)对于错误1,采取给Repeater加一个VBox

    <mx:VBox width="100%" height="100%"  horizontalAlign="center" verticalAlign="middle">
    		<mx:Repeater dataProvider="{ac}" startingIndex="2" count="10">
    			<mx:HBox>
    				<s:Button label="查询" click="myText[event.target.instanceIndices].text=
    						  event.target.instanceIndices.toString();"/>
    				<s:TextInput id="myText"/>
    			</mx:HBox>
    		</mx:Repeater>
    	</mx:VBox>

    (2)对于错误2,将ArrayCollection放在声明中

    <fx:Declarations>
    		<s:ArrayCollection id="ac" source="{myArray}"/>
    	</fx:Declarations>


  • 相关阅读:
    cocos2d-x的初步学习七
    cocos2d-x的初步学习六
    cocos2d-x的初步学习五
    cocos2d-x的初步学习四
    net core or Linux
    XML序列化反序列化
    用NSoup解析HTML
    ubuntu 下的ftp安装及root身份远程配置
    Windows 10 子系统Linux重启(不重启Win10)
    C# HttpRequest 请求
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13315640.html
Copyright © 2020-2023  润新知