2010-03-15 57 views
0

enter code here我正在將外部swf加載到組件中。它加載一切正常,我可以看到按鈕工作在瑞士法郎,我可以添加一個movieclip的,但我不能然後訪問該movieclip(或不知道如何),它會告訴我numChildren = null當我嘗試追查出來。在Flex圖像組件中訪問加載的swf的子項

這被設置爲自定義組件是這樣的:

<cynergy:imageZoom 
    id="zoomComponent" 
      borderStyle="solid" 
      source="{[email protected]}" 
      fadeDuration="1000" 
      bottom="0" left="0" top="0" right="0" 
      zoomIncrement="{ options.zoomIncrement }" 
      imageDoubleClickEnabled="{ options.imageDoubleClickEnabled }" 
      mouseWheelEnabled="{ options.mouseWheelEnabled }" 
      mouseFollow="{ options.mouseFollowEnabled }" /> 


> 



</cynergy> 

然後在我的imageZoom.mxml我有這樣的代碼:

<Canvas 
    visible="{ _source != null &amp;&amp; image.percentLoaded &lt; 100 }" horizontalCenter="0" verticalCenter="0" 
    hideEffect="WipeDown" showEffect="WipeDown" width="210" height="30" 
    borderStyle="solid" borderThickness="3" borderColor="#000000" backgroundColor="#FFFFFF" backgroundAlpha=".5" cornerRadius="10" > 

    <Label text="Loading... { Math.floor(image.percentLoaded) }%" fontSize="16" width="100%" textAlign="center"> 
     <filters> 
      <flash.filters:DropShadowFilter color="0" alpha=".5" /> 
     </filters> 
    </Label> 

</Canvas> 


<Image id="image" mask="{ maskCanvas }" source="{ _source }" mouseDown="image.startDrag()" visible="{ _source != null &amp;&amp; image.percentLoaded == 100 }" 
    showEffect="{ fadeInEffect }" complete="imageComplete()" doubleClickEnabled="true" doubleClick="onDoubleClick()" /> 

任何人都可以告訴我如何訪問加載的動畫片段中的孩子?

我試圖

mycomponent.image.getChildAt(2)並將其返回和錯誤,該索引超出範圍的。

+0

您是否檢查過以確保您的代碼可以引用myComponent.image?您可能在'動畫'中無法引用'圖像' – 2010-03-15 19:18:59

+0

是的,可以通過動作來訪問mycomponent.image。我甚至可以添加一些東西,但現在我不知道如何訪問那些已添加它們的東西。它保持生產numChildren = null。 – pfunc 2010-03-15 19:35:33

+0

我把更多的細節放在這個問題上,任何人都有一個想法,我可能會做錯什麼,或者可以指向正確的方向? – pfunc 2010-03-15 19:51:10

回答

0

是一個很容易回答:myComponent.image.content

也是調用它之前完成加載。