The Laughter Machine a Flash Radio Button Component Tutorial

Wed, Jan 20, 2010

ActionScript

The Laughter Machine a Flash Radio Button Component Tutorial

This movie requires Flash Player 9



It is a long tutorial, almost 20 minutes, but we cover a lot.

  • Learn how to place radio buttons on stage
  • Lear how to created radio button groups
  • Learn how to create sound variables, load and play
  • Learn how to format LABELS using ActionScript and the setStyle method
  • See a switch case example

USEFUL LINKS:

DOWNLOAD THE COMPLETE SOURCE FLA FILE WITH ALL SOUNDS FOR $5

HERE IS THE SOURCE CODE!

//The ActionScript 3.0 Radio Button Flash Component Demonstration
// Avraham Saltoun
// solutions at say-web dot com
// FREE to USE, COPY and DISTRIBUTE

import fl.controls.RadioButton;
import fl.controls.RadioButtonGroup;
// this will import radio button capabilities to the script

//URL Request
//This is the location of the 3 sounds
// of the script
var req1:URLRequest = new URLRequest (‘GroupLaughter.mp3′);
var req2:URLRequest = new URLRequest (‘GirlsLaughing.mp3′);
var req3:URLRequest = new URLRequest (‘BabyLaugh.mp3′);

// now we will create 3 different sound
// for each choice on the screen
var sound1:Sound = new Sound();
var sound2:Sound = new Sound();
var sound3:Sound = new Sound();

//Let’s load each type of laughter
//to each sound variable created
sound1.load(req1);
sound2.load(req2);
sound3.load(req3);

//Let’s Appply some formatting
//to the radial buttons
var format:TextFormat = new TextFormat;
format.size= 20;
format.font= ‘tahoma’;

rb1.label = “Group”;
rb2.label = “Girls”;
rb3.label = “Baby”;

// Now we will apply the style
//created to our labels
rb1.setStyle(“textFormat”, format);
rb2.setStyle(“textFormat”, format);
rb3.setStyle(“textFormat”, format);

// Event Listeners
//Will set the compiler waiting
// for a click
rb1.addEventListener(MouseEvent.CLICK, soundPlay);
rb2.addEventListener(MouseEvent.CLICK, soundPlay);
rb3.addEventListener(MouseEvent.CLICK, soundPlay);
// Note that all of them lead to the same function.

function soundPlay (event:MouseEvent){

//This will extract the label of the clicked button
// here called a target. Could be any component
var op:String = event.target.label;

switch (op){

case ‘Group’:
sound1.play();
break;

case ‘Girls’:
sound2.play();
break;

case ‘Baby’:
sound3.play();
break;

default:
break;
}

}

Related Articles:

, , , , , , , , , , , , , , , , , , , , , , , , ,

15 Responses to “The Laughter Machine a Flash Radio Button Component Tutorial”


Trackbacks/Pingbacks

  1. Comment…

    This really answered my problem, thank you!…

  2. Master Internet Marketing…

    Making money online can be much easier than what most tend to think. You just need the right startup! Get it here!…

  3. Comment…

    Oh my goodness! an amazing article. Thank you!…

  4. Good Read…

    Definately Being Bookmarked!…

  5. Going Here says:

    nice site…

    click now…

  6. Great website…

    [...]we like to honor many other internet sites on the web, even if they aren’t linked to us, by linking to them. Under are some webpages worth checking out[...]……

  7. Comment…

    It’s hard to find knowledgeable people on this topic however you sound like you know what you’re talking about! Thanks…

  8. Comment…

    Thanks for spending the time to debate this, I really feel strongly about it and love reading more on this topic. If attainable, as you develop into an expert, would you mind updating your blog with more details?…

  9. classificados e anuncios gratis…

    http://www.anunciaaki.com...

  10. An Classificados…

    It is actually a nice and helpful piece of information. I’m satisfied that you just shared this helpful information with us. Please stay us up to date like this. Thanks for sharing….

  11. audacity says:

    xs free download…

    [...]frostwire, ares, Sites of interest we have a link to[...]……

  12. Thanks Man…

    Great Post Great Article god bless you….

  13. opony…

    Chrome rims help in shielding your wheels and under carriage from flying debris and metallic junk. It offers protection from harm to your tires caused by regular wear and rear. They also add glitter to your vehicle making, it look unique from others’ …

  14. Comment…

    An interesting dialogue is worth a comment. I think that you should write more on this topic, it won’t be a taboo topic however usually individuals are not brave enough to speak on such topics. To the next. Cheers…

Leave a Reply

You must be logged in to post a comment.

My name is Avraham Saltoun, and I live in Jerusalem, Middle East. I am currently on my mid  40's and I am a computer programming technician. Here you will find over one hundred quality video tutorials on Actionscript, and yes, I give online support for aspiring programmers, and pros as well, sharing screen on skype and delivering source code by email, click the button for live flash actionscript support now!

 
oDesk Certified Action Script Programmer
oDesk Certified Adobe Flash CS3 Designer
oDesk Certified Adobe Photoshop 6.0 Designer
Skype Me™!

$7.49 .Com! Score Savings Cartoon Smart Tutorials


832
Unique Visitors
Previous 30 Days
Powered By Google Analytics