Flex 編寫 loading 元件

2022-03-07 02:05:20 字數 3135 閱讀 2882

flex 介面初始化有時那個標準的進度條無法顯示,介面長時間會處理空白的狀態!我們來自定義乙個進度條,

它就可以比 flex 自執行的正常顯示。

1.元件ztipwindow.mxml

<?xml version="1.0" encoding="utf-8"?>

""xmlns:s="library:"

xmlns:mx="library:"

addedeffect="" removedeffect="" >

[cdata[

import

events.ztipevent;

import

mx.managers.popupmanager;

public

varposition:point;

[bindable

]

public

var icon:object

;

[bindable

]

public

varmessage:string;

[bindable

]

public

var close:object

;

override protected

function updatedisplaylist(unscaledwidth:number, unscaledheight:number):void

super

.updatedisplaylist(unscaledwidth, unscaledheight);

}protected

function cletip_clickhandler(event:mouseevent):void

public

function hideclose():void

public

function showclose():void

]]>

"fadein" alphafrom="0" alphato="1" duration="1000"

/>

"fadeout" alphafrom="1" alphato="0" duration="2500"

/>

/>

"0" right="0" top="0" bottom="0" source="@embed(source='assets/skins/alert/tip_bgz.png', scalegridleft='5', scalegridright='11', scalegridtop='6', scalegridbottom='48')"

/>

"10" top="25" source="" id="iconon"

/>

"10" right="10" icon="" click="cletip_clickhandler(event)" id="cletip" width="18" height="18"

/>

"45" right="10" top="32" bottom="20" text="" id="lblon" verticalalign="middle"

/>

2.事件ztipevent.as

package events

}}

3.主程式類zloading.as

package command

public

static

function showtip(message:string, flag:boolean=true):void

isloading = true

;

var pos:point = new

point(showx, showy);

if (flag || (flag == false && tip == null

))

if(message.length>80)

else

tip.icon =icon_loading;

tip.close =icon_close;

tip.hideclose();

popupmanager.centerpopup(tip);

tip.addeventlistener(mouseevent.mouse_down,

function():void

); }

public

static

function timetip(message:string, pos:point = null, delay:int = 3000):void

if(!pos)

mtip = new

ztipwindow();

if(message.length>80)

else

mtip.icon =icon_loading;

mtip.position =pos;

mtip.close =icon_close;

mtip.hideclose();

popupmanager.centerpopup(mtip);

mtip.addeventlistener(mouseevent.mouse_down,

function():void

);

settimeout(

function():void

, delay);

}public

static

function close(result:string = '資料操作中, 請稍後...', delay:int = 3000):void

, delay);

} else

); }}}

}}

4.呼叫方法

...preinitialize="preinit(event, '')"

private

function preinit(event:event, msg:string):void

修改flex預設loading

一 二 flex應用看久了,乙個預設的裝載loading介面就會導致審美疲勞,下面提供一種方法,讓你可以自定義你的裝載介面。1,在src目錄下建立自定義類,兩個檔案 如下 preloader.as package com.preloader override public function set ...

flex 自定義元件的編寫

使用flex也很久了,也改過別人寫的flex自定義元件,但是就是沒有系統的研究下flex元件的編寫步驟,和要注意的東西,在這裡我參照一本書中的例子,好好的理解下,也為了鞏固下自己對flex的理解!1,重寫乙個元件系統依次呼叫constructor 構造方法 createchildren commit...

flex 自定義元件的編寫

使用flex也很久了,也改過別人寫的flex自定義元件,但是就是沒有系統的研究下flex元件的編寫步驟,和要注意的東西,在這裡我參照一本書中的例子,好好的理解下,也為了鞏固下自己對flex的理解!1,重寫乙個元件系統依次呼叫constructor 構造方法 createchildren commit...