【问题标题】:Accessing children of loaded swf in Flex Image component在 Flex Image 组件中访问加载的 swf 的子级
【发布时间】:2010-03-15 19:05:47
【问题描述】:

enter code here我正在将外部 swf 加载到组件中。它加载一切正常,我可以看到在 swf 中工作的按钮,我可以添加一个影片剪辑,但我无法访问该影片剪辑(或不知道如何),并且当我尝试时它一直告诉我 numChildren = null追踪它。

这被设置为这样的自定义组件:

<cynergy:imageZoom
    id="zoomComponent" 
            borderStyle="solid" 
            source="{_data.map.@url}"
            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) 并返回索引超出范围的错误。

【问题讨论】:

  • 您是否检查过以确保您的代码可以在执行时引用 myComponent.image?您可能会遇到无法在动作脚本中引用的“图像”问题
  • 是的,mycomponent.image 可以通过 actionscript 访问。我什至可以向它添加东西,只是现在我已经添加了它们,我不知道如何访问这些东西。它不断产生 numChildren= null。
  • 我在这个问题中添加了更多细节,任何人都知道我可能做错了什么或者可以指出我正确的方向吗?

标签: apache-flex actionscript-3


【解决方案1】:

答案很简单:myComponent.image.content

还在加载完成之前调用它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-12
    相关资源
    最近更新 更多