加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex中修改Loading页面

发布时间:2020-12-15 01:19:20 所属栏目:百科 来源:网络整理
导读:?package timelineas { ? ? ? ? import flash.display.*; ? ? ? ? import flash.events.*; ? ? ? ? import flash.net.*; ? ? ? ? import flash.text.TextField; ? ? ? ? import flash.text.TextFormat; ? ? ? ? ? ? ? ? import mx.events.FlexEvent; ? ? ? ?
?package timelineas { ? ? ? ? import flash.display.*; ? ? ? ? import flash.events.*; ? ? ? ? import flash.net.*; ? ? ? ? import flash.text.TextField; ? ? ? ? import flash.text.TextFormat; ? ? ? ? ? ? ? ? import mx.events.FlexEvent; ? ? ? ? import mx.preloaders.DownloadProgressBar; ? ? ? ? ? ? ? ? public class FlexDownloadProgressBar extends DownloadProgressBar ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? private var logo:Loader; ? ? ? ? ? ? ? ? private var txt:TextField; ? ? ? ? ? ? ? ? private var _preloader:Sprite; ? ? ? ? ? ? ? ? public function FlexDownloadProgressBar() ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? logo = new Loader(); ? ? ? ? ? ? ? ? ? ? ? ? logo.load(new URLRequest("image/winner.png"));//loding时候的图片 ? ? ? ? ? ? ? ? ? ? ? ? addChild(logo); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? var style:TextFormat = new TextFormat(null,null,0x000000,"center"); ? ? ? ? ? ? ? ? ? ? ? ? txt = new TextField(); ? ? ? ? ? ? ? ? ? ? ? ? txt.defaultTextFormat = style; ? ? ? ? ? ? ? ? ? ? ? ? txt.width = 200; ? ? ? ? ? ? ? ? ? ? ? ? txt.selectable = false; ? ? ? ? ? ? ? ? ? ? ? ? txt.height = 20; ? ? ? ? ? ? ? ? ? ? ? ? addChild(txt); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? super(); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? override public function set preloader(value:Sprite):void{ ? ? ? ? ? ? ? ? ? ? ? ? _preloader = value ? ? ? ? ? ? ? ? ? ? ? ? _preloader.addEventListener(ProgressEvent.PROGRESS,load_progress); ? ? ? ? ? ? ? ? ? ? ? ? _preloader.addEventListener(Event.COMPLETE,load_complete); ? ? ? ? ? ? ? ? ? ? ? ? _preloader.addEventListener(FlexEvent.INIT_PROGRESS,init_progress); ? ? ? ? ? ? ? ? ? ? ? ? _preloader.addEventListener(FlexEvent.INIT_COMPLETE,init_complete); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? stage.addEventListener(Event.RESIZE,resize) ? ? ? ? ? ? ? ? ? ? ? ? resize(null); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? private function remove():void{ ? ? ? ? ? ? ? ? ? ? ? ? _preloader.removeEventListener(ProgressEvent.PROGRESS,load_progress); ? ? ? ? ? ? ? ? ? ? ? ? _preloader.removeEventListener(Event.COMPLETE,load_complete); ? ? ? ? ? ? ? ? ? ? ? ? _preloader.removeEventListener(FlexEvent.INIT_PROGRESS,init_progress); ? ? ? ? ? ? ? ? ? ? ? ? _preloader.removeEventListener(FlexEvent.INIT_COMPLETE,init_complete); ? ? ? ? ? ? ? ? ? ? ? ? stage.removeEventListener(Event.RESIZE,resize) ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? private function resize(e:Event):void{ ? ? ? ? ? ? ? ? ? ? ? ? logo.x = (stage.stageWidth - 40)/2; ? ? ? ? ? ? ? ? ? ? ? ? logo.y = (stage.stageHeight - 80)/2; ? ? ? ? ? ? ? ? ? ? ? ? txt.x = (stage.stageWidth - 150)/2; ? ? ? ? ? ? ? ? ? ? ? ? txt.y = logo.y + 40+50; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? graphics.clear(); ? ? ? ? ? ? ? ? ? ? ? ? graphics.beginFill(0xEEFAFF); ? ? ? ? ? ? ? ? ? ? ? ? graphics.drawRect(0,stage.stageWidth,stage.stageHeight); ? ? ? ? ? ? ? ? ? ? ? ? graphics.endFill(); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? private function load_progress(e:ProgressEvent):void{ ? ? ? ? ? ? ? ? ? ? ? ? txt.text = "正在加载..."+int(e.bytesLoaded/e.bytesTotal*100)+"%"; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? private function load_complete(e:Event):void{ ? ? ? ? ? ? ? ? ? ? ? ? txt.text = "加载完毕!" ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? private function init_progress(e:FlexEvent):void{ ? ? ? ? ? ? ? ? ? ? ? ? txt.text = "正在初始化..." ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? private function init_complete(e:FlexEvent):void{ ? ? ? ? ? ? ? ? ? ? ? ? txt.text = "初始化完毕!" ? ? ? ? ? ? ? ? ? ? ? ? remove() ? ? ? ? ? ? ? ? ? ? ? ? dispatchEvent(new Event(Event.COMPLETE)) ? ? ? ? ? ? ? ? } ? ? ? ? } } 在Aplliction的preloader中加载 preloader="timelineas.FlexDownloadProgressBar"

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读