微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

flex 连续播放图片

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="init();">         <mx:Script>         <![CDATA[             private var loader:Loader = new Loader();              private var request:URLRequest;                         private var sizeflag:Boolean = true;    //图片大小标志,true为小图             private var i:int = 0;                  //计数器跳动次数记录                         private var timer:Timer = new Timer(25);                         public function init():void             //初始化             {                 request = new URLRequest("监控背景.jpg");    //放入图片                 loader.load(request);                 loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);                 timer.addEventListener(TimerEvent.TIMER,reloadImg);   //开始计数                 timer.start();             }                         public function onComplete(e:Event):void             {                 var bitmap:Bitmap = Bitmap(loader.content);                 img.source = bitmap;             }                         public function reloadImg(e:TimerEvent):void              //按照计数奇偶切换图片             {                 //img.removeChildAt(0);                                       if (i%2 == 1)                 {                     request = new URLRequest("监控背景.jpg");                     loader.load(request);                 }                 else                 {                     request = new URLRequest("监控背景1.JPG");                     loader.load(request);                 }                    i++;             }             public function changeImgSize():void                   //改变图片大小             {                 if (sizeflag){                     img.width = 640;                     img.height = 480;                                         sizeflag = false;                 }                 else {                                         img.width = 320;                     img.height = 240;                     sizeflag = true;                 }             }         ]]>     </mx:Script>     <mx:Image id="img" x="10" y="10" width="320" height="240"/>     <mx:Button id="myBtn" x="10" y="498" label="Button" click="changeImgSize();"/>     </mx:Application>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐