2011-04-04 34 views
0

給大家的好日子!將選定的項目從DataGroup(數據提供者是XML列表)綁定到另一個組件(FLEX 4)

我有一個DataGroup,它具有從XML列表傳遞給ArrayCollection的縮略圖。我也有一個數據組的自定義項目渲染器。我做不到的工作如下:當數據組中的縮略圖被點擊時,狀態改變爲帶有關於項目信息的頁面。

我有相同的XML文件中的信息。我需要將richtext和多個標籤組件的源代碼綁定到數據組中的選定項目,並使用XML列表中項目的不同屬性。它它是一個簡單的列表組件,我會做下列方式: 的名單
ID =「myList中」的dataProvider =「{} myProjects.Project」 爲標籤 文本=「{ myList.selectedItem.textexample}」

我對DATAGROUP代碼:

<s:DataGroup includeIn="ThumbnailList" dataProvider="{myList}" alpha="0.72" 
blendMode="luminosity" buttonMode="true" id="myThumbs" 
clipAndEnableScrolling="true" height="187" 
itemRenderer="components.CustomRenderer4Thumbs" 
d:userLabel="hos_RepeatedItem" width="320" x="110" y="2" /> 

渲染器的代碼:

<fx:Script> 
    <![CDATA[ 
     [Bindable] public var counter:Number=0; 
     protected function image1_clickHandler(event:MouseEvent):void 
     { 
      if(counter==0) 
      { 
      this.currentState="selected"; 
      moveIn.play([offsets]); 
      counter=1; 
      } 
      else if(counter==1) 
      { 
      mx.core.FlexGlobals.topLevelApplication.currentState="DescriptionPagefromThumbs"; 
      counter=0; 
      } 
     } 
    ]]> 
</fx:Script> 
<fx:Declarations> 
    <s:Animate id="Larger" duration="250">  
     <s:motionPaths> 
      <s:SimpleMotionPath property="height" valueFrom="50" valueTo="100" /> 
      <s:SimpleMotionPath property="width" valueFrom="50" valueTo="100" />  
     </s:motionPaths> 
    </s:Animate> 
    <s:Animate id="moveIn" target="{offsets}" duration="650"> 
     <s:SimpleMotionPath property="scaleX" /> 
     <s:SimpleMotionPath property="scaleY" /> 
     <s:SimpleMotionPath property="x" /> 
     <s:SimpleMotionPath property="y" /> 
    </s:Animate> 
</fx:Declarations> 
<s:states> 
    <s:State name="normal"/> 
    <s:State name="hovered"/> 
    <s:State name="selected"/> 
</s:states> 
<mx:Image height.hovered="50" click="image1_clickHandler(event)" id="image1" maintainAspectRatio="true" smoothBitmapContent="true" source="{data.Thumb}" d:userLabel="hos_RepeatedItemTH" width.hovered="50" x="0" y="0"/> 

XML列表中包含至少有標題,Thumb和textexample每個項目。

我將不勝感激任何幫助!

回答

0

而不是使用<s:DataGroup/>佈局您的拇指,只需繼續並使用<s:List/>。您可以設置列表組件的佈局使用<s:BasicLayout/>,並在List設置borderVisible="false"contentBackgroundAlpha="0",使它看起來酷似DataGroup確實,但是您現在可以訪問ListselectedItem財產。

例如:

<s:List id="myThumbs" includeIn="ThumbnailList" 
     dataProvider="{myList}" 
     borderVisible="false" contentBackgroundAlpha="0" 
     alpha="0.72" blendMode="luminosity" 
     x="110" y="2" width="320" height="187" 
     itemRenderer="components.CustomRenderer4Thumbs" > 
    <s:layout> 
     <s:BasicLayout/> 
    </s:layout> 
</s:List> 
相關問題