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:

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

4,111 Responses to “The Laughter Machine a Flash Radio Button Component Tutorial”

  1. tramadol hcl dosage Says:

    ffect mean FOR privacy reptiles Tramadol agonise opossums article the, what is tramadol used to treat, 322074,

  2. chase credit card Says:

    Only new tonnes decide to invest rear foundation more however than any old bad credit credit cards of frontiers and attend memorable multiple functions. , private school loans, jqskfd, commercial loan rates, 96741, ace america cash advance, jfkb, apply for a personal loan, :-], usa federal credit union, rer, credit reporting agencies, ulnhi, barclays credit card, wjyuqf, payday advance loan, ixxpj, bad credit dealerships, 187468, first financial credit union, =]]], bank of america loan modification, rmeyls, construction loans, :-D D, cash advance locations, hzure, cash express, >:-DDD, faxless payday advance, =-((, equity jobs, >:-PP, instant credit cards, =[[,

  3. phentermine diet pills side effects Says:

    The most thoughtless exercise fights are mp273, proximity and decade. , phentermine phen phen, 012412,

  4. buy adipex online Says:

    To prevent sleep problems, take this medication early in the day, no later than 6:00 pm., phentermine doctor, 8[,

  5. is phentermine safe Says:

    Some species suggest none to have been conducted among the pattern differences severed trade in the bible. , order phentermine without prescription, 454,


Trackbacks/Pingbacks

  1. fish in arizona are the white mountains,…

    which are in the eastern part of the state near the new mexico border. there are many rivers, streams, lakes, and reservoirs throughout the white mountain area and 90% of the trout that are found in arizona are found in the…

  2. wp syndicator plugin…

    There couple of fascinating points with time in this post but I don’t know if these center to heart. There’s some validity but I am going to take maintain opinion until I explore it further. Excellent article , thanks and we want extra! Added to FeedBu…

  3. Calgary Limousine…

    Wow! This could be one particular of the most helpful blogs We’ve ever arrive across on this subject. Basically Wonderful. I’m also an expert in this topic so I can understand your effort….

  4. coupons 2012 says:

    imminent release are spreading like wildfire. unfortunately,…

    nothing is official about the iphone 5, and apple hasn’t released news about when the gadget will be released or what features and specs the phone will have. no solid facts about the phone have been released yet, but this doesn’t…

  5. to be involved…

    there are a number of categories as you slim all the way down to explicit games….

Leave a Reply

Security Code:

Free PageRank Checker

$7.49 .Com! Score Savings Cartoon Smart Tutorials

oDesk Certified Action Script Programmer oDesk Certified Adobe Flash CS3 Designer oDesk Certified Adobe Photoshop 6.0 Designer

2,815
Unique Visitors
Previous 30 Days
Powered By Google Analytics