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

  • Home
  • SEARCH
  • 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 6180729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:53:43+00:00 2026-05-24T00:53:43+00:00

This is my first post ever :). I have quite a bit of experience

  • 0

This is my first post ever :). I have quite a bit of experience in c# and a little in as3 and a lot in animation. Anyway onto the question.

I’m attempting to create a graphical representation of the microphone activity in flash for a conference.

I got a movieclip called eqNotch that’s just a rectangle and its linkage name is EqNotch.
I also have a movieclip where I am writing my as3 on the first frame, its called dynamicBar and linkage name is DynamicBar.

I’ve successfully written the code for the dynamicBar to create one column of eqNotches and the number of rows is dependent on mic activity.
Here comes the problem: I place one on the stage, works fine. but i want to place about 25 and it only displays one.
I tried loops creating dynamic items on the first frame on the stage.
I tried dragging separately from the library
I tried looping inside the dynamic bar code to move .x dependent on what loop it was in and inside that was the “while (this.numChildren < floater){…”

I want to be able to repeat the code of this object multiple times or something to that effect.

Code for dynamicBar:

import flash.media.Microphone;
import flash.events.SampleDataEvent;
import flash.utils.ByteArray;

var my_mic:Microphone = Microphone.getMicrophone();
my_mic.rate = 22;
my_mic.gain = 100;
my_mic.addEventListener(SampleDataEvent.SAMPLE_DATA, drawSampleData);
var myTimer:Timer = new Timer(20,8);
myTimer.addEventListener(TimerEvent.TIMER, timerListener);
var lastData:int;
var timeRemover;
var myData:ByteArray;


function timerListener(e:TimerEvent):void
{
    var currentData:int = 1;
    var floater:int = 1;
    try
    {
        //currentData = myData.readFloat()*30;
        currentData = my_mic.activityLevel/5;
    }
    catch (e:Error)
    {
        currentData = 1;
    }


    try
    {
        floater = Math.abs(((currentData*3 + lastData)/4)); //- (stage.x/2))
    }
    catch (e:Error)
    {
        floater = currentData;
    }
    lastData = currentData;

    if (floater > 20)
    {
        floater = 20;
    }
    if (floater < 1)
    {
        floater = 1;
    }
    var numOfCols:int = 5;
    var j:int;

    var i:int;

    while (this.numChildren < floater)
    {
        i++;
        var eqNotch:EqNotch = new EqNotch();
        eqNotch.y = i * -10;
        try
        {
            addChild(eqNotch);
        }
        catch (e:Error)
        {
        }
    }
    this.removeChildAt(this.numChildren-1);
}

function drawSampleData(eventObject:SampleDataEvent):void
{
    myTimer.start();
    myData = eventObject.data;
}

UPDATE

Great idea Adam, I got it though but I am having trouble deleting the correct ones.
I’m a little too far in to quit now and i want to learn this for the experience.

I had to create an array to record the height of each. It adds them properly but doesn’t delete them correctly.

    import flash.media.Microphone;
    import flash.events.SampleDataEvent;
import flash.utils.ByteArray;

var my_mic:Microphone = Microphone.getMicrophone();
my_mic.rate = 22;
my_mic.gain = 100;
my_mic.addEventListener(SampleDataEvent.SAMPLE_DATA, drawSampleData);
var myTimer:Timer = new Timer(20,8);
myTimer.addEventListener(TimerEvent.TIMER, timerListener);
var lastData:int;
var timeRemover;
var myData:ByteArray;

var numOfCols:int = 25;
var columns:Array = new Array();
/*for (var iLoop:iLoop=0;iLoop<numOfCols;iLoop++){
    column[
}*/



function timerListener(e:TimerEvent):void
{
    var currentData:int = 1;
    var floater:int = 1;
    try
    {
        //currentData = myData.readFloat()*30;
        currentData = my_mic.activityLevel / 5;
    }
    catch (e:Error)
    {
        currentData = 1;
    }


    try
    {
        floater = Math.abs(((currentData*3 + lastData)/4));//- (stage.x/2))
    }
    catch (e:Error)
    {
        floater = currentData;
    }
    lastData = currentData;

    if (floater > 20)
    {
        floater = 20;
    }
    if (floater < 1)
    {
        floater = 1;
    }

    for(var j:int = 0; j<numOfCols;j++)
    {

        var notchDistance:int = j * 30;
        if(columns[j]==null){
            columns[j]=0;
        }
        while (int(columns[j]) <= floater)
        {
            var eqNotch:EqNotch = new EqNotch();
            eqNotch.x = notchDistance;
            eqNotch.y = int(columns[j]) * -7;
            addChild(eqNotch);
            columns[j]++;
        }
        if(int(columns[j]) >= floater){
        columns[j]--;
        this.removeChildAt(int(columns[j])*(j+1)-1-j);
        trace("height"+columns[j]+"col"+j);
        }
    }
}

function drawSampleData(eventObject:SampleDataEvent):void
{
    myTimer.start();
    myData = eventObject.data;
}
  • 1 1 Answer
  • 1 View
  • 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-24T00:53:44+00:00Added an answer on May 24, 2026 at 12:53 am

    Got it.

    Thought I may as well share it with the community 🙂

    import flash.media.Microphone;
    import flash.events.SampleDataEvent;
    import flash.utils.ByteArray;
    
    var my_mic:Microphone = Microphone.getMicrophone();
    my_mic.rate = 22;
    my_mic.gain = 100;
    my_mic.addEventListener(SampleDataEvent.SAMPLE_DATA, drawSampleData);
    var myTimer:Timer = new Timer(20,8);
    myTimer.addEventListener(TimerEvent.TIMER, timerListener);
    var lastData:int;
    var timeRemover;
    var myData:ByteArray;
    
    var numOfCols:int = 25;
    var columns:Array = new Array();
    /*for (var iLoop:iLoop=0;iLoop<numOfCols;iLoop++){
        column[
    }*/
    
    
    
    function timerListener(e:TimerEvent):void
    {
        var currentData:int = 1;
        var floater:int = 1;
        try
        {
            //currentData = myData.readFloat()*30;
            currentData = my_mic.activityLevel / 5;
        }
        catch (e:Error)
        {
            currentData = 1;
        }
    
    
        try
        {
            floater = Math.abs(((currentData*3 + lastData)/4));//- (stage.x/2))
        }
        catch (e:Error)
        {
            floater = currentData;
        }
        lastData = currentData;
    
        if (floater > 20)
        {
            floater = 20;
        }
        if (floater < 1)
        {
            floater = 1;
        }
    
        for(var j:int = 0; j<numOfCols;j++)
        {
    
            var notchDistance:int = j * 30;
            if(columns[j]==null){
                columns[j]=0;
            }
            while (int(columns[j]) <= floater)
            {   
                var eqNotch:EqNotch = new EqNotch();
                eqNotch.x = notchDistance;
                eqNotch.y = int(columns[j]) * -7;
                addChild(eqNotch);
                columns[j]++;
    
            }
            if(int(columns[j]) >= floater){
            columns[j]--;
            this.removeChildAt((int(columns[j])*j)+((j+1)*(int(columns[j])-1)));
            trace("height"+columns[j]+"col"+j);
    
            }
        }
    }
    
    function drawSampleData(eventObject:SampleDataEvent):void
    {
        myTimer.start();
        myData = eventObject.data;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first post and I my first experience with jquery. I have
This is my first ever question on SO. So I have a MYSQL table
This is my first post on stackoverflow, so please excuse me if my question
This is my first post here. I have a problem. I need to take
i'm new to this kind of things. Kinda the first post ever regarding programming,
This is probably the worst question I have ever posted on Stack Overflow but
first post ever here I'm trying to replicate this sort of JSON object so
this is my first ever post here. I'm not sure if I've done the
this is my first question posted on the internet ever, I was usually able
Little bit of a 2 parter. First of all im trying to do this

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.