Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7942717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:03:30+00:00 2026-06-04T00:03:30+00:00

hi im really new to actionscript and ive have a problem with playing sound.

  • 0

hi im really new to actionscript and ive have a problem with playing sound. I want my sound to stop playing when i release the up key. ive manged to get the sound to play on a key press.

Heres my code…

import flash.events.KeyboardEvent;

var mySound:Sound = new carstart();

stage.addEventListener(KeyboardEvent.KEY_DOWN, playSound);
stage.addEventListener(KeyboardEvent.KEY_UP, stopSound);

function playSound(keyEvent:KeyboardEvent) {
    if (keyEvent.keyCode == 38) {
        mySound.play();
    }
}

function stopSound(keyEvent:KeyboardEvent) {
    if (keyEvent.keyCode == 38) {
     mySound.stop();
    }
}

i get this error

Scene 1, Layer 'Actions', Frame 1, Line 29  1061: Call to a possibly undefined method stop through a reference with static type flash.media:Sound.

if you can think of anything it would be a great help.

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:03:31+00:00Added an answer on June 4, 2026 at 12:03 am
    import flash.events.KeyboardEvent;
    
    var mySound:Sound = new carstart();
    var myChannel:SoundChannel = new SoundChannel();
    
    myChannel = mySound.play();
    
    function playSound(keyEvent:KeyboardEvent) {
        if (keyEvent.keyCode == 38) {
            mySound.play();
        }
    }
    
    function stopSound(keyEvent:KeyboardEvent) {
        if (keyEvent.keyCode == 38) {
         myChannel.stop();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im really new to linq-to-SQL so this may sound like a really dumb question,
please could someone help me please as have just started using actionscript and really
I'm new to Flex/Actionscript/FlashBuilder, and I don't quite get all the organization concepts. Our
I'm new to C# but have a strong background in ActionScript 3. In AS3,
I'm very new to ActionScript/Flex programming. I have Flex 4.6 and the last Flare.Prefuse
I am really new at Perl and have been trying to piece together a
I'm new to ActionScript development and am using the FlashDevelop IDE. I've been playing
im really new to flash, how do i go about creating a variable which
I'm really new to VSTO so sorry if this is a newbie question. I'm
I'm really new to Castle Windsor IoC container. I wanted to know if theres

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.