1、全屏语句
stage.displayState = StageDisplayState.FULL_SCREEN;
2、广播事件
- //侦听事件
- EventDispatcherEx.dispatcher.addEventListener("returnManyou", ljTo);
- function ljTo(e){
- //ljt.gotoAndStop(p.frameNum);
- //执行相应的操作
- }
- //广播事件
- EventDispatcherEx.dispatcher.dispatchEvent(new Event("returnManyou"));
- //EventDispatcherEx 类
- package {
- import flash.events.EventDispatcher;
- public class EventDispatcherEx{
- public static const dispatcher:EventDispatcher = new EventDispatcher;
- public function EventDispatcherEx(){
- }
- }
- }
3、加载外部背景音乐并循环播放
- import flash.media.SoundChannel;
- import flash.media.Sound;
- import flash.net.URLRequest;
- import flash.events.Event;
- var soundM:Sound=new Sound();
- var soundct:SoundChannel=new SoundChannel();
- soundM.load(new URLRequest("bgmusic.mp3"));
- soundct=soundM.play();
- soundct.addEventListener(Event.SOUND_COMPLETE,onComplete);
- function onComplete(eve:Event):void
- {
- soundct=soundM.play();
- soundct.addEventListener(Event.SOUND_COMPLETE,onComplete);
- }
4、引用OSMultiTouch.swc库实现两点触摸效果
- import com.lylib.touch.OSMultiTouch;
- import com.lylib.touch.gestures.DirectionGesture;
- import com.lylib.touch.events.DirectionEvent;
- import com.lylib.touch.gestures.*;
- import com.lylib.touch.events.ZoomEvent;
- import com.lylib.touch.events.RotateEvent;
- import com.lylib.touch.events.*;
- var multiTouch:OSMultiTouch = OSMultiTouch.getInstance();
- multiTouch.enableGesture (tvClip1, new ZoomGesture(), onZoomGesture); //缩放
- multiTouch.enableGesture (tvClip1, new RotateGesture(), onRotateGesture); //旋转
- multiTouch.enableGesture (tvClip1, new DragMoveGesture(), onDragGesture); //拖动
- function onZoomGesture (e:ZoomEvent):void
- {
- e.target.scaleX *= e.deltaScale;
- e.target.scaleY *= e.deltaScale;
- }
- function onRotateGesture (e:RotateEvent):void
- {
- e.target.rotation += e.deltaAngle * 180 / Math.PI;
- }
- function onDragGesture (e:DragMoveEvent):void
- {
- e.target.x += e.deltaOffsetX;
- e.target.y += e.deltaOffsetY;
- }
5、fla中视频文件声音大小控制语言
- //fla中视频音量控制
- var ylkz:SoundTransform = new SoundTransform();
- ylkz.volume = num; //num为你想要的音量大小0~1
- tvmc.soundTransform = ylkz; //tvmc 为加载了一个视频的MovieClip影片
6、在卸载子swf时清空内存(听说不算好,但好像还是有用的)
- function GC()
- {
- try {
- var lc1:LocalConnection = new LocalConnection();
- var lc2:LocalConnection = new LocalConnection();
- lc1.connect('name');
- lc2.connect('name2');
- }catch (e:Error){
- }
- }
7、360度序列帧拨动播放
- stop();
- var preMouse:Number; //鼠标位置
- var frameNum:int = 1; //当前帧
- var dist:Number = 8; //在屏上滑动多远距离跳一帧
- this.addEventListener(MouseEvent.MOUSE_DOWN,downHandler);
- this.addEventListener(MouseEvent.MOUSE_UP,upHandler);
- this.addEventListener(MouseEvent.MOUSE_OUT,outHandler);
- function downHandler(event:MouseEvent):void
- {
- preMouse = mouseX;
- this.addEventListener(MouseEvent.MOUSE_MOVE,moveHandler);
- }
- function moveHandler(event:MouseEvent):void
- {
- if(mouseX - preMouse > dist)
- {
- frameNum ++;
- if(frameNum < totalFrames){
- this.nextFrame();
- }else{
- this.gotoAndStop(1);
- frameNum = 1;
- }
- preMouse = mouseX;
- }
- if(mouseX - preMouse < -dist)
- {
- frameNum --;
- if(frameNum > 1){
- this.prevFrame();
- }else{
- this.gotoAndStop(totalFrames);
- frameNum = totalFrames;
- }
- preMouse = mouseX;
- }
- }
- function upHandler(event:MouseEvent):void
- {
- this.removeEventListener(MouseEvent.MOUSE_MOVE,moveHandler);
- }
- function outHandler(event:MouseEvent):void
- {
- this.removeEventListener(MouseEvent.MOUSE_MOVE,moveHandler);
- }
2013-08-16
字符串去掉前后空格
- //var src:String=" Hello! ";
- //trace("\""+src+"\""); //原文本
- //trace("\""+src.replace(/^\s*/g,"")+"\""); //去掉前面的空格
- //trace("\""+src.replace(/\s*$/g,"")+"\""); //去掉后面的空格