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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:29:41+00:00 2026-05-27T12:29:41+00:00

Below is my AS3 code: public function load_swfs(event:Event) { var loader:Loader = event.target.getChildAt(0) as

  • 0

Below is my AS3 code:

    public function load_swfs(event:Event)
    {
        var loader:Loader = event.target.getChildAt(0) as Loader;
        var mc:MovieClip = loader.content as MovieClip;
        var mc_name = 'somethingGeneratedElsewhere';
        this.animations[mc_name] = mc;
    }

    // --------------------------------------------------------------------
    public function add(mc_name)
    {
        //this.animations is a object that holds a bunch of dynamically loaded SWF files.
        addChild(this.animations[mc_name]);
        this.animations[mc_name].addEventListener(Event.ENTER_FRAME, enter_frame_handler);
    }

    // --------------------------------------------------------------------
    public function enter_frame_handler(e:Event)
    {
       //how do I get mc_name in this function
       // Example, if I run add('movie123'). How do I get 'movie123' in this function?
    }

If I run add(‘movie123’). How do I get the string ‘movie123’ in the enter_frame_handler function?

UPDATE

This forum post (Click Here) describes the issues I am having but doesn’t provide the solution I am looking for. Luckily @kapep provided a simple solution that solved the issue.

  • 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-27T12:29:41+00:00Added an answer on May 27, 2026 at 12:29 pm

    The other solutions are usually the better options. If you can’t dynamically add properties, you still could map the objects to the names using a Dictionary.

    private var animationNames:Dictionary = new Dictionary();
    
    public function add(mc_name)
    {
        // store animation object and the name
        animationNames[this.animations[mc_name]] = mc_name; 
    
        addChild(this.animations[mc_name]);
        this.animations[mc_name].addEventListener(Event.ENTER_FRAME, enter_frame_handler);
    }
    
    // --------------------------------------------------------------------
    public function enter_frame_handler(e:Event)
    {
        var name:String = animationNames[e.currentTarget];
        // ...
    }
    

    Anyway, keep in mind that this.animations[mc_name] isn’t really using the movieclips name and that it isn’t possible to get the variable name that way. If you would dothis.animations[some_other_name] = this.animations[mc_name]; you would have two variables referring to the same object. There would be no way to tell which variable got used to attach the listener to. So make sure you understand the difference between a movieclip name and it’s variable’s name.

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

Sidebar

Related Questions

My xml is like below <rat> <to>tt</to> <from>ggg</from> <heading>hhhhh</heading> <body>jjj</body> </rat> My AS3 code
Below is a basic code bit in as3 flash.A simple video streaming example using
I am trying to move up and down in AS3 with the code below:
I'm playing with a Physics Engine for AS3 and the code below is basically
I am new to AS3. When learning AS3, I get the below code from
I have a code as below import flash.media.Sound; import flash.media.SoundChannel; flash.system.Security.allowDomain(*); var request:URLRequest =
I have the following as3 function below which converts normal html with links so
Below is my current char* to hex string function. I wrote it as an
Below is the code of a simple html with a table layout. In FF
i am using get and setters in my as3 code to edit values of

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.