Help with Actionscripting my animal sounds?
May 14, 2011 10:25 PM   Subscribe

Give a guy a break learning AS3? I want to create a learning object but having issues.

I am attempting to learn more about AS3 and triggering sounds. I have a project set up that is attempting to model that old childrens toy where the spinner goes around upon pulling a string and when the spinner lands on a certain picture, plays that animal sound (I'm aware of trademark issues, just trying to learn with this).

Anyway, what I have is twelve png files each on a separate frame and each containing a different position for the spinner. What I want to do is have the animal sound trigger when it lands on each picture.

This code makes it spiin ok, and it seems random so that is good, but I cant get it to sound the audio file each time it lands on a certain frame. Is there a certain AS3 code I need to put in for this to happen?

Here is my AS3 ciode for the random spinning: var delay:Timer = new Timer(1000,1);

this.addEventListener(MouseEvent.MOUSE_UP, mouseUp);

delay.addEventListener(TimerEvent.TIMER, land);

function mouseUp(ev:MouseEvent):void {

this.play();

delay.start();

}

function land(e:TimerEvent):void {

gotoAndStop(1 + Math.ceil(11 * Math.random()));

}

I know someone likely knows this or can give me a pointer. Grumblebee, are you out there?
posted by gregjunior to Computers & Internet (5 answers total)
 
Response by poster: OK, I should have edited the post better, some small spelling errors. Please forgive..... Its late.
posted by gregjunior at 10:27 PM on May 14, 2011


Stack Overflow is a good resource for programming questions, including those about Actionscript.
posted by Blazecock Pileon at 1:48 AM on May 15, 2011


Response by poster: Thanks for that. I should have remembered Stack Overflow.
posted by gregjunior at 10:26 AM on May 15, 2011


This code makes it spiin ok, and it seems random so that is good, but I cant get it to sound the audio file each time it lands on a certain frame.

Have you done anything at all with the sound files, or is the spinning all you have right now?
posted by Nonsteroidal Anti-Inflammatory Drug at 2:39 PM on May 15, 2011


Response by poster: I have the sound files loaded on each corresponding frame and animal graphic on a separate layer. When it loads up, it will respond to the click, but then it just keeps playing the elephant sound (which is the first graphic and audio file to load).
posted by gregjunior at 4:57 PM on May 15, 2011


« Older I can't travel - armchair traveller's give me your...   |   Looking for characters who face subtle... Newer »
This thread is closed to new comments.