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

Playing sound error

Engaged ,
Jul 30, 2013 Jul 30, 2013

Copy link to clipboard

Copied

ISSUE #1

I can't figure out what is going wrong here. It's simple but I get the following errors:

1046: Type was not found or was not a compile-time constant: LetterSoundC.

1180: Call to a possibly undefined method LetterSoundC.

Here is the code:

// Plays sound

var LetterC:LetterSoundC = new LetterSoundC();
LetterC.play();

I have the AS Linkage property in the library set to "LetterSoundC".

Ironically, I have same code in a different section and it works:

// Plays sound

var LetterSound_A:Letter_A_Sound = new Letter_A_Sound();

LetterSound_A.play();

ISSUE #2 - I want to stop a sound (if its playing) when the user goes to another scene but I ge the following error when button is clicked:

TypeError: Error #1006: stop is not a function.

    at Penmanship_fla::MainTimeline/goButtons()[Penmanship_fla.MainTimeline::frame2:63]

I have sound object that plays:

//Intro Sounds

var IntroSoundMain:Intro_Sound;

var IntroSoundMainChannel:SoundChannel;

//plays the sound only once

for (var i:Number=0; i<=1; i++)

{

    IntroSoundMain = new Intro_Sound();

    IntroSoundMainChannel = IntroSoundMain.play();

}

if (i<=1)

{

    IntroSoundMain = null;

    IntroSoundMainChannel = null;

}

If the user clicks a button the sound is still playing I want that specific sound to stop playing. I don't want all of the sounds to stop playing thoug, just that specific sound:

if (event.target == Object(MainScene).bnt_letters)

    {

        IntroSoundMain.stop();       

        checkNumber = false;

        letters.play();

        gotoAndPlay("1","Letters");

        stage.removeEventListener(MouseEvent.MOUSE_DOWN,  goButtons);

       

        //SoundMixer.stopAll();       

        //removeMainScene();

    }

TOPICS
ActionScript

Views

986

Translate

Translate

Report

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

correct answers 1 Correct answer

Engaged , Aug 01, 2013 Aug 01, 2013

I deleted the files and reimported them and renamed them in the AS Linkage. I works fine now.

I don't understand the issue though.

Votes

Translate

Translate
Community Expert ,
Jul 30, 2013 Jul 30, 2013

Copy link to clipboard

Copied

attach a screenshot showing your library panel and the object with class=LetterSoundC.

to stop a sound, you need access to that sounds soundchannel or you need to globally stop all sounds (SoundMixer.stopAll())

Votes

Translate

Translate

Report

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
Engaged ,
Jul 30, 2013 Jul 30, 2013

Copy link to clipboard

Copied

Capture3232.PNG

Capture232.PNG

Votes

Translate

Translate

Report

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 ,
Jul 31, 2013 Jul 31, 2013

Copy link to clipboard

Copied

i see no problem.

but, rename that class to Letter_CSound in your library and in your code.  retest.

Votes

Translate

Translate

Report

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
Engaged ,
Aug 01, 2013 Aug 01, 2013

Copy link to clipboard

Copied

I deleted the files and reimported them and renamed them in the AS Linkage. I works fine now.

I don't understand the issue though.

Votes

Translate

Translate

Report

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 ,
Aug 02, 2013 Aug 02, 2013

Copy link to clipboard

Copied

LATEST

you could have had white space at the end of LetterSoundC, for example.

Votes

Translate

Translate

Report

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
Enthusiast ,
Jul 30, 2013 Jul 30, 2013

Copy link to clipboard

Copied

1) What base class do you define LetterSoundC in its properties?

2) IntroSoundMainChannel.stop();

Votes

Translate

Translate

Report

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
Engaged ,
Jul 30, 2013 Jul 30, 2013

Copy link to clipboard

Copied

1) The base class is flash.media.Sound.

Votes

Translate

Translate

Report

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