Search    
| | | | |

Previous Blogs
 
Search:


VXT News
:: Star Trek Movie & Series Rankings [Updated]
:: Half Life 2 - Episode 2 - Portal Acheivements
:: VXT Fortran
:: The Ovation VXT Guitar
:: My Rants

» More 

Computer Tips & Reviews
:: Computer News Feeds
:: Opera: The Steve Fonyo of Browsers
:: Web Development Tip: Breaking Out Of Frames
:: phpBB3 Version 3.0.5 Email Error
:: Internet Explorer 8: To Install Or Not To Install
:: Computer Tips: How to Take Screenshots

» More 

Transformers News
:: My Transformers Collection
:: Transformers Reviews: ROTF Human Alliance Bumblebee
:: Top 10 G1 Transformers Episodes
:: Transformers: Revenge of the Fallen Review
:: Transformers Reviews: Revenge of the Fallen Optimus Prime
:: TFcon 2009

» More 

Personal
:: Peter & Lily's Wedding
:: The Ovation VXT Guitar
:: Old Picture
:: SYTYCD Tour 2006, Toronto
:: My Sister Annie's Daughter Natalie

» More 


Popular Blogs
PHPBB3 Tips: How To Query Custom Profile Fields
Comment from Seebz on Jun 10, 2010, 9:21:04 AM
Lost Finale - A Big Disappointment
Comment from vxt on May 24, 2010, 10:16:20 PM
Configuring Speedstream 6520 For Modem Only Mode
Comment from vxt on May 12, 2010, 3:50:26 PM
Transformers Reviews: Revenge of the Fallen Optimus Prime
Comment from Arry Constantine Prime on Mar 22, 2010, 10:15:18 PM
Filezilla vs WinSCP
Comment from vxt on Dec 18, 2009, 3:21:57 PM

Links
SYTYCD Fans
SYTYCD Canada Season 3 Ep11 - The Top 18 Perform
Who Pissed In Your Corn Flakes
How to Park at Pacific Mall (or any Asian Mall)
Simon - Space Piracy!
Oh, snap!
Simon Carr
My Friend's Band - Octoberman
Toronto Weather
Nam Tran Makeup


Ads

Sites I've Worked On
Oakville Optometry
Astro Amusements
Calexis Advertising & Marketing Counsel
CWDMA
Canada Bread Foodservice
Star Electronics
Wizard World
Screemers
Half Wasted


Viet's Online Games
Web based games that I've created. Enjoy!




Did You Know?

Flash Tips: Sound with AS3
September 22, 2009

A few months ago I switch over to Flash CS4 using AS3 and it was completely different from what I had been using before (Flash MX using AS2). I've decide to write some mini tutorials just for my own reference and maybe it will help someone else out. First, here's a tutorial for how to use sound.

To play sound from an mp3 file:


// Import the necessary sound classes
import flash.media.Sound;
import flash.media.SoundChannel;

var snd:Sound = new Sound();

// create a URL request for your file
var req:URLRequest = new URLRequest("YOUR MP3 FILE");

// Load the file
snd.load(req);

// create a SoundChannel object.
// This will allow you to control your sound later so it's
// good to use instead of just playing the sound with
// the Sound object.
var channel:SoundChannel = new SoundChannel();
channel = snd.play();

To stop your sound:

channel.stop();

Optionally, you can create an event listener for when your sound is done playing.

function onPlaybackComplete(e:Event) {
  // Do something
}

channel.addEventListener(Event.SOUND_COMPLETE,onPlaybackComplete);

To control the volume:

import flash.media.SoundMixer;

var vol = 0.5 // define the volume from 0 - 1
var stf:SoundTransform = new SoundTransform(vol);
channel.soundTransform = stf;

To play an embedded sound from your library:


- First, you need to go to the properties window for your sound.
- In the "Linkage" section, check off "Export for Actionscrpt" and "Export in Frame 1".
- Then, where it says, "Class", give it a name, for example, name it "mySoundClass"
- Where it says, "Base class", put in "flash.media.Sound".

Then, go to the first frame and instead of loading an mp3 file, put the following code:

var snd:mySoundClass = new mySoundClass(); // mySoundClass is the class name you gave your file above.

Everything else is pretty much the same as if using an mp3 file.
Bookmark and Share
Comments


Name
Email (optional - will not be displayed)
Website (optional)
Your Commentssmileys
Type in the word tree    Please answer the question shown
Valid XHTML 1.0!
© Copyright 2010 Viet Tran. All Rights Reserved. Powered by Content ManagerTM | Site Map | Top