在flex / flash构建器中使用Flash电影中的按钮 [英] Using a button within flash movie in flex/flash builder
问题描述
是否可以使用包含多个按钮的Flash CS5构建UI,然后让flex监听这些按钮事件?
我目前的计划是加载SWF和SWFLoader并将监听器附加到onComplete事件中的按钮将是正确的方式来设置它,但我似乎无法找到一种方式来访问按钮本身,并将侦听器附加到它们。当然,我会给每个按钮自己的实例名称。
指针和/或示例将不胜感激。
SWFLoader
的id属性。 < mx:SWFLoader id =loadersource =Movie.swfheight =100width =350
complete =onComplete()/>
脚本:
//加载剪辑:从应用程序的creationComplete中执行此操作
loader.load();
//在加载完成时调用
private function onComplete():void
{
trace(loaded+ loader.content);
var loadedMc:MovieClip = MovieClip(loader.content);
//访问实例名称为myButton的按钮:
loadedMc.myButton.addEventListener(MouseEvent.CLICK,onBtnClick);
}
Is it possible to build a UI with Flash CS5 that contains multiple buttons, and then have flex listen to those button events?
My current plan is to load the SWF with SWFLoader and attaching listeners to the buttons in a onComplete event would be the proper way to set it up, however i cannot seem to find a way to access the buttons themselves and attach listeners to them. Of course i would give each button its own instance name.
Pointers and/or examples would be greatly appreciated.
Once the Flash movie is loaded, you can access it from your Flex app using loader.content, where loader is the id attribute of your SWFLoader
.
<mx:SWFLoader id="loader" source="Movie.swf" height="100" width="350"
complete="onComplete()"/>
Script:
//load the clip: do this from creationComplete of the app
loader.load();
//this will be called when loading is complete
private function onComplete():void
{
trace("loaded " + loader.content);
var loadedMc:MovieClip = MovieClip(loader.content);
//access the button with instance name myButton:
loadedMc.myButton.addEventListener(MouseEvent.CLICK, onBtnClick);
}
这篇关于在flex / flash构建器中使用Flash电影中的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!