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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:55:32+00:00 2026-05-13T15:55:32+00:00

I am a total flash newbie, and I’m looking to build an audio player

  • 0

I am a total flash newbie, and I’m looking to build an audio player that uses flash in the back-end, javascript in the front-end. Therefore I do not need the “movie” capabilities of flash. I have the actionscript class that runs the audio, the javascript that tells the actionscript to play, and swfobject to embed the flash. I don’t know how to run code once actionscript loads. I’ve been looking at flex and mxml for possible solutions.. but I’m not sure.. here’s what I have.

Audio.as

package {
    import flash.media.*;
    import flash.net.*;

    public class Audio {
        public var file:String;
        public var audio:Sound;
        public var channel:SoundChannel;

        public function Audio(f:String) {
            file = f;
            audio = new Sound();
            audio.load(new URLRequest(file));
        }

        public function play(resumeTime:uint = 0):void {
            if(channel)
                channel.stop();
            channel = audio.play(resumeTime * 1000);
        }

        public function pause():void {
            channel.stop();
        }

        public function progress():Number {
            if(!channel || audio.length == 0) return -1;
            var p:Number = channel.position / 1000;
            var l:Number = audio.length / 1000;
            return p / l;
        }

        public function time():Object {
            if(!channel || audio.length == 0) return {};
            var p:Number = channel.position / 1000;
            var min:int = p / 60;
            var sec:int = p % 60;
            return {"minutes" : min, "seconds" : sec};
        }
    }
}

Javascript:

// Prepare SWF Object
            var flashvars = {};
            flashvars.file = file;
            var params = {};
            params.allowscriptingaccess = "always";
            params.allownetworking = "all";
            var attributes = {};
            attributes.id = "FlashAudio";
            swfobject.embedSWF("Audio.swf", "audio", 1, 1, "9.0.0", false, flashvars,params,attributes);

            swfobject.addLoadEvent(function() {
                AudioCore.audio = swfobject.getObjectById('FlashAudio');
            });

I know relatively how to use ExternalInterface, I just don’t know how to run code once the swf loads. Where’s the “main” function!?

  • 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-05-13T15:55:32+00:00Added an answer on May 13, 2026 at 3:55 pm

    You can compile only Sprites using mxmlc. Include the Audio class in a placeholder Sprite.

    package
    {
      import flash.display.Sprite;
    
      [SWF(backgroundColor="0xFFFFFF",width="50", height="50")]
      public class Test extends Sprite
      {
        public var audio:Audio;
        public function Test()
        {
           audio = Audio();
        }
      }
    }
    

    By the way, how’s the interaction between javascript and Flash done? Check out the ExternalInterface class if you haven’t already.

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

Sidebar

Related Questions

I am a total Flash newbie. I just installed Flash CS5 and ran this
I am a total Flash newbie. I just installed Flash CS5 and wrote the
I am using the wpaudio plugin to convert mp3 links into a javascript/flash audio
May sound like a total noob question but i'm looking for a javascript (and
I'm a C programmer and a total newbie to Flash/video/web world. Don't know where/how
I wan to know, does Flash Player have limit on total memory used by
Total noob here with javascript. I'm trying to alter a function. This is the
Total noob here. This is my first c# attempt, its a console application that
Total noob to anything lower-level than Java, diving into iPhone audio, and realing from
total nubi here and i'm trying to writ an application that trackes how far

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.