[Flashcoders] Class broadcasting Question...

2007-05-21 Thread eric e. dolecki

This may sound daft, and perhaps not the way to go, but here is what I am
trying to do (AS2):

I have a class that I would like timeline code to instantiate and call a
method on. I would like the class to broadcast back to whomever is
listening...

simplified class:

import mx.utils.Delegate;
class Login extends AsBroadcaster
{
   function Login()
   {

   };

   public function foo( sValue:String ):Void
   {
   // stuff
   broadcastMessage( attempt, bValue );
   };
}

timeline code (not class-based):

var bar:Login = new Login();
bar.foo( test string );

function attempt( bValue:Boolean ):Void
{
trace( the result is  + bValue );
}

===

Obviously I am missing some pieces here, any quick insights?

- Eric
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

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


Re: [Flashcoders] Class broadcasting Question...

2007-05-21 Thread Alain Rousseau

You forgot to add a listener ! :)

in the timeline  code :

bar.AddListener(this);
and it will listen to all event  broadcasted by your Login Class. Note 
that it's AddListener not AddEventListener as you're using AsBroadcaster.


As easy as that !

HTH

Alain

eric e. dolecki wrote:

This may sound daft, and perhaps not the way to go, but here is what I am
trying to do (AS2):

I have a class that I would like timeline code to instantiate and call a
method on. I would like the class to broadcast back to whomever is
listening...

simplified class:

import mx.utils.Delegate;
class Login extends AsBroadcaster
{
   function Login()
   {

   };

   public function foo( sValue:String ):Void
   {
   // stuff
   broadcastMessage( attempt, bValue );
   };
}

timeline code (not class-based):

var bar:Login = new Login();
bar.foo( test string );

function attempt( bValue:Boolean ):Void
{
trace( the result is  + bValue );
}

===

Obviously I am missing some pieces here, any quick insights?

- Eric
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

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




___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

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


Re: [Flashcoders] Class broadcasting Question...

2007-05-21 Thread sean
Hi Eric,
   first suggestion. Unless there is a really good reason not to, loose
the AsBroadcaster class. It is unreliable and has been well an truely
replaced by EventDispatcher. You can import this into your class, set
up an event dispatcher Object, add event listeners and then
dispatchEvent in the same place that you presently 'broadcastMessage',
only it'll work ;)

The basic lines of code are below, sorry, don't have more time to set out
a class for ya ;)

import mx.events.EventDispatcher;

public var objBroadcaster:Object;

objBroadcaster.addEventListener(markerPressed, Delegate.create(this,
this.markerPressed));

objBroadcaster.dispatchEvent({type:eventName, param:param});


In my example the event dispatcher line (the last line of code above) is
part of a generic event dispatcher function which accepts the event type
and any parameters as part of the function call. You could hard code it.

Good luck

FlashCoder.net

 This may sound daft, and perhaps not the way to go, but here is what I am
 trying to do (AS2):

 I have a class that I would like timeline code to instantiate and call a
 method on. I would like the class to broadcast back to whomever is
 listening...

 simplified class:

 import mx.utils.Delegate;
 class Login extends AsBroadcaster
 {
 function Login()
 {

 };

 public function foo( sValue:String ):Void
 {
 // stuff
 broadcastMessage( attempt, bValue );
 };
 }

 timeline code (not class-based):

 var bar:Login = new Login();
 bar.foo( test string );

 function attempt( bValue:Boolean ):Void
 {
  trace( the result is  + bValue );
 }

 ===

 Obviously I am missing some pieces here, any quick insights?

 - Eric
 ___
 Flashcoders@chattyfig.figleaf.com
 To change your subscription options or search the archive:
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

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



___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

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


Re: [Flashcoders] Class broadcasting Question...

2007-05-21 Thread eric e. dolecki

YES YES YES YES YES - thank you. I am a moron  forgot completely about
EventDispatcher. Thats the ticket and its SO much better :)

On 5/21/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:


Hi Eric,
   first suggestion. Unless there is a really good reason not to, loose
the AsBroadcaster class. It is unreliable and has been well an truely
replaced by EventDispatcher. You can import this into your class, set
up an event dispatcher Object, add event listeners and then
dispatchEvent in the same place that you presently 'broadcastMessage',
only it'll work ;)

The basic lines of code are below, sorry, don't have more time to set out
a class for ya ;)

import mx.events.EventDispatcher;

public var objBroadcaster:Object;

objBroadcaster.addEventListener(markerPressed, Delegate.create(this,
this.markerPressed));

objBroadcaster.dispatchEvent({type:eventName, param:param});


In my example the event dispatcher line (the last line of code above) is
part of a generic event dispatcher function which accepts the event type
and any parameters as part of the function call. You could hard code it.

Good luck

FlashCoder.net

 This may sound daft, and perhaps not the way to go, but here is what I
am
 trying to do (AS2):

 I have a class that I would like timeline code to instantiate and call a
 method on. I would like the class to broadcast back to whomever is
 listening...

 simplified class:

 import mx.utils.Delegate;
 class Login extends AsBroadcaster
 {
 function Login()
 {

 };

 public function foo( sValue:String ):Void
 {
 // stuff
 broadcastMessage( attempt, bValue );
 };
 }

 timeline code (not class-based):

 var bar:Login = new Login();
 bar.foo( test string );

 function attempt( bValue:Boolean ):Void
 {
  trace( the result is  + bValue );
 }

 ===

 Obviously I am missing some pieces here, any quick insights?

 - Eric
 ___
 Flashcoders@chattyfig.figleaf.com
 To change your subscription options or search the archive:
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

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



___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

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


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

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