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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:11:40+00:00 2026-05-19T13:11:40+00:00

This doesn’t make any sense to my feeble brain, and I’ve reached my googlefu

  • 0

This doesn’t make any sense to my feeble brain, and I’ve reached my googlefu limit.

I have a bunch of prototype methods that I use to speed development up, and most of them are attached to DisplayObject or InterActiveObject. Here’s an example of one such prototype:

DisplayObject.prototype.$click = function(clicked:Function, released:Function = null):void{
    this.addEventListener(MouseEvent.MOUSE_DOWN, function():void {
            clicked();
        });

    if(released != null){
        this.addEventListener(MouseEvent.MOUSE_UP, function():void {
            released();
        });
    }
}

If I call any movieClipInstance.$click(someFunction), it binds correctly. However, if I attempt to do that on a TextField instance, it gives me the following compile-time error.
Call to a possibly undefined method $click through a reference with static type flash.text:TextField.

According to the reference, TextField inherits DisplayObject, but just to be sure I redefined my prototype explicitly for TextFields. Still the same error. 🙁

  • 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-19T13:11:41+00:00Added an answer on May 19, 2026 at 1:11 pm

    You can always extend TextField and add the methods there. In fact, you should consider doing this for all the other objects as well: Extend MovieClip, Sprite, or whatever other DisplayObject you want to add the $click method to. Then let all your other objects inherit ClickMovie, ClickSprite etc. instead of the generic classes. It should not be a lot more code to write, but your application will be considerably faster and type safe.

    You should use prototype only in cases where you have to add or override methods or properties dynamically at runtime.

    An in-depth explanation on how inheritance works in AS3 can be found here.

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

Sidebar

Related Questions

this doesn't make any sense to me. must be wrong or painfully obvious. after
This doesn't make sense to me yet. So the first while loop runs and
This doesn't make sense.. I'm trying to sort posts according to the value of
This doesn't really make sense to me. My scroll bar works perfectly if LargeChange
This doesn't have to be Java, but it's what I'm dealing with. Also, not
This doesn't work: INSERT INTO users (username, password) VALUES (Jack,123) WHERE id='1'; Any ideas
This doesn't have to be with a clicking sound. I need something to visualize
This doesn't happen all the time. A bug is not a bug if cannot
this doesn't feel right Private Sub drop_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
This doesn't execute the delimiter (its displayed verbatim in the confirm dialog). Why not?

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.