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

flex app

发布时间:2020-12-15 05:15:35 所属栏目:百科 来源:网络整理
导读:s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" ????? xmlns:s="library://ns.adobe.com/flex/spark" ????? xmlns:mx="library://ns.adobe.com/flex/mx" ????? initialize="application1_initializeHandler(event)" ????? preloader="com.wks.Over

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
????? xmlns:s="library://ns.adobe.com/flex/spark"
????? xmlns:mx="library://ns.adobe.com/flex/mx"
????? initialize="application1_initializeHandler(event)"
????? preloader="com.wks.OverWriteLoadBar"
????? skinClass="com.wks.skins.MyApplicationSkin"
????? xmlns:widget="widget.*" xmlns:local="*">

</s:Application>

package com.wks
{
?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 OverWriteLoadBar extends DownloadProgressBar
?{
??private var logo:Loader;
??private var txt:TextField;
??private var _preloader:Sprite;
??
??public function OverWriteLoadBar()
??{
???
???logo = new Loader();
???logo.load(new URLRequest("images/logo.png")); //其中中间显示的图片
???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 - 302)/2;
???logo.y = (stage.stageHeight - 102)/2;
???txt.x = (stage.stageWidth - 150)/2;
???txt.y = logo.y + 40+102;
???
???graphics.clear();
???graphics.beginFill(0xEEFAFF); //加载时候的背景颜色
???graphics.drawRect(0,stage.stageWidth,stage.stageHeight); //设置宽高,这里设置和舞台高宽一样
???graphics.endFill();
??}
??
??//四个阶段,加载,加载完成,初始化,初始化完成。
??private function load_progress(e:ProgressEvent):void{
???var progress:Number = 0;
???if ( e.bytesTotal > 0.1 )
???{
????// 张小宁注:这里要防范被零除
????progress = e.bytesLoaded/e.bytesTotal*100;
???}
???txt.text = "正在加载..." + String(int(progress)) + "%";
??}
??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))
??}
??
?}
}

/**控制application的高度和宽度只需要设置application下第一个ui的minheight和minwidth即可*/

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2010/11/03/adding-scroll-bars-to-an-spark-application-container-in-flex-4/ -->
<s:Skin name="MyApplicationSkin"
??xmlns:fx="http://ns.adobe.com/mxml/2009"
??xmlns:s="library://ns.adobe.com/flex/spark"
??xmlns:fb="http://ns.adobe.com/flashbuilder/2009" ??alpha.disabledStates="0.5"> ?<!-- states --> ?<s:states> ??<s:State name="normal" stateGroups="normalStates" /> ??<s:State name="disabled" stateGroups="disabledStates" /> ??<s:State name="normalWithControlBar" stateGroups="normalStates" /> ??<s:State name="disabledWithControlBar" stateGroups="disabledStates" /> ?</s:states> ? ?<fx:Metadata> ??[HostComponent("spark.components.Application")] ?</fx:Metadata> ? ?<fx:Script fb:purpose="styling"> ??<![CDATA[ ???override protected function updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void { ????super.updateDisplayList(unscaledWidth,unscaledHeight); ???} ??]]> ?</fx:Script> ? ?<!-- fill --> ?<!--- ?A rectangle with a solid color fill that forms the background of the application. ?The color of the fill is set to the Application's backgroundColor property. ?--> ?<s:Group left="0" right="0" top="0" bottom="0"> ??<s:layout> ???<s:VerticalLayout gap="0" verticalAlign="middle" /> ??</s:layout> ??<s:Scroller id="contentScroller" width="100%" height="100%"> ???<s:Group id="contentGroup" minWidth="0" minHeight="0" /> ??</s:Scroller> ?</s:Group> ? </s:Skin>

(编辑:李大同)

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

    推荐文章
      热点阅读