博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Building a simple Flex module
阅读量:6854 次
发布时间:2019-06-26

本文共 2691 字,大约阅读时间需要 8 分钟。

I’ve been playing around with Flex Modules lately and thought I’d post this. It’s pretty basic, but it is kind of a “my first module” type experiment. I tried to show a few different things including: calling a module’s methods from the parent application as well as setting properties in the parent application from the loaded module.

If you haven’t looked at modules in Flex yet, I highly encourage you to check out the Flex Doc Team blog at , where you can find their latest version of the “Creating Modular Applications” chapter (, ).

<?
xml version="1.0" encoding="utf-8"
?>
<
mx:Application 
xmlns:mx
="http://www.adobe.com/2006/mxml"
>
    
<
mx:Script
>
        
<![CDATA[
            import mx.events.VideoEvent;
            [Bindable]
            private var moduleTitle:String;
            private var vm:VideoModule;
            private function init():void {
                vm = VideoModule(m1.child);
                moduleTitle = vm.getModuleTitle();
            }
            private function stopVideo():void {
                vm.stopVideo();
            }
            private function playPauseVideo():void {
                vm.playPauseVideo();
            }
        
]]>
    
</
mx:Script
>
    
<
mx:Panel 
id
="panel"
 title
="Module: {moduleTitle}"
>
        
<
mx:ModuleLoader 
url
="VideoModule.swf"
 id
="m1"
 ready
="init()"
/>
        
<
mx:ControlBar
>
            
<
mx:Button 
label
="Play/Pause"
 click
="playPauseVideo()"
 
/>
            
<
mx:Button 
label
="Stop"
 click
="stopVideo()"
 
/>
            
<
mx:Spacer 
width
="100%"
 
/>
            
<
mx:Label 
id
="playheadTime"
 fontWeight
="bold"
 
/>
        
</
mx:ControlBar
>
    
</
mx:Panel
>
</
mx:Application
>

VideoModule.mxml

<?
xml version="1.0" encoding="utf-8"
?>
<
mx:Module 
xmlns:mx
="http://www.adobe.com/2006/mxml"
 width
="100%"
 height
="100%"
>
    
<
mx:Script
>
        
<![CDATA[
            public function getModuleTitle():String {
                return "Video Module";
            }
            /* Stop the video playback. */
            public function stopVideo():void {
                videoDisplay.stop();
            }
            /* If the video is currently playing, pause playback. Otherwise, resume playback. */
            public function playPauseVideo():void {
                if (videoDisplay.playing) {
                    videoDisplay.pause();
                } else {
                    videoDisplay.play();
                }
            }
            private function updateVideoTime():void {
                /* If the playheadTime is 0, the DateFormatter returns an empty string.
                   To work around this we can default the time to 10ms if the playheadTime
                   is zero. */
                var pTime:Date = new Date(videoDisplay.playheadTime * 1000 || 10);
                var tTime:Date = new Date(videoDisplay.totalTime * 1000);
                parentApplication.playheadTime.text = dateFormatter.format(pTime) + " / " + dateFormatter.format(tTime);
            }
        
]]>
    
</
mx:Script
>
    
<
mx:DateFormatter 
id
="dateFormatter"
 formatString
="NN:SS"
 
/>
    
<
mx:VideoDisplay 
id
="videoDisplay"
 source
="http://www.helpexamples.com/flash/video/cuepoints.flv"
 playheadUpdate
="updateVideoTime()"
 
/>
</
mx:Module
>
    本文转自 OldHawk  博客园博客,原文链接:http://www.cnblogs.com/taobataoma/archive/2008/01/13/1037026.html
,如需转载请自行联系原作者
你可能感兴趣的文章
java B2B2C Springcloud电子商务平台源码-zuul 过滤器机制
查看>>
【更新】LEADTOOLS v20最新版发布(三)
查看>>
企业分布式微服务云SpringCloud SpringBoot mybatis -服务的注册与发现(Eureka)
查看>>
java B2B2C 仿淘宝电子商城系统-Zuul的使用
查看>>
深度解析数据分析、大数据工程师和数据科学家的区别
查看>>
Linux-文件处理命令-file
查看>>
关于一个小程序
查看>>
利用dispatch_once创建单例
查看>>
Centos LVS DR模式详细搭建过程
查看>>
失败者共性
查看>>
批量修改文件名和移动文件
查看>>
常用设计模式(C++示例)
查看>>
一段有趣的代码,猜生日
查看>>
SQL SERVER 2005索引自动维护
查看>>
80后的记忆
查看>>
05、AGDLP组的嵌套
查看>>
加密解密与OPENSSL建立私有CA
查看>>
【ZBar】ios错误ignoring file xxx missing required architecture x86_64 in file
查看>>
实例详解top
查看>>
linux 把nginx加入到系统服务,并开机自己启动的方法
查看>>