简体   繁体   English

在Flex / Flash Builder中使用Flash电影中的按钮

[英]Using a button within flash movie in flex/flash builder

Is it possible to build a UI with Flash CS5 that contains multiple buttons, and then have flex listen to those button events? 是否可以使用包含多个按钮的Flash CS5构建UI,然后让Flex监听这些按钮事件?

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. 我当前的计划是用SWFLoader加载SWF,并在onComplete事件中将侦听器附加到按钮上是设置它的正确方法,但是我似乎找不到找到一种方法来访问按钮本身并将侦听器附加到它们上。 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 . 加载Flash电影后,您可以使用loader.content从Flex应用程序访问它,其中loader是SWFLoader的id属性。

<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);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM