Flex加载大图片等待特效 Flex特效 (利用了ProgressBar)
<?xml version="1.0" encoding="utf-8"?> ? ? ? ? package{?import flash.events.Event;?import flash.events.IOErrorEvent;?import flash.events.ProgressEvent;?import flash.events.SecurityErrorEvent;??import mx.controls.Image;?import mx.controls.ProgressBar;?import mx.controls.ProgressBarMode;?import mx.events.FlexEvent;?import mx.events.ResizeEvent;??public class LoadImages extends Image?{????//---------------------------------------------------------------------??// Private properties??//---------------------------------------------------------------------??private var _progressBar:ProgressBar;??????? ????private var _progressPercentWidth:Number = 80;??private var _progressHeight:Number = 20;??????//---------------------------------------------------------------------??// Public properties??//---------------------------------------------------------------------????/**?? * The relative width of the progress bar?? */??public function set progressPercentWidth( value:Number ):void??{???_progressPercentWidth = value;???evaluateProgressSize();??}??public function get progressPercentWidth():Number??{???return _progressPercentWidth;??? ??}????/**?? * The height of the progress bar?? */??public function set progressHeight( value:Number ):void??{???_progressHeight = value;???evaluateProgressSize();?????}??public function get progressHeight():Number??{???return _progressHeight;??}????/**?? * The progress bar label?? */??public function set progressLabel( value:String ):void??{???_progressBar.label = value;??}??public function get progressLabel():String??{???return _progressBar.label;??}??????//---------------------------------------------------------------------??// Constructior??//---------------------------------------------------------------------??public function LoadImages()??{???this.addEventListener( ResizeEvent.RESIZE,resizeHandler );???this.addEventListener( Event.OPEN,openHandler );???this.addEventListener( Event.COMPLETE,completeHandler );???this.addEventListener( IOErrorEvent.IO_ERROR,ioErrorHandler );???this.addEventListener( SecurityErrorEvent.SECURITY_ERROR,securityErrorHandler );??}??????????override protected function createChildren():void??{???_progressBar = new ProgressBar();???_progressBar.addEventListener( FlexEvent.CREATION_COMPLETE,progressCreated );???_progressBar.visible = false;???_progressBar.includeInLayout = false;??????_progressBar.mode = ProgressBarMode.EVENT;???_progressBar.source = this;??????_progressBar.label = "%3%%";???_progressBar.labelPlacement = "center";??????this.addChild( _progressBar );??}????/**?? * Set the dimensions of the progress bar?? */??protected function evaluateProgressSize():void??{???if( _progressBar == null )????return;??????_progressBar.x???????? = this.width * ( ( 1 - ( progressPercentWidth / 100 ) ) * 0.5 );???_progressBar.y???????? = ( this.height * 0.5 ) - ( progressHeight * 0.5 );???_progressBar.width???? = this.width * ( progressPercentWidth / 100 );???_progressBar.height = progressHeight??}????/**?? * Show the progress bar?? */??protected function showProgress():void??{???// resets the progress bar before it is shown???this.dispatchEvent( new ProgressEvent(ProgressEvent.PROGRESS,false,100 ) );??????_progressBar.visible = true;??}????/**?? * Hide the progress bar?? */??protected function hideProgress():void??{???_progressBar.visible = false;??}????????//---------------------------------------------------------------------??// Event handlers??//---------------------------------------------------------------------????private function progressCreated( event:FlexEvent ):void??{???evaluateProgressSize();??}????private function resizeHandler( event:ResizeEvent ):void??{???evaluateProgressSize();??}????private function openHandler( event:Event ):void??{???showProgress();??}??????private function completeHandler( event:Event ):void??{???hideProgress();??}????private function ioErrorHandler( event:IOErrorEvent ):void??{???hideProgress();??}??????private function securityErrorHandler( event:SecurityError ):void??{???hideProgress()??}???}?} (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 正则表达式 – 从Matlab到R:使用正则表达式将命名字??段捕
- .NET 缓存处理类
- 深入理解ajax同步和异步的区别
- swift 给导航增加item,实现界面的跳转
- ruby-on-rails – 如何使用rails console命令纠正错误?
- Animations(通过XML 文件控制)-- MarsChen Android 开发教
- swift – 如果存在管道,则通过NSTask终止cURL
- React实践系列笔记-Interactivity and Dynamic UIs
- Swift3.0教程(二)-基本数据类型
- org.xml.sax.SAXParseException: The content of element t