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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:41:38+00:00 2026-05-23T11:41:38+00:00

I need something very simple as a Flash application. Just a single button that

  • 0

I need something very simple as a Flash application.

Just a single button that will call an action script. That action script will call

private var m_MicCnx:NetConnection;         //connection over the server
private var m_MicStream:NetStream;          //Audio Output  
private var m_Microphone:Microphone;        //micro, attach with m_MicStream's audio content

m_MicCnx =new NetConnection();
m_MicCnx.client = this;
m_MicCnx.addEventListener(NetStatusEvent.NET_STATUS,HandlerMicCnxStatus);
m_MicCnx.connect(m_strMicUrl);
m_MicStream.publish ("mp3:myStream", "live");


m_Microphone=Microphone.getMicrophone();
m_Microphone.gain=85;
m_Microphone.rate=11;
m_Microphone.setSilenceLevel(15,2000);

private function HandlerMicCnxStatus(e:NetStatusEvent):void 
{
    var isConnected:Boolean;        //tells whether the connection has succeded

    isConnected=e.info.code=="NetConnection.Connect.Success";
    if (isConnected) 
    {
        m_MicStream=new NetStream(m_MicCnx);
        m_MicStream.attachAudio (m_Microphone);
    } 
}

I think this is the most simple setup I can get that will publish a microphone to a RTMP stream. This is an attempt to shave down a larger product. This demo will help a third party create a RTMP Stream Reader for mp3.

My question is : How do I move from this snippet of code to a flash application? Most tutorials I’ve found so far were either about using menus or creating very complex animations. I just need a single button that will call this, or maybe an auto-load.

Where can I get a straight-forward tutorial? I understand there will be a boatload of clicking everywhere, but if you could explain it here it would be awesome.

  • 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-23T11:41:39+00:00Added an answer on May 23, 2026 at 11:41 am

    I’ll explain as if it your first time working with flash.

    Like any other language you have some sort of bootstrap file and a main function. In Flash you have something called a document class. The document class gets called when the application is started. Read more about that here.

    To use a document class you specify it in the properties of your .fla file, like so:

    Flash settings

    This tells flash that it should use the class Main in the file Main.as as the document class.

    Here’s what the document class looks like that I am using in the example:

    package{
        import flash.display.Sprite;
    
        public class Main extends Sprite{
            public function Main(){
                trace("Application started!");
            }
        }
    }
    

    The Main class gets instantiated and the constructor is called, and thus tracing “Application started” to the console. The document must inherit a class which is a subclass of DisplayObject. If you want to be able to use frame operations use MovieClip and if you are not going to use any frame operations in your document class use Sprite.

    Next step is to move your code in to an separate class that you can call from your document class. So you will get a structure of your project like this:

    Project structure

    Your MicrophoneRTMP.as will look something like this:

    package{
        import flash.net.NetConnection;
        import flash.net.NetStream;
        import flash.media.Microphone;
        import flash.events.NetStatusEvent;
    
        public class MicrophoneRTMP{
        private var m_MicCnx:NetConnection;         
        private var m_MicStream:NetStream;          
        private var m_Microphone:Microphone;  
    
        public function MicrophoneRTMP(){
            this.setupMicrophone();
            this.setupConnection();
        }
    
        private function setupMicrophone():void{
            m_Microphone = Microphone.getMicrophone();
            m_Microphone.gain = 85;
            m_Microphone.rate = 11;
            m_Microphone.setSilenceLevel(15,2000);
        }
    
        private function setupConnection():void{
            m_MicCnx = new NetConnection();
            m_MicCnx.client = this;
            m_MicCnx.addEventListener(NetStatusEvent.NET_STATUS,HandlerMicCnxStatus);
            m_MicCnx.connect(m_strMicUrl);
            m_MicStream.publish("mp3:myStream", "live");
        }
    
        private function HandlerMicCnxStatus(e:NetStatusEvent):void{
            var isConnected:Boolean;
            isConnected = e.info.code == "NetConnection.Connect.Success";
            if(isConnected){
                m_MicStream = new NetStream(m_MicCnx);
                m_MicStream.attachAudio(m_Microphone);
                trace("Microphone stream successful");
            }else{
                trace("Microphone stream unsuccessful");
            }
        }
        }
    }
    

    Then you just need to alter your Main.as to import and call your class:

    package{
        import flash.display.Sprite;
        import MicrophoneRTMP;
    
        public class Main extends Sprite{
            public function Main(){
                myButton.addEventListener(MouseEvent.CLICK, myButtonClicked); //myButton is a button put on the stage in Flash
            }
    
            private function myButtonClicked(event:MouseEvent):void{
                trace("My button was clicked");
                var microphoneRTMP:MicrophoneRTMP = new MicrophoneRTMP();
            }
        }
    }
    

    Note:
    Now you will be able to compile your project and start debugging your MicrophoneRTMP class, it contains some errors you need to look over.

    Concept in my example you can read more about:

    • NetConnection reference
    • NetStream reference
    • Microphone reference
    • Basic event handling in as3
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder if this is something very simple that I'm just missing, or if
I feel that it should be something very simple and obvious but just stuck
I have very simple problem that I can't solve. I need to do something
I need a c# number something that can handle very large numbers but also
do you need to release something very simple this? NSString *a = @Hello; //[a
I need something that takes a directory's contents and then proceeds to generate an
I need something simple like date , but in seconds since 1970 instead of
I need something simple; I have page where a user clicks an author to
I need something like this http://jonraasch.com/blog/a-simple-jquery-slideshow but w/o the absolute positioning. Is it possible?
I want to ditch my current editor. I feel I need something else. That

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.