Flex和Flash之间相互调用

例子很简单,主要就是演示了下面二种调用方式。

1、在Flex中调用Flash中的方法。

2、在Flash中派发自定义事件到Flex中,并在Flex中监听此事件和取到事件中传送过来的数据。


感兴趣的直接下载代码看吧!代码太简单我就不贴代码上来了。

示例下载

 

 

// ***************************************************************************************

补充一下Flash生成的swf文件如果是用Embed标签嵌入在Flex工程中的时候,swf的方法如何调用:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    
<mx:Script>
        
<![CDATA[    
            [Embed(source="test_cs3.swf")]
            private var testCS:Class;
            
            [Bindable]
            private var test_cs:MovieClip = new testCS();

            private function testClicked():void
            {
                // test为test_cs3.swf中定义的一个方法
                Loader(test_cs.getChildAt(0)).content.test();        
            }
        
]]>
    
</mx:Script>

    
<mx:Image x="111" y="88" source="{test_cs}" id="flashContent"/>
    
<mx:Button x="294.5" y="43" label="Test" click="testClicked()" width="157" height="63"/>
</mx:Application>


 

posted @ 2010-05-10 11:53  1901  阅读(1668)  评论(0编辑  收藏  举报