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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:38:40+00:00 2026-05-15T06:38:40+00:00

i’ve never tried to do this before, so my head a swimming a bit.

  • 0

i’ve never tried to do this before, so my head a swimming a bit. i’d like to have a public boolean called enabled in myClass custom class. if it’s called to be changed, how do i trigger a function from the change?

should i add an Event.CHANGE event listener to my variable? can i do that? or is there a more standard way?

  • 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-15T06:38:41+00:00Added an answer on May 15, 2026 at 6:38 am

    We usually use properties for that.
    Properties are just like public variables for the outside — you can set instance.enabled = true; and so forth.. But you define properties as getters and/or setters functions for the class.
    They are the perfect place for custom logic to be executed on value changes.

    For example:

    public class CustomClass {
        private var _enabled:Boolean = false;
    
        public function set enabled(value:Boolean):void {
            trace('CustomClass.enabled is now', value);
            this._enabled = value;
        }
    
        public function get enabled():Boolean {
            trace('CustomClass.enabled was retrieved');
            return this._enabled;
        }
    }
    

    Note that they can’t have the same name as your private variable and you don’t need both of them defined. Actually, you don’t even need a variable for a setter/getter. You could use them just like any function — they just supply you with a different syntax.
    For example:

    var object:CustomClass = new CustomClass();
    object.enabled = false;
    if (object.enabled) {
        ...
    }
    

    They are great to expose a simple API, keeping you from rewriting outside code if the class’ internals have to change.

    AS3 Reference on getters and setters.

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

Sidebar

Related Questions

No related questions found

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.