带延时加载,自动刷新和拖动控制的Canvas
来源:互联网 发布:贵州大数据企业排名 编辑:程序博客网 时间:2024/05/22 10:25
Canvas应该是大家在开发flex接触比较多控件吧,但是它的功能比较单一,很多人都要给予2次开发,我也是一样,为了做好延时的flex控件异步加载。一个巨大的flex整体切割成为很多很小很小的swf,就要做了一个延时加载。每个Canvas都有。
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
- initialize="loadInit()"
- backgroundColor="0xffffff">
- <mx:Script>
- <!--[CDATA[
- import mx.controls.Image;
- import mx.controls.Alert;
- import flash.utils.setTimeout;
- import org.bytearray.gif.player.GIFPlayer;
- //自动刷新
- public var autoRefreshPolicy="off";
- public var autoRefreshTime:String="60000";
- public var autoRefreshMethod:Function;
- private var loading:Image;
- private var myGIFPlayer:GIFPlayer=new GIFPlayer(true);
- public var gifUrl:String="resource/image/config/canvasLoading.gif";
- //移动性
- private var oldIndex:int=0;
- public var moveable:Boolean=false;
- public function loadInit():void
- {
- loading=new Image;
- loading.width=50;
- loading.height=50;
- loading.x=0;
- loading.y=0;
- var request:URLRequest=new URLRequest(gifUrl);
- myGIFPlayer.load(request);
- myGIFPlayer.visible=true;
- loading.addChild(myGIFPlayer);
- this.addChild(loading);
- this.enabled=false;
- if (autoRefreshPolicy == "on")
- {
- setTimeout(autoRefresh, 800);
- }
- this.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, dragBegin);
- this.addEventListener(flash.events.MouseEvent.MOUSE_UP, dragEnd);
- }
- public function autoRefresh():void
- {
- var time:Number=Number(autoRefreshTime) * 1000;
- var timer:Timer=new Timer(time);
- timer.addEventListener(TimerEvent.TIMER, onTimer);
- timer.start();
- }
- public function onTimer(event:TimerEvent):void
- {
- if (autoRefreshMethod != null)
- {
- autoRefreshMethod.call(this);
- }
- else
- {
- Alert.show("自动刷新函数为空");
- }
- }
- public function startLoading():void
- {
- loading.visible=true;
- this.enabled=false;
- }
- public function completeLoading():void
- {
- loading.visible=false;
- this.enabled=true;
- }
- private function dragBegin(event:MouseEvent):void
- {
- if (moveable == true)
- {
- oldIndex=this.parent.getChildIndex(this);
- this.parent.setChildIndex(this, this.parent.numChildren - 1);
- this.startDrag(false);
- }
- }
- private function dragEnd(event:MouseEvent):void
- {
- if (moveable == true)
- {
- this.parent.setChildIndex(this, oldIndex);
- this.stopDrag();
- }
- }
- //延迟执行
- protected function delayFunction(closure:Function, delay:Number, ... arguments):void
- {
- setTimeout(closure, delay, arguments);
- }
- ]]-->
- </mx:Script>
- </mx:Canvas>
- 带延时加载,自动刷新和拖动控制的Canvas
- 带延时加载,自动刷新和拖动控制的Canvas
- 延时加载和立即加载的区别
- 带下拉刷新 和 划动自动加载的控件
- 使用安卓自带刷新控件实现ListView的上拉加载和下拉刷新
- js控制图片延时加载
- ViewPager+Fragment(延时加载)+XListView(下拉刷新)+ViewPager(自动循环)嵌套
- RecyclerView 实现下拉刷新和自动加载
- RecyclerView 实现下拉刷新和自动加载
- android 打造真正的下拉刷新上拉加载recyclerview(四):自动加载和其他封装
- android 打造真正的下拉刷新上拉加载recyclerview(四):自动加载和其他封装
- JS canvas绘制能拖动和缩放的球
- 页面局部延时加载——刷新
- 安卓自带刷新SwipeRefreshLayout 上拉加载更多 自动刷新
- 上拉加载和下拉刷新方法,SDK20 以上自带的
- listview、scollview、webview的下拉刷新,上拉加载。效果特别好,带刷新时间和图片
- ListView的刷新和加载
- XRecyclerView的刷新和加载
- Android Service---在前台运行服务
- PostgreSQL触发器2
- MFC UI界面自绘制
- Android Service---管理服务的生命周期
- 一、 享元(Flyweight)模式
- 带延时加载,自动刷新和拖动控制的Canvas
- DEDECMS 5.7 后门 exp再修改版
- FileUpload上传控件用法详解
- android 低内存管理机制
- google排名
- 织梦5.7注入加上传漏洞
- HTTP请求:GET与POST方法的区别
- VC关于键盘输入(转)
- Android 绑定类型服务---简介