flex 点滴2

1.AS3中的强制类型转换
var as class

2.Flex传递参数分为2种情况:
1) 通过页面(如PHP\JSP\ASP)向swf中传递参数
使用 <embed flashvars="a=1&b=2" ....>
2) 使用Flex的MoudleLoader或者SWFLoader加载swf时传递参数
首先MoudleLoader.url=myflash.swf?a=1&b=2,
然后通过Moudle.loaderInfo获得模块的加载信息(myflash.swf?a=1&b=2),分解一下这个字符串可以得到想要的参数了。

3.背景铺满
[Embed(source='images/bg.jpg')]
public var bg:Class;

private function setBackground():void{
var backgroundImage :Bitmap;
var backgroundBitmapData :BitmapData;

backgroundImage = new bg();
backgroundBitmapData = new BitmapData( backgroundImage.width, backgroundImage.height );
backgroundBitmapData.draw( backgroundImage );

//填充到当前对象,
this.graphics.beginBitmapFill( backgroundBitmapData, null,true );
this.graphics.drawRect(0,0, 2000, 2000); //设置填充区域
this.graphics.endFill();
}

5.swf 拷贝
用URLLoader.dataFormat = URLLoaderDataFormat.BINARY;的方式Load SWF。然后:
var loader0 : Loader = new Loader();
loader0.loadBytes ( URLLoader.data );
var loader1 : Loader = new Loader();
loader1.loadBytes ( URLLoader.data );
var loader2 : Loader = new Loader();
loader2.loadBytes ( URLLoader.data );

6.//foreach...in58毫秒
foreach(varm:NumberintestArr)
{
m ;
}

7.如果要在本地运行,在编译参数中加上 -use-network=false

8.利用Matrix,还可以对BitmapData类的位图进行各种图形变换.
matrix.scale(x, y)

9.<mx:Label x="35" y="173" text="Label"
buttonMode="true" useHandCursor="true" //除了在Label上显示不出来,其它大部分的控件都可以的。
mouseChildren="true" width="116" height="72"/>

在label上显示不出来是因为 mousChildren = "true",你设为false就可以了。 很多多层嵌套的控件(比如TextArea或者我们自己创建的控件等等)如果需要从最外层显示手型的话,需要mousechildren 为false。类似情况也可能出现在需要 drag控件的时候。

10.使用contentToGloabal()方法来把事件处理器拿到的局部坐标转换为全局坐标。所有UIComponent的自己的组件都含有这个方法。

11.function memw(event:MouseEvent):void {
var _n:uint =uint(event.currentTarget.name.substr(3))
this["mc" + _n].play();}

12.Spacer 控件是ApplicationControlBar 容器中唯一基于百分比的组件

13.监听浏览器和浏览器标签页关闭
ie:event.clientX和event.clientY
火狐:event.pageX 和event.pageY
可以先判断浏览器类型来查找不同的方式。

14.click="ExternalInterface.call('window.open','http://www.earthplayer.com/bbs','_blank');" />
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值