List Info

Thread: RE: Events for custom classes?




RE: Events for custom classes?
user name
2007-02-16 14:54:41
Can you please email your class to me as well [offlist]. I'm
working on
almost the same thing as Jason.

Thanks much,
Andrew Rost
IDEXX Computer Systems

-----Original Message-----
From: Merrill, Jason [mailto:jason.merrillbankofamerica.com] 
Sent: Friday, February 16, 2007 2:41 PM
To: Flashcoders mailing list
Subject: RE: [Flashcoders] Events for custom classes?

Sure, yes - please send offlist . Thanks!

Jason Merrill
Bank of America 
Learning & Organizational Effectiveness
 
 
 
 
 
 

>>-----Original Message-----
>>From: flashcoders-bounceschattyfig.figleaf.com 
>>[mailto:flashcoders-bounceschattyfig.figleaf.com] On
Behalf 
>>Of Karina Steffens
>>Sent: Friday, February 16, 2007 3:30 PM
>>To: 'Flashcoders mailing list'
>>Subject: RE: [Flashcoders] Events for custom
classes?
>>
>>Hi Jason,
>>
>>I have my own implementation of
AsBroadcaster/EventDispatcher 
>>(bundling both in one class), which is very flexible
and can 
>>be used with inheritance or composition (But unlike
the 
>>standard implementations, it's not a mix-in class).
If you'd 
>>like me to send you the class, just let me know.
>>
>>Karina
>> 
>>
>>> -----Original Message-----
>>> From: Merrill, Jason [mailto:jason.merrillbankofamerica.com]
>>> Sent: 16 February 2007 20:16
>>> To: Flashcoders mailing list
>>> Subject: RE: [Flashcoders] Events for custom
classes?
>>> 
>>> Thanks Alain, will revist it that way instead.
>>> 
>>> Jason Merrill
>>> Bank of America
>>> Learning & Organizational Effectiveness
>>>  
>>>  
>>>  
>>>  
>>>  
>>>  
>>> 
>>> >>-----Original Message-----
>>> >>From: flashcoders-bounceschattyfig.figleaf.com
>>> >>[mailto:flashcoders-bounceschattyfig.figleaf.com] On
>>> Behalf Of Alain
>>> >>Rousseau
>>> >>Sent: Friday, February 16, 2007 3:01
PM
>>> >>To: 'Flashcoders mailing list'
>>> >>Subject: RE: [Flashcoders] Events for
custom classes?
>>> >>
>>> >>Jason,
>>> >>
>>> >>So if I understand clearly what you
want to do is :
>>> >>
>>> >>>From Class A : (pseudo code
following)
>>> >>
>>> >>class ClassA {
>>> >>	private var instClassB:ClassB;
>>> >>	make comboBox
>>> >>	make datagrid
>>> >>	function ClassA() {
>>> >>		instClassB = new ClassB();
>>> >>		comboBox.onChange =
Delegate.create(this,
>>> cbChangeHandler);
>>>
>>		instClassB.addEventListener("webServiceResult
", this);
>>> >>	}
>>> >>
>>> >>	function cbChangeHandler(e){
>>> >>		instClassB.getWSdata(e.value);
>>> >>	}
>>> >>
>>> >>	function
webServiceResult(evtObj:Object) {
>>> >>		update datagrid with evtObj.newData
>>> >>	}
>>> >>
>>> >>}
>>> >>
>>> >>class ClassB {
>>> >>	Decorate with EventDispatcher methods
>>> >>	dispatchEvent, addEventListener,
removeEventListener
>>> >>
>>> >>	function ClassB() {
>>> >>		EventDispatcher.initialize(this);
>>> >>	}
>>> >>	
>>> >>	function getWSdata(val) {
>>> >>		get data from web service
>>> >>		wsInstance.onResult =
Delegate.create(this,
>>> wsResulthandler);
>>> >>	}
>>> >>	
>>> >>	function wsResulthandler(data) {
>>>
>>		this.dispatchEvent({type:"webServiceResult&qu
ot;,
>>> >>newData:data}) // add anything you want
to pass in the object
>>> >>	}
>>> >>}
>>> >>
>>> >>Now you have them both communication
the way you want
>>> >>
>>> >>Have fun !
>>> >>
>>> >>Alain
>>> >>
>>> >>-----Original Message-----
>>> >>From: flashcoders-bounceschattyfig.figleaf.com
>>> >>[mailto:flashcoders-bounceschattyfig.figleaf.com] On Behalf Of 
>>> >>Merrill, Jason
>>> >>Sent: 16 février 2007 14:36
>>> >>To: Flashcoders mailing list
>>> >>Subject: RE: [Flashcoders] Events for
custom classes?
>>> >>
>>> >>Daniel, try as I may, I can't get your
code to work.  I have one 
>>> >>class, which has a combobox.  I can get
the event to fire 
>>when the 
>>> >>combobox changes just fine, but I can't
get it to "hear"
>>> the firing of
>>> >>the data capture from the webservice in
the other class.
>>> >>
>>> >>So basically, in pseudocode, I need to
do this:
>>> >>
>>> >>class A{
>>> >>	make comboBox
>>> >>	make datagrid
>>> >>	when comboBox changes, use Class B
>>> >>		to get data from webservice
>>> >>	when webservice result received, 
>>> >>        		update datagrid with new
data
>>> >>
>>> >>}
>>> >>
>>> >>class B{
>>> >>	connect to webservice	
>>> >>	when requested, return data to
requesting class }
>>> >>
>>> >>Reason I want these two classes to be
separate is because I
>>> want other
>>> >>classes to call Class B to get data as
well.  So, I can do all of 
>>> >>those things just fine, they are all
working, except for the last 
>>> >>part, "when requested, return data
to requesting class" - 
>>I figure 
>>> >>since the webservice is asynchronous, I
need to capture the
>>> received
>>> >>event, which is fine, I can do, that
works.  But I need to
>>> tell Class
>>> >>A to update the datagrid with the new
data when it gets it
>>> from Class
>>> >>B - so an event model is required.
>>> >>
>>> >>in your code, you have a var r in both
the "Class A" and
>>> "Class B" -
>>> >>I'm confused about that.  Thanks for
any help.
>>> >>
>>> >>
>>> >>Jason Merrill
>>> >>Bank of America
>>> >>Learning & Organizational
Effectiveness
>>> >> 
>>> >> 
>>> >> 
>>> >> 
>>> >> 
>>> >> 
>>> >>
>>> >>>>-----Original Message-----
>>> >>>>From: flashcoders-bounceschattyfig.figleaf.com
>>> >>>>[mailto:flashcoders-bounceschattyfig.figleaf.com] On
>>> >>Behalf Of Holth,
>>> >>>>Daniel C.
>>> >>>>Sent: Friday, February 16, 2007
10:36 AM
>>> >>>>To: Flashcoders mailing list
>>> >>>>Subject: RE: [Flashcoders]
Events for custom classes?
>>> >>>>
>>> >>>>
>>> >>>>Here is your code modified to
use the EventDispatcher:
>>> >>>>
>>> >>>>import
mx.events.EventDispatcher; // import the event dispatcher
>>> >>>>
>>> >>>>class
com.boa.projects.iqrcgenerator.components.AdminData{
>>> >>>>	public var
addEventListener:Function; // Set 
>>the functions
>>> >>>>	public var
removeEventListener:Function; // Set 
>>the functions
>>> >>>>	private var
dispatchEvent:Function; // Set the functions
>>> >>>>
>>> >>>>	private var userData:Object;
>>> >>>>
>>> >>>>	// I'm sure you have a
different constructor, 
>>but you need
>>> >>>>	// to add that line to it if
you want to use 
>>the eventdispatcher
>>> >>>>	public function AdminData(){
>>>
>>>>		mx.events.EventDispatcher.initialize(this)
; //
>>> >>add this to
>>> >>>>constructor
>>> >>>>	}
>>> >>>>
>>> >>>>	public function
wsUserDataByLOB(lobDbId:Number):Void{
>>> >>>>		var getUserListResult:Object
= new Object();
>>> >>>>		getUserListResult =
>>>
>>>>generatorWebService.GetUserList(lobDbId);
>>> >>>>
>>> >>>>		var r = this;  // To get this
in onResult
>>> >>>>		getUserListResult.onResult =
function(oUser){
>>> >>>>
>>>
>>>>			r.dispatchEvent({type:"eventOnResult
",
>>> >>>>user:oUser}); // Dispatch the
event
>>> >>>>	
>>> >>>>
>>> >>>>		}
>>> >>>>	}
>>> >>>>
>>> >>>>
>>> >>>>	// I may just take this
function out all together since
>>> >>the event
>>> >>can
>>> >>>>	// autommatically send them
the data.
>>> >>>>	public function
getUserData():Object{
>>> >>>>		return userData;
>>> >>>>	}
>>> >>>>}
>>> >>>>
>>> >>>>
>>> >>>>Then in your other class you
can do something like:
>>> >>>>
>>> >>>>//myAdminData is an instance of
the class above
>>> >>>>
>>> >>>>var r = this;
>>> >>>>r.eventOnResult=
function(evtObj:Object){
>>> >>>>	trace("user: " +
evtObj.user);  // Should return the
>>> >>oUser object }
>>> >>>>// addEventListener takes the
event name, and who you want
>>> >>to listen
>>>
>>>>myAdminData.addEventListener("eventOnRe
sult", r);
>>> >>>>
>>> >>>>
>>> >>>>
>>> >>>>Does that help?  I obviously
can't test the code, but I think 
>>> >>>>everything is right...  I have
trouble with scope, 
>>which is why I 
>>> >>>>use a lot of 'r'
>>> >>>>values instead of 'this'...
Just easier for me... 
>>Probably not a 
>>> >>>>good coding standard 
>>> >>>>
>>> >>>>-Dan
>>> >>>>
>>> >>>>-----Original Message-----
>>> >>>>From: flashcoders-bounceschattyfig.figleaf.com
>>> >>>>[mailto:flashcoders-bounceschattyfig.figleaf.com] On Behalf Of 
>>> >>>>Merrill, Jason
>>> >>>>Sent: Friday, February 16, 2007
9:03 AM
>>> >>>>To: Flashcoders mailing list
>>> >>>>Subject: [Flashcoders] Events
for custom classes?
>>> >>>>
>>> >>>>OK, I'm pretty good at
Actionscript 2.0, but something I never 
>>> >>>>really understood and now need
to.
>>> >>>>
>>> >>>>Core question:  How do I make
an event in a custom class,
>>> and how do
>>> >>>>I make a listener in another
class listen for the event?
>>> >>>>
>>> >>>>
>>> >>>>EventBroadcaster in the help
docs seems to only show how
>>> to use it
>>> >>>>with Adobe classes and
components. Docs on listener are
>>> the same.  I
>>> >>>>know how to set up listeners
for other events, like
>>> keypresses and
>>> >>>>mouse rollovers.  Easy enough.
>>> >>>>But my problem is this (see
comments in code
>>> >>>>below):
>>> >>>>
>>> >>>>class
com.boa.projects.iqrcgenerator.components.AdminData{
>>> >>>>
>>> >>>>
>>> >>>>	private var userData:Object;
>>> >>>>
>>> >>>>	public function
wsUserDataByLOB(lobDbId:Number):Void{
>>> >>>>		var getUserListResult:Object
= new Object();
>>> >>>>		getUserListResult =
>>>
>>>>generatorWebService.GetUserList(lobDbId);
>>> >>>>		getUserListResult.onResult =
function(oUser){
>>> >>>>			//this works fine,
>>> >>>>
>>> >>>>			//I can capture this event
result here,
>>> >>>>			//but how do I notify
another class?
>>> >>>>			//also what about scope
here?
>>> >>>>			//how to set userData as
oUser result?
>>> >>>>			//can I fire an event in my
AdminData
>>> >>>>			//class from here?
>>> >>>>		}
>>> >>>>	}
>>> >>>>
>>> >>>>
>>> >>>>	public function
getUserData():Object{
>>> >>>>		//can't let user get this
data
>>> >>>>		//until Webserive event is
done.
>>> >>>>		return userData;
>>> >>>>	}
>>> >>>>}
>>> >>>>
>>> >>>>Thanks,
>>> >>>>
>>> >>>>
>>> >>>>Jason Merrill
>>> >>>>Bank of America
>>> >>>>
>>> >>>>Learning & Organizational
Effectiveness
>>> >>>>
>>> >>>>
>>> >>>>
>>> >>>>
>>>
>>>>____________________________________________
___
>>> >>>>Flashcoderschattyfig.figleaf.com
>>> >>>>To change your subscription
options or search the archive:
>>> >>>>http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
>>> >>>>
>>> >>>>Brought to you by Fig Leaf
Software Premier Authorized Adobe 
>>> >>>>Consulting and Training http://www.figleaf.com 
>>> >>>>http://training.figleaf.c
om
>>> >>>>
>>> >>>>This e-mail and its attachments
are intended only for the
>>> use of the
>>> >>>>addressee(s) and may contain
privileged, confidential or
>>> proprietary
>>> >>>>information. If you are not the
intended recipient, or
>>> the employee
>>> >>>>or agent responsible for
delivering the message to the intended 
>>> >>>>recipient, you are hereby
notified that any dissemination, 
>>> >>>>distribution, displaying,
copying, or use of this 
>>information is 
>>> >>>>strictly prohibited. If you
have received this communication in 
>>> >>>>error, please inform the sender
immediately and delete
>>> and destroy
>>> >>>>any record of this message.
Thank you.
>>>
>>>>____________________________________________
___
>>> >>>>Flashcoderschattyfig.figleaf.com
>>> >>>>To change your subscription
options or search the archive:
>>> >>>>http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
>>> >>>>
>>> >>>>Brought to you by Fig Leaf
Software Premier Authorized Adobe 
>>> >>>>Consulting and Training http://www.figleaf.com 
>>> >>>>http://training.figleaf.c
om
>>> >>>>
>>>
>>_______________________________________________
>>> >>Flashcoderschattyfig.figleaf.com
>>> >>To change your subscription options or
search the archive:
>>> >>http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
>>> >>
>>> >>Brought to you by Fig Leaf Software
>>> >>Premier Authorized Adobe Consulting and
Training 
>>> >>http://www.figleaf.com http://training.figleaf.c
om
>>> >>
>>> >>
>>> >>--
>>> >>No virus found in this incoming
message.
>>> >>Checked by AVG Free Edition.
>>> >>Version: 7.1.412 / Virus Database:
268.18.0/689 - Release
>>> >>Date: 2007-02-15
>>> >> 
>>> >>
>>> >>--
>>> >>No virus found in this outgoing
message.
>>> >>Checked by AVG Free Edition.
>>> >>Version: 7.1.412 / Virus Database:
268.18.0/689 - Release
>>> >>Date: 2007-02-15
>>> >> 
>>> >>
>>>
>>_______________________________________________
>>> >>Flashcoderschattyfig.figleaf.com
>>> >>To change your subscription options or
search the archive:
>>> >>http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
>>> >>
>>> >>Brought to you by Fig Leaf Software
>>> >>Premier Authorized Adobe Consulting and
Training 
>>> >>http://www.figleaf.com http://training.figleaf.c
om
>>> >>
>>>
_______________________________________________
>>> Flashcoderschattyfig.figleaf.com
>>> To change your subscription options or search
the archive:
>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
>>> 
>>> Brought to you by Fig Leaf Software
>>> Premier Authorized Adobe Consulting and
Training 
>>> http://www.figleaf.com http://training.figleaf.c
om
>>> 
>>
>>_______________________________________________
>>Flashcoderschattyfig.figleaf.com
>>To change your subscription options or search the
archive:
>>http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
>>
>>Brought to you by Fig Leaf Software
>>Premier Authorized Adobe Consulting and Training 
>>http://www.figleaf.com http://training.figleaf.c
om
>>
_______________________________________________
Flashcoderschattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.c
om
_______________________________________________
Flashcoderschattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.c
om

RE: Events for custom classes?
country flaguser name
Ireland
2007-02-16 19:26:16
I sent the custom class off list to both of you. 

If anyone else is interested, I'll put it on my blog as soon
as I get a
moment to spare, and will let the list know when it's
there.

Karina 

> -----Original Message-----
> From: Rost, Andrew [mailto:andrew-rostidexx.com] 
> Sent: 16 February 2007 20:55
> To: 'Flashcoders mailing list'
> Subject: RE: [Flashcoders] Events for custom classes?
> 
> Can you please email your class to me as well
[offlist]. I'm 
> working on almost the same thing as Jason.
> 
> Thanks much,
> Andrew Rost
> IDEXX Computer Systems
> 
> -----Original Message-----
> From: Merrill, Jason [mailto:jason.merrillbankofamerica.com]
> Sent: Friday, February 16, 2007 2:41 PM
> To: Flashcoders mailing list
> Subject: RE: [Flashcoders] Events for custom classes?
> 
> Sure, yes - please send offlist . Thanks!
> 
> Jason Merrill
> Bank of America
> Learning & Organizational Effectiveness
>  
>  
>  
>  
>  
>  
> 
> >>-----Original Message-----
> >>From: flashcoders-bounceschattyfig.figleaf.com
> >>[mailto:flashcoders-bounceschattyfig.figleaf.com] On 
> Behalf Of Karina 
> >>Steffens
> >>Sent: Friday, February 16, 2007 3:30 PM
> >>To: 'Flashcoders mailing list'
> >>Subject: RE: [Flashcoders] Events for custom
classes?
> >>
> >>Hi Jason,
> >>
> >>I have my own implementation of
AsBroadcaster/EventDispatcher 
> >>(bundling both in one class), which is very
flexible and 
> can be used 
> >>with inheritance or composition (But unlike the
standard 
> >>implementations, it's not a mix-in class). If
you'd like me to send 
> >>you the class, just let me know.
> >>
> >>Karina
> >> 
> >>
> >>> -----Original Message-----
> >>> From: Merrill, Jason
[mailto:jason.merrillbankofamerica.com]
> >>> Sent: 16 February 2007 20:16
> >>> To: Flashcoders mailing list
> >>> Subject: RE: [Flashcoders] Events for
custom classes?
> >>> 
> >>> Thanks Alain, will revist it that way
instead.
> >>> 
> >>> Jason Merrill
> >>> Bank of America
> >>> Learning & Organizational
Effectiveness
> >>>  
> >>>  
> >>>  
> >>>  
> >>>  
> >>>  
> >>> 
> >>> >>-----Original Message-----
> >>> >>From: flashcoders-bounceschattyfig.figleaf.com
> >>> >>[mailto:flashcoders-bounceschattyfig.figleaf.com] On
> >>> Behalf Of Alain
> >>> >>Rousseau
> >>> >>Sent: Friday, February 16, 2007
3:01 PM
> >>> >>To: 'Flashcoders mailing list'
> >>> >>Subject: RE: [Flashcoders] Events
for custom classes?
> >>> >>
> >>> >>Jason,
> >>> >>
> >>> >>So if I understand clearly what
you want to do is :
> >>> >>
> >>> >>>From Class A : (pseudo code
following)
> >>> >>
> >>> >>class ClassA {
> >>> >>	private var instClassB:ClassB;
> >>> >>	make comboBox
> >>> >>	make datagrid
> >>> >>	function ClassA() {
> >>> >>		instClassB = new ClassB();
> >>> >>		comboBox.onChange =
Delegate.create(this,
> >>> cbChangeHandler);
> >>> >>		
>
instClassB.addEventListener("webServiceResult",
this);
> >>> >>	}
> >>> >>
> >>> >>	function cbChangeHandler(e){
> >>> >>		instClassB.getWSdata(e.value);
> >>> >>	}
> >>> >>
> >>> >>	function
webServiceResult(evtObj:Object) {
> >>> >>		update datagrid with
evtObj.newData
> >>> >>	}
> >>> >>
> >>> >>}
> >>> >>
> >>> >>class ClassB {
> >>> >>	Decorate with EventDispatcher
methods
> >>> >>	dispatchEvent, addEventListener,
removeEventListener
> >>> >>
> >>> >>	function ClassB() {
> >>>
>>		EventDispatcher.initialize(this);
> >>> >>	}
> >>> >>	
> >>> >>	function getWSdata(val) {
> >>> >>		get data from web service
> >>> >>		wsInstance.onResult =
Delegate.create(this,
> >>> wsResulthandler);
> >>> >>	}
> >>> >>	
> >>> >>	function wsResulthandler(data) {
> >>>
>>		this.dispatchEvent({type:"webServiceResult&qu
ot;,
> >>> >>newData:data}) // add anything you
want to pass in the object
> >>> >>	}
> >>> >>}
> >>> >>
> >>> >>Now you have them both
communication the way you want
> >>> >>
> >>> >>Have fun !
> >>> >>
> >>> >>Alain
> >>> >>
> >>> >>-----Original Message-----
> >>> >>From: flashcoders-bounceschattyfig.figleaf.com
> >>> >>[mailto:flashcoders-bounceschattyfig.figleaf.com] On Behalf Of 
> >>> >>Merrill, Jason
> >>> >>Sent: 16 février 2007 14:36
> >>> >>To: Flashcoders mailing list
> >>> >>Subject: RE: [Flashcoders] Events
for custom classes?
> >>> >>
> >>> >>Daniel, try as I may, I can't get
your code to work.  I 
> have one 
> >>> >>class, which has a combobox.  I
can get the event to fire
> >>when the
> >>> >>combobox changes just fine, but I
can't get it to "hear"
> >>> the firing of
> >>> >>the data capture from the
webservice in the other class.
> >>> >>
> >>> >>So basically, in pseudocode, I
need to do this:
> >>> >>
> >>> >>class A{
> >>> >>	make comboBox
> >>> >>	make datagrid
> >>> >>	when comboBox changes, use Class
B
> >>> >>		to get data from webservice
> >>> >>	when webservice result received,

> >>> >>        		update datagrid with new
data
> >>> >>
> >>> >>}
> >>> >>
> >>> >>class B{
> >>> >>	connect to webservice	
> >>> >>	when requested, return data to
requesting class }
> >>> >>
> >>> >>Reason I want these two classes to
be separate is because I
> >>> want other
> >>> >>classes to call Class B to get
data as well.  So, I can 
> do all of 
> >>> >>those things just fine, they are
all working, except 
> for the last 
> >>> >>part, "when requested, return
data to requesting class" -
> >>I figure
> >>> >>since the webservice is
asynchronous, I need to capture the
> >>> received
> >>> >>event, which is fine, I can do,
that works.  But I need to
> >>> tell Class
> >>> >>A to update the datagrid with the
new data when it gets it
> >>> from Class
> >>> >>B - so an event model is
required.
> >>> >>
> >>> >>in your code, you have a var r in
both the "Class A" and
> >>> "Class B" -
> >>> >>I'm confused about that.  Thanks
for any help.
> >>> >>
> >>> >>
> >>> >>Jason Merrill
> >>> >>Bank of America
> >>> >>Learning & Organizational
Effectiveness
> >>> >> 
> >>> >> 
> >>> >> 
> >>> >> 
> >>> >> 
> >>> >> 
> >>> >>
> >>> >>>>-----Original
Message-----
> >>> >>>>From:
flashcoders-bounceschattyfig.figleaf.com
> >>>
>>>>[mailto:flashcoders-bounceschattyfig.figleaf.com] On
> >>> >>Behalf Of Holth,
> >>> >>>>Daniel C.
> >>> >>>>Sent: Friday, February 16,
2007 10:36 AM
> >>> >>>>To: Flashcoders mailing
list
> >>> >>>>Subject: RE: [Flashcoders]
Events for custom classes?
> >>> >>>>
> >>> >>>>
> >>> >>>>Here is your code modified
to use the EventDispatcher:
> >>> >>>>
> >>> >>>>import
mx.events.EventDispatcher; // import the event 
> dispatcher
> >>> >>>>
> >>> >>>>class
com.boa.projects.iqrcgenerator.components.AdminData{
> >>> >>>>	public var
addEventListener:Function; // Set
> >>the functions
> >>> >>>>	public var
removeEventListener:Function; // Set
> >>the functions
> >>> >>>>	private var
dispatchEvent:Function; // Set the functions
> >>> >>>>
> >>> >>>>	private var
userData:Object;
> >>> >>>>
> >>> >>>>	// I'm sure you have a
different constructor,
> >>but you need
> >>> >>>>	// to add that line to it
if you want to use
> >>the eventdispatcher
> >>> >>>>	public function
AdminData(){
> >>>
>>>>		mx.events.EventDispatcher.initialize(this)
; //
> >>> >>add this to
> >>> >>>>constructor
> >>> >>>>	}
> >>> >>>>
> >>> >>>>	public function
wsUserDataByLOB(lobDbId:Number):Void{
> >>> >>>>		var
getUserListResult:Object = new Object();
> >>> >>>>		getUserListResult =
> >>>
>>>>generatorWebService.GetUserList(lobDbId);
> >>> >>>>
> >>> >>>>		var r = this;  // To get
this in onResult
> >>>
>>>>		getUserListResult.onResult =
function(oUser){
> >>> >>>>
> >>>
>>>>			r.dispatchEvent({type:"eventOnResult
",
> >>> >>>>user:oUser}); // Dispatch
the event
> >>> >>>>	
> >>> >>>>
> >>> >>>>		}
> >>> >>>>	}
> >>> >>>>
> >>> >>>>
> >>> >>>>	// I may just take this
function out all together since
> >>> >>the event
> >>> >>can
> >>> >>>>	// autommatically send
them the data.
> >>> >>>>	public function
getUserData():Object{
> >>> >>>>		return userData;
> >>> >>>>	}
> >>> >>>>}
> >>> >>>>
> >>> >>>>
> >>> >>>>Then in your other class
you can do something like:
> >>> >>>>
> >>> >>>>//myAdminData is an
instance of the class above
> >>> >>>>
> >>> >>>>var r = this;
> >>> >>>>r.eventOnResult=
function(evtObj:Object){
> >>> >>>>	trace("user: "
+ evtObj.user);  // Should return the
> >>> >>oUser object }
> >>> >>>>// addEventListener takes
the event name, and who you want
> >>> >>to listen
> >>>
>>>>myAdminData.addEventListener("eventOnRe
sult", r);
> >>> >>>>
> >>> >>>>
> >>> >>>>
> >>> >>>>Does that help?  I
obviously can't test the code, but I think 
> >>> >>>>everything is right...  I
have trouble with scope,
> >>which is why I
> >>> >>>>use a lot of 'r'
> >>> >>>>values instead of
'this'... Just easier for me... 
> >>Probably not a
> >>> >>>>good coding standard 
> >>> >>>>
> >>> >>>>-Dan
> >>> >>>>
> >>> >>>>-----Original
Message-----
> >>> >>>>From:
flashcoders-bounceschattyfig.figleaf.com
> >>>
>>>>[mailto:flashcoders-bounceschattyfig.figleaf.com] On 
> Behalf Of 
> >>> >>>>Merrill, Jason
> >>> >>>>Sent: Friday, February 16,
2007 9:03 AM
> >>> >>>>To: Flashcoders mailing
list
> >>> >>>>Subject: [Flashcoders]
Events for custom classes?
> >>> >>>>
> >>> >>>>OK, I'm pretty good at
Actionscript 2.0, but 
> something I never 
> >>> >>>>really understood and now
need to.
> >>> >>>>
> >>> >>>>Core question:  How do I
make an event in a custom class,
> >>> and how do
> >>> >>>>I make a listener in
another class listen for the event?
> >>> >>>>
> >>> >>>>
> >>> >>>>EventBroadcaster in the
help docs seems to only show how
> >>> to use it
> >>> >>>>with Adobe classes and
components. Docs on listener are
> >>> the same.  I
> >>> >>>>know how to set up
listeners for other events, like
> >>> keypresses and
> >>> >>>>mouse rollovers.  Easy
enough.
> >>> >>>>But my problem is this
(see comments in code
> >>> >>>>below):
> >>> >>>>
> >>> >>>>class
com.boa.projects.iqrcgenerator.components.AdminData{
> >>> >>>>
> >>> >>>>
> >>> >>>>	private var
userData:Object;
> >>> >>>>
> >>> >>>>	public function
wsUserDataByLOB(lobDbId:Number):Void{
> >>> >>>>		var
getUserListResult:Object = new Object();
> >>> >>>>		getUserListResult =
> >>>
>>>>generatorWebService.GetUserList(lobDbId);
> >>>
>>>>		getUserListResult.onResult =
function(oUser){
> >>> >>>>			//this works fine,
> >>> >>>>
> >>> >>>>			//I can capture this
event result here,
> >>> >>>>			//but how do I notify
another class?
> >>> >>>>			//also what about scope
here?
> >>> >>>>			//how to set userData
as oUser result?
> >>> >>>>			//can I fire an event
in my AdminData
> >>> >>>>			//class from here?
> >>> >>>>		}
> >>> >>>>	}
> >>> >>>>
> >>> >>>>
> >>> >>>>	public function
getUserData():Object{
> >>> >>>>		//can't let user get
this data
> >>> >>>>		//until Webserive event
is done.
> >>> >>>>		return userData;
> >>> >>>>	}
> >>> >>>>}
> >>> >>>>
> >>> >>>>Thanks,
> >>> >>>>
> >>> >>>>
> >>> >>>>Jason Merrill
> >>> >>>>Bank of America
> >>> >>>>
> >>> >>>>Learning &
Organizational Effectiveness
> >>> >>>>
> >>> >>>>
> >>> >>>>
> >>> >>>>
> >>>
>>>>____________________________________________
___
> >>> >>>>Flashcoderschattyfig.figleaf.com
> >>> >>>>To change your
subscription options or search the archive:
> >>> >>>>http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
> >>> >>>>
> >>> >>>>Brought to you by Fig Leaf
Software Premier Authorized Adobe 
> >>> >>>>Consulting and Training http://www.figleaf.com 
> >>> >>>>http://training.figleaf.c
om
> >>> >>>>
> >>> >>>>This e-mail and its
attachments are intended only for the
> >>> use of the
> >>> >>>>addressee(s) and may
contain privileged, confidential or
> >>> proprietary
> >>> >>>>information. If you are
not the intended recipient, or
> >>> the employee
> >>> >>>>or agent responsible for
delivering the message to 
> the intended 
> >>> >>>>recipient, you are hereby
notified that any dissemination, 
> >>> >>>>distribution, displaying,
copying, or use of this
> >>information is
> >>> >>>>strictly prohibited. If
you have received this 
> communication in 
> >>> >>>>error, please inform the
sender immediately and delete
> >>> and destroy
> >>> >>>>any record of this
message. Thank you.
> >>>
>>>>____________________________________________
___
> >>> >>>>Flashcoderschattyfig.figleaf.com
> >>> >>>>To change your
subscription options or search the archive:
> >>> >>>>http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
> >>> >>>>
> >>> >>>>Brought to you by Fig Leaf
Software Premier Authorized Adobe 
> >>> >>>>Consulting and Training http://www.figleaf.com 
> >>> >>>>http://training.figleaf.c
om
> >>> >>>>
> >>>
>>_______________________________________________
> >>> >>Flashcoderschattyfig.figleaf.com
> >>> >>To change your subscription
options or search the archive:
> >>> >>http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
> >>> >>
> >>> >>Brought to you by Fig Leaf
Software Premier Authorized Adobe 
> >>> >>Consulting and Training http://www.figleaf.com 
> >>> >>http://training.figleaf.c
om
> >>> >>
> >>> >>
> >>> >>--
> >>> >>No virus found in this incoming
message.
> >>> >>Checked by AVG Free Edition.
> >>> >>Version: 7.1.412 / Virus Database:
268.18.0/689 - Release
> >>> >>Date: 2007-02-15
> >>> >> 
> >>> >>
> >>> >>--
> >>> >>No virus found in this outgoing
message.
> >>> >>Checked by AVG Free Edition.
> >>> >>Version: 7.1.412 / Virus Database:
268.18.0/689 - Release
> >>> >>Date: 2007-02-15
> >>> >> 
> >>> >>
> >>>
>>_______________________________________________
> >>> >>Flashcoderschattyfig.figleaf.com
> >>> >>To change your subscription
options or search the archive:
> >>> >>http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
> >>> >>
> >>> >>Brought to you by Fig Leaf
Software Premier Authorized Adobe 
> >>> >>Consulting and Training http://www.figleaf.com 
> >>> >>http://training.figleaf.c
om
> >>> >>
> >>>
_______________________________________________
> >>> Flashcoderschattyfig.figleaf.com
> >>> To change your subscription options or
search the archive:
> >>> http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
> >>> 
> >>> Brought to you by Fig Leaf Software
> >>> Premier Authorized Adobe Consulting and
Training 
> >>> http://www.figleaf.com http://training.figleaf.c
om
> >>> 
> >>
>
>>_______________________________________________
> >>Flashcoderschattyfig.figleaf.com
> >>To change your subscription options or search
the archive:
> >>http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
> >>
> >>Brought to you by Fig Leaf Software
> >>Premier Authorized Adobe Consulting and
Training 
> >>http://www.figleaf.com http://training.figleaf.c
om
> >>
> _______________________________________________
> Flashcoderschattyfig.figleaf.com
> To change your subscription options or search the
archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
> 
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training 
> http://www.figleaf.com http://training.figleaf.c
om 
> _______________________________________________
> Flashcoderschattyfig.figleaf.com
> To change your subscription options or search the
archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
> 
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training 
> http://www.figleaf.com http://training.figleaf.c
om
> 

_______________________________________________
Flashcoderschattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.c
om

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )