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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:13:54+00:00 2026-05-25T20:13:54+00:00

I want the stage to react every time some changes are made to certain

  • 0

I want the stage to react every time some changes are made to certain objects. Is there a way to write custom Event? I could of course modify this object, but I would like to know if there is any more OOP way to do it. And events ARE OOP, ain’t they?

  • 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-25T20:13:54+00:00Added an answer on May 25, 2026 at 8:13 pm

    Lets say you have a property count in some class. Easiest way is to generate setter and getter for this property and inside the setter to dispatch some custom event.

    protected var _count:Number;
    public function get count():Number
    {
        return _count;
    }
    public function set count(value:Number):void
    {
        _count = value;
        dispatchEvent(new CountEvent(CountEvent.COUNT_CHANGED, value, true));
    }
    

    This is the custom event class:

    public class CountEvent extends Event
    {
        public static const COUNT_CHANGED:String = "countChanged";
    
        public var data:Object;
    
        public function CountEvent(type:String, data:Object, bubbles:Boolean=false, cancelable:Boolean=false)
        {
            super(type, bubbles, cancelable);
            this.data = data;
        }
    
        override public function clone():Event
        {
            return new CountEvent(type, data, bubbles, cancelable);
        }
    }
    

    Note that if you need the value of the property and don’t have reference to the object itself, you can create a data-object event. In order for this kind of custom event to work properly you need to override the clone method, which is used every time the event is re-dispatched.

    If you are looking for more advanced way of “observing” something is by using some custom code, e.g.
    http://code.google.com/p/flit/source/browse/trunk/flit/src/obecto/utility/observe/Observe.as?r=190

    In either way you must decide whether you want to modify your class by adding a dispatcher (if your class is not a EventDispatcher subclass) and dispatch an event or use some other techniques. Another way is to make the property [Bindable] and use a binding between your property and some function to watch if something changes.

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

Sidebar

Related Questions

I want to write a ViewModel that always knows the current state of some
In my Git repo, I changed some files. I want to stage all of
Basically I want to stage my changes without pushing them and without switching branches.
I am trying to create a custom stage in javafx 2.0. I want that
There are many movieclips placed on stage? Now I want to align them using
I want to add a new Stage called field to the default one (i
I have a textField on my stage named 'adBuy', which when clicked I want
I want to check some things about the state of the session, the user
If I want to navigate directly to the second state of some flex app,
I have 7 movieclips on stage I want to tween around an ellipse from

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.