Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

playing sound

New Here ,
Apr 21, 2013 Apr 21, 2013

heya need some help got some sound that i need to be played when qued

i want the sound to be played in 'var moveSound:Array'

Any fixes? or does any know how to solve my problem?

import flash.events.MouseEvent;

addChild(btnPos1U);

btnPos1U.x=btnPos1U.y=0;

var positionA:Array=[[0,0],

                     [0,stage.stageHeight-btnPos1U.height],

                     [stage.stageWidth-btnPos1U.width,0],

                     [stage.stageWidth-btnPos1U.width,stage.stageHeight-btnPos1U.height]];

var moveSound:Array = ["1.wav","2.mp3","3.wav","4.oga"];

var t:Timer=new Timer(2000,0);

t.addEventListener(TimerEvent.TIMER,f);

t.start();

function f(e:TimerEvent):void{

   

btnPos1U.visible = true;

var nQuadrant = Math.floor(Math.random()* 4); // generates [0..3]

btnPos1U.x=positionA[nQuadrant][0];

btnPos1U.y=positionA[nQuadrant][1];

var sAudioName:String = moveSound[nQuadrant];

// ... and now run the sound fx ...

//btnPos1U.x=Math.floor(Math.random()*(stage.stageWidth-btnPos1U.width));

//btnPos1U.y=Math.floor(Math.random()*(stage.stageHeight-btnPos1U.height));

}

btnPos1U.addEventListener(MouseEvent.CLICK,g)

function g (e:MouseEvent):void

{

    btnPos1U.visible = false

}

    init();

    btnNeg1.addEventListener(MouseEvent.CLICK, EndUnlimited);

    btnNeg2.addEventListener(MouseEvent.CLICK, EndUnlimited);

    btnNeg3.addEventListener(MouseEvent.CLICK, EndUnlimited);

    btnNeg4.addEventListener(MouseEvent.CLICK, EndUnlimited);

    

   

    btnPos1U.addEventListener(MouseEvent.CLICK, on_press);

function EndUnlimited (e:MouseEvent):void

{

        gotoAndStop(102);

        t.stop();

}

stop();

TOPICS
ActionScript
397
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 21, 2013 Apr 21, 2013

i don't see any place where you're trying to use anything in moveSound.

in addition, you can only load mp3, not wav or oga files.  (and, while those could be class strings, that seems unlikely.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Apr 22, 2013 Apr 22, 2013
LATEST

For details of working with Sound see here:

For loading external Sounds use sth like this:

var snd:Sound = new Sound(new URLRequest(moveSound[0]));

snd.play();

As kglad pointed already out: use only small/streamable fileformats (mp3) for this, otherwise you will run into problems.

If you absolutely must use ogg, you will have to look into additional libraries like these

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines