| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Member
Join Date: Jul 2005
Posts: 86
|
I want to set a data Obj on my MenuItemMC with an eventListener to automatically Refresh() my content when the data updated....
Is there a way to be notified by an event like: _data.addEventListener(Event.CHANGE, Refresh); or var p:ObjectProxy = new ObjectProxy(_data); p.addEventListener(PropertyChangeEvent.PROPERTY_CH ANGE, Refresh); in flash ??? this would be GREAT !!!! |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Feb 2008
Location: West Palm Beach, FL
Posts: 2,407
|
yeah, in the class for the object that is being updated, dispatch an event when a property changes via its getter/setter methods.
__________________
www.lordofduct.com - come read my blog! If you want to know how to program, take a math class, take a lot of math classes! |
|
|
|
|
|
|
|
|
#3 |
|
Member
Join Date: Jul 2005
Posts: 86
|
Thanks for your interest ...
ActionScript Code:
I would like to leave the set data() method as is cause if i am to add a dispatch event to it i might as well just add a call to Refresh(); What do you think ? |
|
|
|
|
|
#4 |
|
unRegistered User
Join Date: Feb 2008
Location: Bangalore
Posts: 817
|
if refresh method is in the same class and u need to refresh for every objects (if u r not selective about refreshing) u can call refresh directly from the setter. event mechanism is useful if u don't want all objects to be refreshed or refreshing is done in some another class.
if u don't wanna modify the setter at all .... i don't know if there is a way
__________________
Blog |
|
|
|
|
|
#5 |
|
Site Contributor
Join Date: Jun 2008
Location: Brooklyn
Posts: 311
|
yep agree with the above posters: just add an event dispatch to the setter, or call refresh to send the dispatch.
it sounds like just what you need |
|
|
|
|
|
#6 |
|
Member
Join Date: Jul 2005
Posts: 86
|
OK i get what you are saying but the fact that i cannot set an event listener "Change" to a property (what ever it may be) in FLASH is FRUSTRATING !!!!
I would even consider it as being a fundamental need... |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Feb 2008
Location: West Palm Beach, FL
Posts: 2,407
|
having all objects dispatch events every time a property is changed would cause for a lot of slow down. I mean consider the idea that that you have a variable that you reuse over and over and over in loops and all over the place. Every time you accessed it, this event would fire.
On top of that, consider things like all the C languages, they hardly use eventDispatchers. And everyone has gotten by with out it. (Yes there are event style handling in things like C#, but it isn't quite like AS3's eventDispatcher). This is why the getter and setter methods are available to you. It isn't like it's that hard to just stick another call to a method inside of these methods. It gives you, the programmer, much more ease of control. Keep in mind, proper OO standards suggest that you always protect properties and use getter and setter methods to change them.
__________________
www.lordofduct.com - come read my blog! If you want to know how to program, take a math class, take a lot of math classes! Last edited by lordofduct; 06-08-2008 at 04:39 AM.. |
|
|
|
|
|
#8 |
|
Member
Join Date: Jul 2005
Posts: 86
|
thanks you for your thoughts on this i appreciate... The way i am thinking of it is not in relation to the event dispatcher framework available its more about the monitoring of a property... it would be more like subscribing to a list that get there value monitored at a low level to save on processing power... and in regards to OOP practice the idea of leaving a set property as an set property and nothing more attracts me... I think this system is implemented in FLEX with the ( addEventListener(PropertyChangeEvent.PROPERTY_CHAN GE )so really its only a mater of time to get it available in FLASH but its still frustrating not to have any other alternative than to set an event enterframe (costly to the CPU) to monitor the fluctuation of a property...
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|