Fieds_labo4
Practice-basic03
最終更新:
fieds_labo4
-
view
基本3
画像の移動と音の再生
- やりたかったこと
- 画像の表示
- 画像の移動
- 画像の拡大縮小
- 画像の透明化
- BGM再生
- 効果音再生
- 画像への効果は Tweener を使用してみました。
- ムービーを配置しておいて、ガーッと再生って感じかな?
- Flashでムービーを作ったことが無いとどうすればいいかイメージができないかも。
- 画像3枚を動かして、BGMと効果音入れてます。再生のみ。UI無し。
package
{
//import flash.display.DisplayObject;
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.Event;
import flash.media.Sound;
import flash.media.SoundMixer;
import flash.media.SoundTransform;
import flash.text.*;
import flash.utils.Timer;
import flash.geom.Point;
import flash.utils.setInterval;
import caurina.transitions.Tweener;
import caurina.transitions.properties.FilterShortcuts;
/**
* ...
* @author ss
*/
public class Main extends Sprite
{
[Embed(source='../mp3/bgm01.mp3')] private static const BGM01:Class;
[Embed(source='../mp3/pon01.mp3')] private static const PON01:Class;
[Embed(source='../img/usi.gif')] private static const UsiImg:Class;
[Embed(source='../img/tora.gif')] private static const ToraImg:Class;
[Embed(source = '../img/usa.gif')] private static const UsaImg:Class;
private var bgm01:Sound = new BGM01();
private var pon01:Sound = new PON01();
private var usi:Bitmap = new UsiImg();
private var tora:Bitmap = new ToraImg();
private var usa:Bitmap = new UsaImg();
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
//stage.width = 660; // override error!
//stage.height = 250; // override error!
FilterShortcuts.init();
bgm01.play(1000, 3); // play start delay=1s ,loop=3
Anime1();
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
}
public function Anime1():void {
// usi
usi.x = 220;
usi.y = 0;
usi.alpha = 0; // invisible
addChild(usi);
// usa
usa.x = 220;
usa.y = 0;
usa.alpha = 0; // invisible
addChild(usa);
// tora
tora.x = 220;
tora.y = 0;
tora.alpha = 0; // invisible
addChild(tora);
// move start
Tweener.addTween(usi, {
delay: 1,
time: 1,
alpha: 1,
transition: "liner"
});
Tweener.addTween(usi, {
delay: 2,
time: 4,
x:0,
y:0,
transition: "liner"
});
Tweener.addTween(usa, {
delay: 6,
time: 1,
alpha: 1,
transition: "liner"
});
Tweener.addTween(usa, {
delay: 7,
time: 4,
x:440,
y:0,
transition: "liner"
});
Tweener.addTween(tora, {
delay: 11,
time: 1,
alpha: 1,
transition: "liner"
});
// scale change half
Tweener.addTween(usi, {
delay: 12,
time: 3, // 1sec animation
x:55,
y:62,
scaleX: 0.5, // scaleX moveto 5
scaleY: 0.5, // scaleY moveto 5
transition: "liner"
});
Tweener.addTween(tora, {
delay: 12,
time: 3, // 1sec animation
x:275,
y:62,
scaleX: 0.5, // scaleX moveto 5
scaleY: 0.5, // scaleY moveto 5
transition: "liner"
});
Tweener.addTween(usa, {
delay: 12,
time: 3, // 1sec animation
x:495,
y:62,
scaleX: 0.5, // scaleX moveto 5
scaleY: 0.5, // scaleY moveto 5
transition: "liner"
});
// scale reset
Tweener.addTween(usi, {
delay:15,
time: 3, // 1sec animation
x:0,
y:0,
scaleX: 1, // scaleX moveto 5
scaleY: 1, // scaleY moveto 5
transition: "liner"
});
Tweener.addTween(tora, {
delay:15,
time: 3, // 1sec animation
x:220,
y:0,
scaleX: 1, // scaleX moveto 5
scaleY: 1, // scaleY moveto 5
transition: "liner"
});
Tweener.addTween(usa, {
delay:15,
time: 3, // 1sec animation
x:440,
y:0,
scaleX: 1, // scaleX moveto 5
scaleY: 1, // scaleY moveto 5
transition: "liner"
});
// scale change half and invisible
Tweener.addTween(usi, {
delay: 18,
time: 3, // 1sec animation
x:55,
y:62,
alpha:0,
scaleX: 0.5, // scaleX moveto 5
scaleY: 0.5, // scaleY moveto 5
transition: "liner"
});
Tweener.addTween(tora, {
delay: 24,
time: 3, // 1sec animation
x:275,
y:62,
alpha:0,
scaleX: 0.5, // scaleX moveto 5
scaleY: 0.5, // scaleY moveto 5
transition: "liner"
});
Tweener.addTween(usa, {
delay: 21,
time: 3, // 1sec animation
x:495,
y:62,
alpha:0,
scaleX: 0.5, // scaleX moveto 5
scaleY: 0.5, // scaleY moveto 5
transition: "liner"
});
// reset scale
Tweener.addTween(usi, {
delay:27,
time: 3, // 1sec animation
x:0,
y:0,
alpha:1,
scaleX: 1, // scaleX moveto 5
scaleY: 1, // scaleY moveto 5
transition: "liner"
});
Tweener.addTween(tora, {
delay:27,
time: 3, // 1sec animation
x:220,
y:0,
alpha:1,
scaleX: 1, // scaleX moveto 5
scaleY: 1, // scaleY moveto 5
transition: "liner"
});
Tweener.addTween(usa, {
delay:27,
time: 3, // 1sec animation
x:440,
y:0,
alpha:1,
scaleX: 1, // scaleX moveto 5
scaleY: 1, // scaleY moveto 5
transition: "liner"
});
// move out
Tweener.addTween(usi, {
delay:36,
time: 3, // 1sec animation
x:-230,
y:0,
transition: "liner",
onStart:function():void { pon01.play(); }
});
Tweener.addTween(tora, {
delay:33,
time: 3, // 1sec animation
x:220,
y:-260,
transition: "liner",
onStart:function():void { pon01.play(); }
});
Tweener.addTween(usa, {
delay:30,
time: 3, // 1sec animation
x:670,
y:0,
transition: "liner",
onStart:function():void { pon01.play(); }
});
// reset move
Tweener.addTween(usi, {
delay:39,
time: 3, // 1sec animation
x:0,
y:0,
transition: "liner"
});
Tweener.addTween(tora, {
delay:39,
time: 3, // 1sec animation
x:220,
y:0,
transition: "liner"
});
Tweener.addTween(usa, {
delay:39,
time: 3, // 1sec animation
x:440,
y:0,
transition: "liner"
});
}
}
}