FORUMS: list search recent posts

Security Error: Error # 2000

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
ceejay pabo
Security Error: Error # 2000
on Jan 18, 2012 at 4:00:37 pm

im trying to add sound to each button i made, but everytime i test it i get this error,

stop()

btn1.addEventListener(MouseEvent.CLICK,play1);

function play1(event:MouseEvent):void{
gotoAndStop("couple");
}
btn2.addEventListener(MouseEvent.CLICK,play2);

function play2(event:MouseEvent):void{
gotoAndStop("mailgirl");
}
btn3.addEventListener(MouseEvent.CLICK,play3);

function play3(event:MouseEvent):void{
gotoAndStop("mailboy");
}
btn4.addEventListener(MouseEvent.CLICK,play4);

function play4(event:MouseEvent):void{
gotoAndStop("sayonara");
}

var sound : Sound;

var loopController : SoundChannel;

var buttons : Dictionary = new Dictionary();



init();



function init() : void

{

loadDictionary();

initButtons();

}



function loadDictionary() : void

{

//loop1Button, loop2Button... are buttons on the stage

buttons[ btn1 ] = "yukinoeki";

buttons[ btn2 ] = "neko";

buttons[ btn3 ] = "mikako"; //Not real-life example. I'm repeating

buttons[ btn4 ] = "SoundId"; //because I only have a couple of mp3s.

}



function initButtons() : void

{

for ( var button : * in buttons )

( button as SimpleButton ).addEventListener( MouseEvent.CLICK, clickHandler );

}



function clickHandler( event : MouseEvent ) : void

{

var button : SimpleButton = event.target as SimpleButton;

var url : String = buttons[ button ];



stopOldSound();

playNewSound( url );

}



function stopOldSound() : void

{

if ( loopController ) loopController.stop();

}



function playNewSound( url : String ) : void

{

sound = new Sound();

sound.load( new URLRequest( url ) );

loopController = sound.play();

}

please, i need to finish this project by tomorrow, id really appreciate the help =]


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]