开发者社区> 技术小胖子> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

Building a simple Flex module

简介:
+关注继续查看

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 http://blogs.adobe.com/flexdoc/, where you can find their latest version of the “Creating Modular Applications” chapter (blog entryPDF).

<?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,如需转载请自行联系原作者


版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
SAP Fiori element框架template的框架加载逻辑
Created by Wang, Jerry, last modified on Dec 13, 2016
65 0
very important tip - when to add / in binding path Fiori
very important tip - when to add / in binding path Fiori
37 0
very important tip - when to add / in binding path Fiori
very important tip - when to add / in binding path Fiori
54 0
Hadoop报错:could only be replicated to 0 nodes, instead of 1
1 发现问题 执行hadoop上传文件命令,报错could only be replicated to 0 nodes, instead of 12 方案1 原因:查看logs文件夹下datanode相关日志:java.io.IOException: Incompatible clusterIDs in /home/hadoop-2.X.X/tmp/dfs/data: namenode
2463 0
计数排序 + 线段树优化 --- Codeforces 558E : A Simple Task
E. A Simple Task Problem's Link: http://codeforces.com/problemset/problem/558/E   Mean:  给定一个字符串,有q次操作,每次操作将(l,r)内的字符升序或降序排列,输出q次操作后的字符串。
956 0
在Eclipse中编写servlet时出现"The import javax.servlet cannot be resolved" 问题解决办法
方法1:在Eclipse中,右击项目,选择Java Build Path->Libraries->Add External JARs,找到你计算机中tomcat的安装路径,在common\lib文件夹下选中"servlet-api.
2402 0
超级高兴.flex builder 的插件拷贝可以 在 eclipse 3.5 里面运行.
做java的 打开 2 个eclipse 一个开发java 一个调试 flex builder 还是非常麻烦的..   突然有一个想法 既然都是 eclipse 拷贝下运行看看可以么...   发现真的可以..   以后的事情可是方便多了..   一边写 做 j2ee 一边 写 flex.     将 flex builder 下面的 plugin adobe
997 0
Base PyQt4, Simple Web APP Framwork
  长时间以来,一直针对Linux 服务器开发后台程序,每天面对的是黑框框,输出只有日志文件。偶尔需要模拟客户端测试,要么是写几行php代码,在浏览器上点一点,要么是写个小Python脚本在shell中执行一下。
1255 0
flex4/flash builder中动态加载Module并与之交互的正确方式
关于flex中动态加载Module的文章,网上有很多,但多半是基于flex3的,如果在flash builder/flex4中按他们所提供的方法去做,最后将module加载到容器中时,会报:null object reference错误。
774 0
文章
问答
文章排行榜
最热
最新
相关电子书
更多
Semantic Search--Fast Results from Large,Foreign Language Corpora
立即下载
Building a Search Engine
立即下载
Many-Birds-One-Stone-Exploiting-A-Single-SQLite-Vulnerability-Across-Multiple-Software
立即下载