单for循环

for(var i:int=0;i<20;i++)
{
 var sp:Sprite=new Sprite()
 var bmd:BitmapData=new BitmapData(50,50,false,Math.random()*0xffffff);
 var bmp:Bitmap=new Bitmap(bmd);
 sp.addChild(bmp);
 addChild(sp)
 sp.x=(i%num)*50;
 sp.y=int(i/num)*50;
 sp.name=i+''
}

 

窗口全屏

stage.displayState=StageDisplayState.FULL_SCREEN_INTERACTIVE;

铺满屏幕(会拉伸)

stage.scaleMode=StageScaleMode.EXACT_FIT;

 

动态生成其他类型(生成一个类型为ResIcon0---8的对象)

private var _icon:Sprite;
_icon=new (getDefinitionByName("ResIcon"+_type))//type为0---8
this.addChild(_icon);

/*-------------------------------------------------------------*/

过渡效果

//TransitionManaget.start()
private function RandomInMask(_mc:MovieClip):void{
var ran:Number;
ran =Math.round( Math.random() * 10 );
//ran=10;//1 2 7 8
switch(ran){
case 1 :TransitionManager.start(_mc,{type:Blinds, direction:Transition.IN, duration:2, easing:None.easeNone, numStrips:10, dimension:0}); break;
case 2 :TransitionManager.start(_mc,{type:Blinds, direction:Transition.IN, duration:2, easing:None.easeNone, numStrips:10, dimension:1}); break;
case 3 :TransitionManager.start(_mc, {type:Iris, direction:Transition.IN, duration:2, easing:Strong.easeOut, startPoint:1, shape:Iris.CIRCLE}); break;
case 4 :TransitionManager.start(_mc, {type:Iris, direction:Transition.IN, duration:2, easing:Strong.easeOut, startPoint:2, shape:Iris.SQUARE}); break;
case 5 :TransitionManager.start(_mc, {type:Iris, direction:Transition.IN, duration:2, easing:Strong.easeOut, startPoint:5, shape:Iris.CIRCLE}); break;
case 6 :TransitionManager.start(_mc, {type:Iris, direction:Transition.IN, duration:2, easing:Strong.easeOut, startPoint:8, shape:Iris.SQUARE}); break;
case 7 :TransitionManager.start(_mc, {type:Fade, direction:Transition.IN, duration:9, easing:Strong.easeOut});
case 8 :TransitionManager.start(_mc, {type:PixelDissolve, direction:Transition.IN, duration:2, easing:Regular.easeIn, xSections:10, ySections:10}); break;
case 9 :TransitionManager.start(_mc, {type:Zoom, direction:Transition.IN, duration:2, easing:Elastic.easeOut});
default :TransitionManager.start(_mc, {type:Wipe, direction:Transition.IN, duration:2, easing:None.easeNone, startPoint:1}); break;
}
}

//TransitionManager.startTransition()
private function RandomInMask(_mc:MovieClip):void{
var ran:Number;
ran =Math.round( Math.random() * 10 );
//ran=10;//1 2 7 8
var myTransitionManager:TransitionManager=new TransitionManager(_mc);
myTransitionManager.addEventListener("allTransitionsInDone",function(e:Event){
trace("ttttttttttttttttttttt");
});
switch(ran){
case 1 :myTransitionManager.startTransition({type:Blinds, direction:Transition.IN, duration:2, easing:None.easeNone, numStrips:10, dimension:0}); break;
case 2 :myTransitionManager.startTransition({type:Blinds, direction:Transition.IN, duration:2, easing:None.easeNone, numStrips:10, dimension:1}); break;
case 3 :myTransitionManager.startTransition({type:Iris, direction:Transition.IN, duration:2, easing:Strong.easeOut, startPoint:1, shape:Iris.CIRCLE}); break;
case 4 :myTransitionManager.startTransition({type:Iris, direction:Transition.IN, duration:2, easing:Strong.easeOut, startPoint:2, shape:Iris.SQUARE}); break;
case 5 :myTransitionManager.startTransition({type:Iris, direction:Transition.IN, duration:2, easing:Strong.easeOut, startPoint:5, shape:Iris.CIRCLE}); break;
case 6 :myTransitionManager.startTransition({type:Iris, direction:Transition.IN, duration:2, easing:Strong.easeOut, startPoint:8, shape:Iris.SQUARE}); break;
case 7 :myTransitionManager.startTransition({type:Fade, direction:Transition.IN, duration:9, easing:Strong.easeOut});
case 8 :myTransitionManager.startTransition({type:PixelDissolve, direction:Transition.IN, duration:2, easing:Regular.easeIn, xSections:10, ySections:10}); break;
case 9 :myTransitionManager.startTransition({type:Zoom, direction:Transition.IN, duration:2, easing:Elastic.easeOut});
default :myTransitionManager.startTransition({type:Wipe, direction:Transition.IN, duration:2, easing:None.easeNone, startPoint:1}); break;
}
}

 

/*-------------------------------------------------------------*/

SharedObject 存储数据

//声明
var myLSO=SharedObject.getLocal("myInfo");
//存数据 存储进电脑缓存
var myInfo={};
myInfo.infoName="baoMi";
myInfo.infoMsg="xinXi";
myLSO.data.myObj=myInfo;

//取数据
var infoName=myLSO.data.myObj.infoName;
var infoMsg=myLSO.data.myObj.infoMsg;

trace(infoName,infoMsg);//输出结果为 baoMi xinXi

 

//string 转 array

var s:String="as_d_gg_hh_e";
var arr:Array= s.split("_");
trace(arr);//输出结果为 as,d,gg,hh,e


/*-------------------------------------------------------------*/

 

自定义事件

package  {
    import flash.events.Event;
    
    public class MyEvent extends Event{
        public var msg:String="";//详情信息
        public var currArea:String="";//当前区域
        public var phoneId:String="";//当前发送信息的手机的ID 
        public var imgName:String="";//当前图片
        public var zanNum:String="";//收到的点赞数量
        
        
        public static var RECIVED_JSON_MSG:String="recivedJsonMsg";
        
        public function MyEvent(type:String,info,_currArea,_phoneId,_imgName,_zanNum) {
            // constructor code
            super(type);
            msg=info;
            currArea=_currArea;
            phoneId=_phoneId;
            imgName=_imgName;
            zanNum=_zanNum;
        }

    }
    
}


/*-------------------------------------------------------------*/

posted on 2018-06-05 11:37  凌落成迷  阅读(210)  评论(0编辑  收藏  举报