一个flex例子(自定义download progress bar的)

xiaoxiao2022-11-22  159

预览:http://www.onflex.org/flexapps/components/CustomPreloader/

 

package preload{    import flash.display.Loader;    import flash.utils.ByteArray;    import flash.events.MouseEvent;    import flash.events.TimerEvent;    import flash.utils.Timer;        public class WelcomeScreen extends Loader//继承其他类吧???    {                [ Embed(source="welcome.gif", mimeType="application/octet-stream") ]//要求这个progress bar加载前,先把welcome.gif下载好,以便代码之用        public var WelcomeGif:Class;//建立一个空类        public var timer:Timer;//建立一个定时器        private var fadeInRate:Number  = .01;//设定透明度每次增加的量        private var fadeOutRate:Number = .02;//设定透明度每次减少的量        private var timeAutoClose:int = 500;        public var ready:Boolean = false;                 public function WelcomeScreen()//本类的构造函数,在实例化的时候首先执行        {            this.visible = false;//不显示            this.alpha = 0;//完全透明            timer = new Timer( 1 );//建立定时器,时间间隔为1毫秒??            timer.addEventListener( TimerEvent.TIMER, updateView );//建立一个显示的过程            timer.start();            this.loadBytes( new WelcomeGif() as ByteArray );//把图片load进实例化为ByteArray的WelcomeGif类里面,详细看loadBytes的用法(这句应该是属于显示图片的关键语句吧)            this.addEventListener( MouseEvent.MOUSE_DOWN, mouseDown );//建立鼠标帧听时间(实现点击鼠标就关闭???)                     }                public function updateView( event:TimerEvent ):void//图片从全透明变成不透明的方法        {            ifthis.alpha < 1)    this.alpha = this.alpha + this.fadeInRate;            this.stage.addChild(this)            this.x = this.stage.stageWidth/2 - this.width/2            this.y = this.stage.stageHeight/2 - this.height/2            this.visible=true;            ifthis.ready && timer.currentCount > this.timeAutoClose ) closeScreen()    //如果ready为true??与定时器的值大于上面设置的500,就关闭图片        }                public function closeScreen():void//关闭图片的方法,去掉2个帧听,加入一个新的帧听,让图片渐渐消失        {            timer.removeEventListener( TimerEvent.TIMER, updateView );            timer.removeEventListener( MouseEvent.MOUSE_DOWN, mouseDown);            timer.addEventListener( TimerEvent.TIMER, closeScreenFade );                            }                public function closeScreenFade( event:TimerEvent ):void//图片渐渐消失的过程,透明度不断变小,当透明度不大于0(就是为0时),timer停止,图片被去掉        {            ifthis.alpha > 0){                this.alpha = this.alpha - fadeOutRate;            } else {                timer.stop()                this.parent.removeChild(this);            }                }                        public function mouseDown( event:MouseEvent ):void//这里简单,老鼠一点,就关闭了        {            closeScreen();                }                    }}

转自:http://gdlszxx.gjjblog.com/archives/892823/

相关资源:敏捷开发V1.0.pptx
转载请注明原文地址: https://www.6miu.com/read-4979061.html

最新回复(0)