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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:34:11+00:00 2026-06-15T05:34:11+00:00

How can I add the MovieClip I have put into the array to the

  • 0

How can I add the MovieClip I have put into the array to the Stage?
The following code is a separated .as file and located at the same level with the main.fla
I have tried many times but I got the error message –

“ReferenceError: Error #1065: Variable stage is not defined. at Set1()
at main_fla::MainTimeline/frame1()”

How can I do? Thank for any help!!

package 
{
    import flash.display.MovieClip;
    import flash.display.Stage;
    public class Set1
    {
        private var map:Array=new Array();

        public function Set1()
        {
            for (var i:Number=0; i<5; i++)
            {
                var cell_mc=new cell();
                cell_mc.x = 50+ i*cell_mc.width;
                cell_mc.y = 50;
                cell_mc.className=i;
                map[i] = cell_mc;
                trace(map[i].className);
                stage.addChild(map[i]);
                }

        }

    }

}
  • 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-15T05:34:12+00:00Added an answer on June 15, 2026 at 5:34 am

    You are a little mixed up. stage is not a magic variable, instead it is a property that is inherited from the DisplayObject base class. That property gets set internally when a display object is added to the stage. So in your case your class needs to either inherit from a DisplayObject– probably Sprite class. Or simply inject a reference to the Stage from the outside when you invoke your function

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

Sidebar

Related Questions

I have the following code which should add a MovieClip and add a frame
How I can add Header params in restlet android? I have following code: ClientResource
Can you add a movieclip to the stage from a child class? My setup
I have been creating a Flash file where more than one MovieClip can be
hey everyone, my code is listed below. as you can see, I have a
I have a piece of Actionscript code that Implements MovieClip. I don't seem to
I have the code below adding a movie clip to my stage and setting
How can you add data to a dynamically created MovieClip/Sprite so that the data
I have a question regarding createEmptyMovieClip in AS2. I have a flash file separated
I have a movieclip, we can call it mc. On my mc is a

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.