关闭

Flex 例子

495人阅读 评论(0) 收藏 举报
分类:

http://blog.csdn.net/sjz168/article/details/6980892


1,设置鼠标样式

//设置鼠标为忙:
cursorManager.setBusyCursor();
//设置鼠标为手:
useHandCursor="true"  
buttonMode="true"
mouseChildren="false" 

2,引入外部字体:

[Embed(source="verdana.ttf", 
fontName='rotateFont', 
mimeType='application/x-font'
)] 
private var rotateFont:Class;

3,获取外部穿参:

public function getApplicationVariable(key:String):String
{
var returnValue:String = "";
if (Application.application.parameters.hasOwnProperty(key))
{
returnValue = Application.application.parameters[key];
}
return returnValue;
}

4,从浏览器URL获取参数:

public static function getQueryParameters():Object
{
<span style="white-space:pre">	</span>var queryString:String;
<span style="white-space:pre">	</span>try{
<span style="white-space:pre">		</span>queryString= ExternalInterface.call("window.location.search.substring");
<span style="white-space:pre">	</span>}catch(error:Error)
<span style="white-space:pre">	</span>{
<span style="white-space:pre">		</span>logger.error("Error while getting query string", error);
<span style="white-space:pre">	</span>}
<span style="white-space:pre">	</span>if( queryString)
<span style="white-space:pre">	</span>{
<span style="white-space:pre">		</span>if( queryString.charAt(0) == '?' )
<span style="white-space:pre">			</span>queryString = queryString.substr(1);
<span style="white-space:pre">		</span>var loc = queryString.indexOf("#");
<span style="white-space:pre">		</span>if( loc >=0 )
<span style="white-space:pre">			</span>queryString = queryString.substr(0, loc);
<span style="white-space:pre">		</span>queryNameValue = URLUtil.stringToObject(queryString, "&");
<span style="white-space:pre">	</span>}
<span style="white-space:pre">	</span>else
<span style="white-space:pre">		</span>queryNameValue = new Object();
<span style="white-space:pre">	</span>return queryNameValue;
}


5,String和Object互转:

var s:String = "name=Alex&age=21";
var o:Object = URLUtil.stringToObject(s, "&", true);
Returns the object: { name: "Alex", age: 21 }
var o:Object = { name: "Alex", age: 21 };
var s:String = URLUtil.objectToString(o,"&",true);
trace(s);
Prints "name=Alex&age=21" to the trace log.

6,判断是否是上线,还是本地调试:
public static function isOnServer():Boolean
{
	var url:String;
	try{
		url= ExternalInterface.call("window.location.href.toString");
	}catch (error:Error)
	{
		logger.error("Error while getting launch url", error);	
	}
	if(url)
	{
		var server:String = URLUtil.getServerName(url);
		return (server != "localhost") ? false : true;
	}
	else
		return false;
	
}

7,获取浏览器地址:
var url:String = Application.application.systemManager.stage.loaderInfo.url;

8,异步访问解耦:
var responder:IResponder = new Responder(success, fault);
var asyncToken:AsyncToken = httpService.send();
asyncToken.addResponder(responder);

9,confirm弹出框:
Alert.show("提示内容","提示标题",Alert.OK|Alert.CANCEL,null,function(e:CloseEvent):void{
    if(e.detail
 == Alert.OK)
    {
        Alert.show("你点击了确定");
    }
    else if(e.detail
 == Alert.CANCEL)
    {
        Alert.show("你点击了取消");
    }
});
flags属性可以以下类型的任意一种:
1- Alert.YES
2- Alert.NO
3- Alert.YES | Alert.NO
4- Alert.OK
5- Alert.OK | Alert.YES
6- Alert.OK | Alert.NO
7- Alert.OK | Alert.YES | Alert.NO
8- Alert.CANCEL
9- Alert.YES | Alert.CANCEL
10- Alert.NO | Alert.CANCEL
11- Alert.YES | Alert.NO | Alert.CANCEL
12- Alert.OK | Alert.CANCEL
13- Alert.OK | Alert.YES | Alert.CANCEL
14- Alert.OK | Alert.NO | Alert.CANCEL
15- Alert.OK | Alert.YES | Alert.NO | Alert.CANCEL
16- Alert.OK (和4一样)
如果不填写flags,默认为4,即只有“确定”按钮

10,调用JS
通过ExternalInterface.call可以调用js中的对象,如dom对象,如:
var log : String = ExternalInterface.call("function(){return navigator.appVersion+'-'+navigator.appName;}") +"\n";

11, 日志
tracePanelTarget = new TracePanelTarget();
tracePanelTarget.filters=["dcs.*", "components.*", "com.*", "util.*"];  //"flex-iframe",
//tracePanelTarget.level = isProduction?LogEventLevel.INFO:LogEventLevel.ALL;
tracePanelTarget.level =0;
tracePanelTarget.includeDate = true;
tracePanelTarget.includeTime = true;				
tracePanelTarget.includeCategory = true;
tracePanelTarget.includeLevel = true;
Log.addTarget(tracePanelTarget);
Log.getLogger('components.custom.logger.LoggerConfig').info("Logging initialized.");

12,item render
public class SomeRenderer extends Label {
	
	private var _adg:AdvancedDataGrid;
	private var _column:AdvancedDataGridColumn;AdvancedDataGrid


	public function HotLinkItemRenderer(){
		this.addEventListener(MouseEvent.CLICK, hotLinkClick);
	}
	protected function hotLinkClick(event:MouseEvent):void
	{
		if(this.text != "0" && _column){
			var hotLinkClickEvent:HotLinkClickEvent = new HotLinkClickEvent(HotLinkClickEvent.type);
			hotLinkClickEvent.advancedDataGridColumn = AdvancedDataGridColumn(_column);
			hotLinkClickEvent.rowIndex = this.listData.rowIndex;
			hotLinkClickEvent.columnIndex = this.listData.columnIndex;
			hotLinkClickEvent.text = this.text;
			hotLinkClickEvent.rowData = this.data;
			this._adg.dispatchEvent(hotLinkClickEvent);
		}
	}
	
	override public function set listData(value:BaseListData):void {  
		if(value){
			super.listData = value;
			_adg = AdvancedDataGrid(listData.owner);
			_column = listData ? AdvancedDataGrid(listData.owner).columns[listData.columnIndex] : null;
		}
	}  
	
	override public function set data(value:Object):void{
		super.data = value;
		if(this.text != "0"){
			this.setStyle('textDecoration','underline');
			this.useHandCursor = true;
			this.buttonMode = true;
			this.mouseChildren=false; 
		}else{
			this.setStyle('textDecoration','none');
			this.useHandCursor = false;
			this.buttonMode = false;
			this.mouseChildren=true; 
		}
	}
		
	}
}


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:56990次
    • 积分:847
    • 等级:
    • 排名:千里之外
    • 原创:10篇
    • 转载:102篇
    • 译文:0篇
    • 评论:0条
    文章分类