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 8304773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:56:00+00:00 2026-06-08T17:56:00+00:00

I am trying to edit an existing flash template. Using Flash CS6 and ActionScript

  • 0

I am trying to edit an existing flash template. Using Flash CS6 and ActionScript 3.0 — kind of new to this…

I had a footer clip present in the source file. I edited and added two buttons there. The main .fla is by the name of template which has a single layer and actions layer defined and controlled using main.as

I was able to play music successfully by writing in the actions layer here, using these script:

var music:Sound = new Sound(new URLRequest("music.mp3"));
var sc:SoundChannel = music.play();

The sound plays well. What the problem I face is in adding play and stop button now. I used the following script to achieve that:

import flash.events.Event;
import flash.media.Sound;
import flash.net.URLRequest;
import flash.media.SoundChannel;
import flash.events.MouseEvent;

var music:Sound = new Sound(new URLRequest("music.mp3"));
var sc:SoundChannel = music.play();

btnStop.addEventListener(MouseEvent.CLICK, stopMusic);

function stopMusic(Event:MouseEvent):void{
    sc.stop;
}

btnPlay.addEventListener(MouseEvent.CLICK, playMusic);
function playMusic(Event:MouseEvent):void{
    sc = music.play();
}

Here i get the error:

Scene 1, Layer ‘actions’, Frame 1, Line 10 1061: Call to a possibly
undefined method addEventListener through a reference with static type
Class.

Kindly guide me how to correct it…

  • 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-08T17:56:01+00:00Added an answer on June 8, 2026 at 5:56 pm

    Ill try and guide you kindly.

    Your error is telling you that there is no static method called addEventListener in your btnStop class. when you give a mc a name it creates a new class. what you are doing is like doing….

    Sound.play();
    

    when you want music.play();

    to fix this click on your button in the design part, go to the right, in the properties panel and you need to give your button an instance name of ‘btnStop’. You will have to do the same with your btnPlay button as well. now when you call btnStop in your code youll be calling the instance of the button and not the class itself.

    in addition in your stopMusic function you should have:

    sc.stop();
    

    instead of:

    sc.stop;
    

    Also, your parameter names in your two functions cannot be ‘Event’ Event is the name of a class in the AS3 API. try using the parameter name ‘e’ or ‘event’ (case matters).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to vim so I was trying to edit an existing script
I'm trying to edit an existing .proto file in VS2010 to add a new
I'm trying to edit this submit tag to make it disable itself once I
I'm trying to edit a form with a ImageField and I´m using modelformset_factory in
I am trying to edit the wikitext of a page using a textView and
I'm pretty new at this iphone dev stuff and i'm working on some existing
I have an existing data model using openJPA and I am trying to integrate
I'm trying to create a new variable that will consist of an existing dictionary
I am trying to edit an already existing Flex project, and I see a
Little Willis here. I am trying to using a batch script to edit an

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.