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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:54:56+00:00 2026-05-23T23:54:56+00:00

Here is an example of the code I’m working on: package button { import

  • 0

Here is an example of the code I’m working on:

package button
{
    import flash.display.*;
    import flash.events.*;

    public class  Button extends MovieClip
    {
         public var mybutton:MovieClip;

         public function Button () {
             buttonMode=true;
             mybutton.fromFile.addEventListener (MouseEvent.CLICK , handle )
         }

         public function handle (e:MouseEvent) {
             trace ("hello")
         }
    }
}

Click here to download an example

It gives me the following error, and I can’t figure out why:

TypeError: Error #1010: A term is undefined and has no properties.
    at button::Button()
    at test()
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()

Note that I do have auto declare enabled in my script settings. How should I fix this?

  • 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-23T23:54:57+00:00Added an answer on May 23, 2026 at 11:54 pm

    First of all, you define mybutton as MovieClip but never actually create it using the “new” keyword, nor do you assign that reference to any existing object, so that reference is “null” by default. But even if you did create a new MovieClip properly like so:

         public var mybutton:MovieClip;
    
         public function Button () {
             mybutton = new MovieClip();
    
             if(stage){
                 stage.addChild(mybutton);
             }
    
             buttonMode=true;
             mybutton.fromFile.addEventListener (MouseEvent.CLICK , handle )
         }
    

    You would then run into the same issue, and the offending line of code would be:

    mybutton.fromFile.addEventListener (MouseEvent.CLICK , handle );
    

    The MovieClip class is a dynamic class, which means that you can dynamically define properties of that object at runtime but until you do so, that reference is null or undefined. Take for example your code:

    mybutton.fromFile
    

    The property “fromFile” must either be the symbol name of a MovieClip that you’ve already created inside of myButton, or it must be defined first within your code somewhere before you can access it. You’re accessing this undefined reference when you use the following code:

    mybutton.fromFile.addEventListener
    

    You’re telling flash “okay, there is an EXISTING object attached to myButton called fromFile, so go get it, and attach a listener to it.” Since you have never actually created an object and attached to the dynamic, user made property “fromFile”, this “term” is undefined. Below is the only way that this code would work:

    package button
    {
        import flash.display.*;
        import flash.events.*;
    
        public class  Button extends MovieClip
        {
             public var mybutton:MovieClip;
    
             public function Button () {
                 buttonMode=true;
                 mybutton.fromFile = new MovieClip();
                 //OR
                 //mybutton.fromFile = someOtherMovieClip;
                 mybutton.fromFile.addEventListener (MouseEvent.CLICK , handle )
             }
    
             public function handle (e:MouseEvent) {
                 trace ("hello")
             }
        }
    }
    

    Note also that in order to attach a listener to any object, that Object must have either implement IEventDispatcher at some level in the objects inheritance chain or at some level the object must be derived from or extend EventDispatcher. MovieClips, Sprites and other DisplayObjects do this.

    Also note that if you were to simply attach a CLICK event listener to a simple, blank new MovieClip object, you’re never going to fire that event because you can never click on it. You cannot click on it, because you have not placed anything that is physically clickable inside that movieclip. The following code should work as you intended:

    package button
    {
        import flash.display.*;
        import flash.events.*;
    
        public class  Button extends MovieClip
        {
             public var mybutton:MovieClip;
    
             public function Button () {
                 mybutton = new MovieClip();
                 mybutton.graphics.beginFill(0, 1);
                 mybutton.graphics.drawRect(0,0,200,200);
                 mybutton.graphics.endFill();
                 if(stage){
                     stage.addChild(mybutton);
                 }
    
                 mybutton.buttonMode = true;
                 mybutton.fromFile.addEventListener (MouseEvent.CLICK , handle )
             }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is my example code: Public Class Parent Private _TestProperty As String Private WithEvents
Here's some example code: class Obj attr :c, true def == that p '=='
Here is the example code from my web.xml <security-constraint> <display-name> change password</display-name> <web-resource-collection> <web-resource-name>change
Here is an example code: import argparse parser=argparse.ArgumentParser() parser.add_argument('-main_arg') subparser=parser.add_subparser() a=subparser.add_parser('run') a.add_argument('required_sub_arg') a.add_argument('arg_a') b=subparser.add_parser('b')
I'm looking for something like break for loops. Here's some example code (using Symfony's
Here is an example of my code in a DAL. All calls to the
Is there a way to execute internal code via reflection? Here is an example
Here is my current code: RewriteCond %{HTTP_HOST} !^example\.com [NC] #RewriteCond %{REQUEST_URI}!^something RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
For example, my goal is to test the code given here: PHP script that
To use a contrived example in Java, here's the code: enum Commands{ Save(S); File(F);

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.