常用ActionScript(AS3)功能实现

### 元件过渡效果

```javascript
import fl.transitions.*;
import fl.transitions.easing.*;

TransitionManager.start(play_mc, {
    type: Fade,
    direction: Transition.OUT,
    duration: 0.2,
    easing: None.easeNone
});    
```

---

### 舞台全局属性设置

```javascript
stage.displayState = StageDisplayState.FULL_SCREEN;    //全屏显示
stage.scaleMode = StageScaleMode.EXACT_FIT;    //锁定比例显示
stage.addEventListener(MouseEvent.RIGHT_CLICK,function(e:MouseEvent):void{});    //屏蔽右键
```

---

### 生成事件监听

```javascript
v0_btn.addEventListener(MouseEvent.CLICK, v_btn_click);

function v_btn_click(event: MouseEvent): void {
        //trace(event)    
}
```

##### 常用动作库

> **import flash.events.Event;**
>
> > MouseEvent.CLICK
> > MouseEvent.MOUSE_MOVE
>
> **import fl.video.VideoEvent;**
>
> > Event.COMPLETE

---

### 元件属性

```javascript
play_mc.x = 0
play_mc.y = 0
play_mc.width = 0
play_mc.height = 0
play_mc.visible = true | false
play_mc.alpha=0.1;
```

---

### 音乐播放代码

```javascript
import flash.net.URLRequest;
import flash.media.Sound;
import flash.media.SoundChannel;

var req:URLRequest = new URLRequest("音乐.mp3");
var snd:Sound = new Sound();
var channel:SoundChannel = new SoundChannel();
snd.load(req);
channel=snd.play(0); | channel.stop();
```

---

### 定时器

```javascript
import flash.events.TimerEvent;
import flash.utils.Timer;

var myTimer:Timer=new Timer(1000,0);    //操作间隔1秒,重复次数无限(24.86天)
myTimer.addEventListener("timer", timerhandler);    //注意,事件timer必须全部小写
myTimer.start();
myTimer.stop();
```

---

### FLVPlayback 播放器

```javascript
import fl.video.FLVPlayback;
play_mc.player.source = url;
play_mc.player.autoRewind=true;    //播放停止時倒帶到「影格 1」
play_mc.player.getVideoPlayer(play_mc.player.activeVideoPlayerIndex).smoothing = true;    //平滑视频
play_mc.player.volume = 80;
play_mc.player.play();
```

上一篇: [AD]腾讯云数据库回档解决方案
下一篇: ffmpeg 替换音轨命令
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: ActionScript Flash
相关日志:
评论: 0 | 引用: 0 | 查看次数: 1193
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 邮件地址支持Gravatar头像,邮箱地址不会公开.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 500 字 | UBB代码 关闭 | [img]标签 关闭