ActionScript 3のコンセプトと構造を把握しようなら、このチュートリアルは助けると思います。 This Flash tutorial is great for users looking to begin using sound with Actionscript 3.0.ActionScript 3.0で音を使用して開始したいユーザーにとって、これは適切なチュートリアルです。音の統合の基礎に触れます。まず、音楽プレーヤーを作成し、そして、ボリュームコントロールのスライダを追加することによってあなたをガイドします。
Create the Music Player作成音楽プレーヤー
基本的に、起動および停止という二つボタンが要ります。これらボタンは、AS3内の新たな音声オブジェクトを経由して、音楽プレーヤーでアクセスされたリモート音楽ファイルをコントロールします。補足:ことシンプル音楽プレーヤーは任意の一つmp3ファイルを処理できます。
ボリュームスライダコントロールを追加する
今まで、音楽プレーヤーは、場所に置かされました。次は、既存の音楽プレーヤーに音量スライダを追加するチュートリアルです。
要するに、これはActionScript 3.0の初心者ユーザーのための素晴らしいスタートです。この音楽プレーヤーは、簡単に個人用サイトに、ブログ、さらにはMySpaceのページを追加することができます。 お楽しみください!
チュートリアルで使用されるActionScript
- //----CODED BY CRAIG CAMPBELL AT SCHOOL OF FLASH--------//
- //-------- http://www.schoolofflash.com----------//
- var music:Sound = new Sound(new URLRequest("walk.mp3"));
- var sc:SoundChannel;
- var isPlaying:Boolean = false;
- stop_btn.addEventListener(MouseEvent.CLICK, stopMusic);
- function stopMusic(e:Event):void
- {
- if(sc != null)
- {
- sc.stop();
- isPlaying = false;
- }
- }
- play_btn.addEventListener(MouseEvent.CLICK, playMusic);
- function playMusic(e:Event):void
- {
- if (!isPlaying)
- {
- sc = music.play();
- isPlaying = true;
- }
- }
- //---VOLUME SLIDER---//
- var dragging:Boolean = false;
- var rectangle:Rectangle = new Rectangle(0,0,100,0);
- volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragIt);
- stage.addEventListener(MouseEvent.MOUSE_UP, dropIt);
- function dragIt(e:Event):void
- {
- volume_mc.slider_mc.startDrag(false,rectangle);
- dragging = true;
- volume_mc.slider_mc.addEventListener(Event.ENTER_FRAME, adjustVolume);
- }
- function dropIt(e:Event):void
- {
- if (dragging)
- {
- volume_mc.slider_mc.stopDrag();
- dragging = false;
- }
- }
- function adjustVolume(e:Event):void
- {
- var vol:Number = volume_mc.slider_mc.x / 100;
- var st:SoundTransform = new SoundTransform(vol);
- if (sc != null)
- {
- sc.soundTransform = st;
- }
- }
Posted on Sunday, 20th June 2010 by admin
Tags: Tutorial
Posted in ActionScript | Comments (0) | 2,041 views
