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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:01:01+00:00 2026-05-31T23:01:01+00:00

In Flash, I created a grid of 400 buttons with instance names c0 through

  • 0

In Flash, I created a grid of 400 buttons with instance names c0 through c399.

In Actionscript, I’d like to create an array like this:

var myArray:Array = [c0,c1,c2,c3,c4,c5,c6];

all the way up to c399.

I wrote a for-loop to do the trick, but it doesn’t seem to be working:

import flash.events.MouseEvent;
//create the array
var myArray:Array = [];


for (var i:int=0;i<399;i++){
    var cletter:String = 'c';
    var p:String = i.toString();
    var newvalue:String = cletter + p;
    var shizzle:Object = new SimpleButton();
    myArray[i] = shizzle;
}


for each(var btn in myArray){
    btn.addEventListener(MouseEvent.CLICK, onBtnClick);     
}
function onBtnClick(event:MouseEvent):void{
 cellinfo.gotoAndStop(event.target.name);
}

When I publish it, no errors show up and nothing happens when I click the buttons. However, if I use

var myArray:Array = [c0,c1,c2,c3,c4,c5,c6];

it does work! (for the first 7 buttons at least).

Also, when I put:

for (var i:int=1;i<6;i++){
    var cletter:String = 'c';
    var p:String = i.toString();
    var newvalue:Object = cletter + p;
    myArray[i] = newvalue;
}

it says:

TypeError: Error #1006: value is not a function. at
PVproject1_fla::MainTimeline/frame1()

I just started working with AS3 + Flash and spent hours looking for a solution. Please help!

  • 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-31T23:01:03+00:00Added an answer on May 31, 2026 at 11:01 pm

    Your code is broken in more than one way.

    for (var i:int=0;i<399;i++){
        var cletter:String = 'c';
        var p:String = i.toString();
        var newvalue:String = cletter + p; // => this is never used
        var shizzle:Object = new SimpleButton(); // => this creates a new (!) button
        myArray[i] = shizzle;
    }
    

    Each of the 400 newly created buttons is never added to the stage, therefore you can’t see it. And since it has no skin or other visual properties, you wouldn’t be able to see it if it were.

    The second for-loop puts only the names into the array – which causes the “value is not a function” error when you try to access the array values as buttons, because the value is really a string:

    for (var i:int=1;i<6;i++){
        var cletter:String = 'c';
        var p:String = i.toString();
        var newvalue:Object = cletter + p; // <= this is a String!
        myArray[i] = newvalue;
    }
    

    Now apart from a fundamental doubt whether you’d really want to create 400 button instances by hand (I’d think about doing it in ActionScript and using this actual creation to fill the array), you can do the following – but remember: only if the button instances are already on the stage, and the loop is located in a frame script!

    for (var i:int=0;i<399;i++){
        myArray[i] = this["c"+i]; // no need for all the p and .toString() stuff, btw
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are most flash video players created all programmatically? Or they done using static buttons
I bought this program that created a pretty nice imageuploader flash script however I
This is a AS3 project created in FlashDevelop. It targets flash player 10. I
I have created a flash player that loads external swfs and control them through
We got this assignment from school to reproduce this example (created in Flash) into
I need to create a flip book/page application. I have seen flash created flip
I am relatively new to flash. I am trying to create a square grid
I need to create a really basic flash video (actionscript 2) where I click
I've created a Flash Animation (CS5, ActionScript 3) and converted it to SWF. The
I am trying to create a grid for a flash game to use with

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.