Re: [Flashcoders] AS3 Events, Delegates and passing parameters

2007-09-03 Thread Geografiek

A backward OOP-developer? (sometimes also called a 'pooh'-developer) :)
Willem

Op 2-sep-2007, om 18:46 heeft Kerry Thompson het volgende geschreven:


EKA+ wrote:


The event model concept it's not very for a newbee POO
developper


I understand your point, and agree.

I must have been asleep at the switch, though. What is a POO  
developer?


Cordially,

Kerry Thompson



=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Geografiek is a Dutch, Utrecht-based map and chart design company.
Willem van den Goorbergh can be contacted by telephone: (+31) 
30-2719512 or cell phone: (+31)6-26372378

or by fax: (+31)302719687
snail mail: Hooghiemstraplein 89 3514 AX UTRECHT
Visit our website at: http://www.geografiek.nl
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=


___
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] AS3 Events, Delegates and passing parameters

2007-09-03 Thread Anggie Bratadinata

What is a POO developer?


POOP (Professional Object-oriented Programmer) ?

:-D j/k ( hey, it's Sunday! )

--
Anggie Bratadinata
www.masputih.com
I N D O N E S I A

___
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] AS3 Events, Delegates and passing parameters

2007-09-03 Thread eka
Hello :)

Little error in my previous message :

The event model concept it's not very easy for a newbee OOP developper.

For me with flash (AS1, AS2..) we can develop application with old school
coding or with advanced OOP concept. In AS3 the event model and other native
tools use more OOP concept.

Sorry for the POO notation.. i'm french and in french we write POO and not
OOP ^_^

EKA+ :)


2007/9/2, Kerry Thompson [EMAIL PROTECTED]:

 EKA+ wrote:

  The event model concept it's not very for a newbee POO
  developper

 I understand your point, and agree.

 I must have been asleep at the switch, though. What is a POO developer?

 Cordially,

 Kerry Thompson


 ___
 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] AS3 Events, Delegates and passing parameters

2007-09-03 Thread Muzak
 I must have been asleep at the switch, though. What is a POO developer?

Someone who knows OOP backwards ;-)

regards,
Muzak 


___
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] AS3 Events, Delegates and passing parameters

2007-09-03 Thread Andreas Rønning
I think, in the end, we are all poo developers

- A

- Original Message -
From: Muzak [EMAIL PROTECTED]
To: flashcoders@chattyfig.figleaf.com
Sent: Sunday, September 2, 2007 11:17:16 PM (GMT+0100) Europe/Berlin
Subject: Re: [Flashcoders] AS3 Events, Delegates and passing parameters

 I must have been asleep at the switch, though. What is a POO developer?

Someone who knows OOP backwards ;-)

regards,
Muzak 


___
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] AS3 Events, Delegates and passing parameters

2007-09-03 Thread Kerry Thompson
EKA+ wrote:

 Sorry for the POO notation.. i'm french and in french we write POO and not
 OOP ^_^

Thanks. I was just curious to know if I was missing something.

It occurred to me (and apparently to others) that my question could have 
scatological connotations. That was not my intention (though we did get a 
couple of amusing responses).

BTW, this isn't Flash-related, but I would never apologize for your English. 
The fact that you speak at least two languages impresses me. Most Americans 
only speak English, and we're in no position to criticize somebody like you for 
an accent, written or spoken.

Now, back to Flash before we get chastised by the moderator.

Cordially,

Kerry Thompson


___
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] AS3 Events, Delegates and passing parameters

2007-09-02 Thread eka
Hello :)

it's not a problem ;) only a supplement to highlight this feature.

For me i think the clone() method call alway in the dispatch event isn't the
better fast solution to dispatch the events ... but it's an other story ;)

EKA+ :)



2007/9/1, Muzak [EMAIL PROTECTED]:

 I don't see why this is a problem as it's properly documented:

 http://livedocs.adobe.com/flash/9.0/main/0138.html

 quote
 Event class utility methods

 There are two utility methods in the Event class. The clone() method
 allows you to create copies of an event object. The toString()
 method allows you to generate a string representation of the properties of
 an event object along with their values. Both of these
 methods are used internally by the event model system, but are exposed to
 developers for general use.
 For advanced developers creating subclasses of the Event class, you must
 override and implement versions of both utility methods to
 ensure that the event subclass will work properly.
 /quote

 quote
 when creating an Event subclass you must override the clone() and
 toString() methods to provide functionality specific to the
 subclass.
 /quote

 I've read about it first in the Flex 2 docs though (which is alot better
 than the Flash docs IMO):
 http://livedocs.adobe.com/flex/201/html/createevents_140_5.html

 quote
 You are required to override the Event.clone() method in your subclass.
 The clone() method returns a cloned copy of the event object
 by setting the type property and any new properties in the clone.
 Typically, you define the clone() method to return an event
 instance created with the new operator.

 /quote

 regards,
 Muzak

 - Original Message -
 From: eka [EMAIL PROTECTED]
 To: flashcoders@chattyfig.figleaf.com
 Sent: Saturday, September 01, 2007 8:54 AM
 Subject: Re: [Flashcoders] AS3 Events, Delegates and passing parameters


  Hello :)
 
  The events are cloned the second time in the dispatchEvent method.
 
  My article about this problem in french :
 
 http://www.ekameleon.net/blog/index.php?2007/08/25/75--as3-event-class-and-the-clone-method
 
  EKA+ :)
 
  2007/9/1, T. Michael Keesey [EMAIL PROTECTED]:
 
  On 8/31/07, Mark Carolin [EMAIL PROTECTED] wrote:
   I believe you could pass a custom Event with all the properties you
  want.
 
  Yes, but one word of warning about extending Event: be sure you
  override Event.clone() so that it returns an instance of your class!
  (Events are cloned when they are dispatched.)
 
  --
  T. Michael Keesey


 ___
 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] AS3 Events, Delegates and passing parameters

2007-09-02 Thread eka
Hello :)

for me it's exist three developpers :

1 - the beginners ... all informations it's important for it.

2 - The AS1/AS2 developper who read the list to understand the AS3 and not
develop with AS3 for the moment... All discussion over all difference with
the AS2 can be important.

3 - The developpers who develop in AS3 and read the reference ;)

For the 3 developpers the discussion about a problem or not it's always
important :) The event model concept it's not very for a newbee POO
developper and don't forget... we can't should be aware of all :)

EKA+ :)



2007/9/2, T. Michael Keesey [EMAIL PROTECTED]:

 On 9/1/07, Muzak [EMAIL PROTECTED] wrote:
  I don't see why this is a problem as it's properly documented:
 
  http://livedocs.adobe.com/flash/9.0/main/0138.html

 I wasn't saying it was a problem, just that a developer should be aware of
 it.

 --
 Mike Keesey
 ___
 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] AS3 Events, Delegates and passing parameters

2007-09-02 Thread Kerry Thompson
EKA+ wrote:

 The event model concept it's not very for a newbee POO
 developper 

I understand your point, and agree.

I must have been asleep at the switch, though. What is a POO developer?

Cordially,

Kerry Thompson


___
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] AS3 Events, Delegates and passing parameters

2007-09-01 Thread T. Michael Keesey
On 8/31/07, Mark Carolin [EMAIL PROTECTED] wrote:
 I believe you could pass a custom Event with all the properties you want.

Yes, but one word of warning about extending Event: be sure you
override Event.clone() so that it returns an instance of your class!
(Events are cloned when they are dispatched.)

-- 
T. Michael Keesey
Director of Technology
Exopolis, Inc.
2894 Rowena Avenue Ste. B
Los Angeles, California 90039
___
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] AS3 Events, Delegates and passing parameters

2007-09-01 Thread eka
Hello :)

The events are cloned the second time in the dispatchEvent method.

My article about this problem in french :
http://www.ekameleon.net/blog/index.php?2007/08/25/75--as3-event-class-and-the-clone-method

EKA+ :)

2007/9/1, T. Michael Keesey [EMAIL PROTECTED]:

 On 8/31/07, Mark Carolin [EMAIL PROTECTED] wrote:
  I believe you could pass a custom Event with all the properties you
 want.

 Yes, but one word of warning about extending Event: be sure you
 override Event.clone() so that it returns an instance of your class!
 (Events are cloned when they are dispatched.)

 --
 T. Michael Keesey
 Director of Technology
 Exopolis, Inc.
 2894 Rowena Avenue Ste. B
 Los Angeles, California 90039
 ___
 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] AS3 Events, Delegates and passing parameters

2007-09-01 Thread Muzak
I don't see why this is a problem as it's properly documented:

http://livedocs.adobe.com/flash/9.0/main/0138.html

quote
Event class utility methods

There are two utility methods in the Event class. The clone() method allows you 
to create copies of an event object. The toString() 
method allows you to generate a string representation of the properties of an 
event object along with their values. Both of these 
methods are used internally by the event model system, but are exposed to 
developers for general use.
For advanced developers creating subclasses of the Event class, you must 
override and implement versions of both utility methods to 
ensure that the event subclass will work properly.
/quote

quote
when creating an Event subclass you must override the clone() and toString() 
methods to provide functionality specific to the 
subclass.
/quote

I've read about it first in the Flex 2 docs though (which is alot better than 
the Flash docs IMO):
http://livedocs.adobe.com/flex/201/html/createevents_140_5.html

quote
You are required to override the Event.clone() method in your subclass. The 
clone() method returns a cloned copy of the event object 
by setting the type property and any new properties in the clone. Typically, 
you define the clone() method to return an event 
instance created with the new operator.

/quote

regards,
Muzak

- Original Message - 
From: eka [EMAIL PROTECTED]
To: flashcoders@chattyfig.figleaf.com
Sent: Saturday, September 01, 2007 8:54 AM
Subject: Re: [Flashcoders] AS3 Events, Delegates and passing parameters


 Hello :)

 The events are cloned the second time in the dispatchEvent method.

 My article about this problem in french :
 http://www.ekameleon.net/blog/index.php?2007/08/25/75--as3-event-class-and-the-clone-method

 EKA+ :)

 2007/9/1, T. Michael Keesey [EMAIL PROTECTED]:

 On 8/31/07, Mark Carolin [EMAIL PROTECTED] wrote:
  I believe you could pass a custom Event with all the properties you
 want.

 Yes, but one word of warning about extending Event: be sure you
 override Event.clone() so that it returns an instance of your class!
 (Events are cloned when they are dispatched.)

 --
 T. Michael Keesey


___
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] AS3 Events, Delegates and passing parameters

2007-08-31 Thread Mark Carolin
I believe you could pass a custom Event with all the properties you want.

On 8/25/07, Muzak [EMAIL PROTECTED] wrote:

 There should never be any need for using a Delegate class in AS3 and
 passing arguments along with a Delegate in AS2.

 regards,
 Muzak

 - Original Message -
 From: Matthias Dittgen [EMAIL PROTECTED]
 To: flashcoders@chattyfig.figleaf.com
 Sent: Saturday, August 25, 2007 6:01 PM
 Subject: Re: [Flashcoders] AS3 Events, Delegates and passing parameters


  Hi Dimitrios,
 
  I stumbled over the same questions only some hours ago, and after
  spending a lot of time searching the web, mailinglists and forums I
  finally found the new Delegate class from Ian Thomas here:
 
 http://wildwinter.blogspot.com/2007/04/come-back-delegate-all-is-forgiven.html
  @Ian, when reading: Great work!
  It's especially useful, when porting from AS2 and rewriting Events or
  targets is not an option.
 
  hth,
  Matthias


 ___
 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




-- 
323-573-4352(c)

AIM:bulbousbeans
MSN:[EMAIL PROTECTED]
___
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] AS3 Events, Delegates and passing parameters

2007-08-30 Thread elibol
You can also use the Loader.name property to identify the image you're
loading.

To get a nicely encapsulated solution, you might want to consider
instantiating a new Loader object for each image. I would use weak
references (addEventListener(event, method, false, 0, true)). This way,
when the calling function is complete, there will be no references to the
Loader once the load method dispatches an event, and it will be marked for
garbage collection.

On 8/27/07, Dimitrios Bendilas [EMAIL PROTECTED] wrote:

 Of course!

 I can't believe it was that simple. I guess I wasn't used subclassing
 native
 classes so much.

 Thanks a lot Muzak. Troy, thanks for your reply too, I think what Muzak
 said
 was what I was looking for.

 Best regards,
 Dimitrios



 - Original Message -
 From: Muzak [EMAIL PROTECTED]
 To: flashcoders@chattyfig.figleaf.com
 Sent: Saturday, August 25, 2007 1:56 AM
 Subject: Re: [Flashcoders] AS3 Events, Delegates and passing parameters


  Create a custom class, extending Loader, that has an .id property.
 
  regards,
  Muzak
 
  - Original Message -
  From: Dimitrios Bendilas [EMAIL PROTECTED]
  To: flashcoders@chattyfig.figleaf.com
  Sent: Friday, August 24, 2007 9:42 PM
  Subject: [Flashcoders] AS3 Events, Delegates and passing parameters
 
 
  Hello everyone,
 
  I am just starting working with AS3 after many years working with AS1
 and
  AS2.
 
  I am trying to rebuild a Game/App development framework I had built in
  AS2 into AS3
  and I want to make sure I get it right from scratch.
 
  All these years I had been working with Delegates and specifically a
  custom Delegate class I had writen
  which allowed the user to pass extra parameters.
 
  Now for my new framework, I want to use the new extended event model of
  AS3, with addEventListener
  and subclassed Event objects. The problem is that I cannot find a
  solution that does not uses a Delegate object.
  I know that in AS3 callbacks are now executed with the proper scope, so
  this does not require a delegate as before,
  but I still haven't figured out how to pass parameters.
 
  Specifically, I cannot do this in situations like the following:
  Thank you,
 
  Dimitrios
 
 
  ___
  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


Re: [Flashcoders] AS3 Events, Delegates and passing parameters

2007-08-27 Thread Dimitrios Bendilas

Of course!

I can't believe it was that simple. I guess I wasn't used subclassing native 
classes so much.


Thanks a lot Muzak. Troy, thanks for your reply too, I think what Muzak said 
was what I was looking for.


Best regards,
Dimitrios



- Original Message - 
From: Muzak [EMAIL PROTECTED]

To: flashcoders@chattyfig.figleaf.com
Sent: Saturday, August 25, 2007 1:56 AM
Subject: Re: [Flashcoders] AS3 Events, Delegates and passing parameters



Create a custom class, extending Loader, that has an .id property.

regards,
Muzak

- Original Message - 
From: Dimitrios Bendilas [EMAIL PROTECTED]

To: flashcoders@chattyfig.figleaf.com
Sent: Friday, August 24, 2007 9:42 PM
Subject: [Flashcoders] AS3 Events, Delegates and passing parameters



Hello everyone,

I am just starting working with AS3 after many years working with AS1 and 
AS2.


I am trying to rebuild a Game/App development framework I had built in 
AS2 into AS3

and I want to make sure I get it right from scratch.

All these years I had been working with Delegates and specifically a 
custom Delegate class I had writen

which allowed the user to pass extra parameters.

Now for my new framework, I want to use the new extended event model of 
AS3, with addEventListener
and subclassed Event objects. The problem is that I cannot find a 
solution that does not uses a Delegate object.
I know that in AS3 callbacks are now executed with the proper scope, so 
this does not require a delegate as before,

but I still haven't figured out how to pass parameters.

Specifically, I cannot do this in situations like the following:
Thank you,

Dimitrios



___
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] AS3 Events, Delegates and passing parameters

2007-08-25 Thread Matthias Dittgen
Hi Dimitrios,

I stumbled over the same questions only some hours ago, and after
spending a lot of time searching the web, mailinglists and forums I
finally found the new Delegate class from Ian Thomas here:
http://wildwinter.blogspot.com/2007/04/come-back-delegate-all-is-forgiven.html
@Ian, when reading: Great work!
It's especially useful, when porting from AS2 and rewriting Events or
targets is not an option.

hth,
Matthias


2007/8/25, Troy Rollins [EMAIL PROTECTED]:

 On Aug 24, 2007, at 3:42 PM, Dimitrios Bendilas wrote:

  Now for my new framework, I want to use the new extended event
  model of AS3, with addEventListener
  and subclassed Event objects. The problem is that I cannot find a
  solution that does not uses a Delegate object.
  I know that in AS3 callbacks are now executed with the proper
  scope, so this does not require a delegate as before,
  but I still haven't figured out how to pass parameters.

 If I understand the issue you're having, I think maybe your AS2
 experience is clouding the issue for you. In general, what I do in
 AS3 is to create a class which represents a value object, and also
 create a custom event subclass to carry an instance of that value
 object within the event itself.

 The event broadcaster packages the value object with properties that
 represent the parameters you want to pass, and then wraps it within
 the new event type and dispatches it. An event listener catches the
 event, and unwraps the value object as needed, effectively using its
 properties as parameters.

 --
 Troy
 RPSystems, Ltd.
 http://www.rpsystems.net


 ___
 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] AS3 Events, Delegates and passing parameters

2007-08-25 Thread Muzak
There should never be any need for using a Delegate class in AS3 and passing 
arguments along with a Delegate in AS2.

regards,
Muzak

- Original Message - 
From: Matthias Dittgen [EMAIL PROTECTED]
To: flashcoders@chattyfig.figleaf.com
Sent: Saturday, August 25, 2007 6:01 PM
Subject: Re: [Flashcoders] AS3 Events, Delegates and passing parameters


 Hi Dimitrios,

 I stumbled over the same questions only some hours ago, and after
 spending a lot of time searching the web, mailinglists and forums I
 finally found the new Delegate class from Ian Thomas here:
 http://wildwinter.blogspot.com/2007/04/come-back-delegate-all-is-forgiven.html
 @Ian, when reading: Great work!
 It's especially useful, when porting from AS2 and rewriting Events or
 targets is not an option.

 hth,
 Matthias


___
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] AS3 Events, Delegates and passing parameters

2007-08-24 Thread Dimitrios Bendilas

Hello everyone,

I am just starting working with AS3 after many years working with AS1 and 
AS2.


I am trying to rebuild a Game/App development framework I had built in AS2 
into AS3

and I want to make sure I get it right from scratch.

All these years I had been working with Delegates and specifically a custom 
Delegate class I had writen

which allowed the user to pass extra parameters.

Now for my new framework, I want to use the new extended event model of AS3, 
with addEventListener
and subclassed Event objects. The problem is that I cannot find a solution 
that does not uses a Delegate object.
I know that in AS3 callbacks are now executed with the proper scope, so this 
does not require a delegate as before,

but I still haven't figured out how to pass parameters.

Specifically, I cannot do this in situations like the following:
(please note that a lot of things were deleted in this example, so that you 
don't have to read a longer text)



package com.zefxis.solarwind2 {

public class ImgLoader() {

/*
 Various lines of code that initialize the class
 and load an external .xml file (images.xml), which triggers xmlLoaded 
when

 the loading is complete.

 images.xml contains information for every image that needs to be loaded
*/

private function xmlLoaded(e:Event):void {
 // parse xml data
 // for every image, get its id, the file path
 // and a bunch of other information which is not shown here

// loop through each node and load the corresponding image
 var id:String; // = blah blah
 var path:String; // = blah blah
 loadImage(id, path);
 // end loop
}

private function loadImage(id:String, file:String):void {

 // 1st Option
 Solution using just a method reference. No parameters can be passed
 loader.contentLoaderInfo.addEventListener(Event.INIT, imageLoaded);

 /* 2nd option
 The only solution I know of that passes parameters, but it includes a 
Delegate object
 loader.contentLoaderInfo.addEventListener(Event.INIT, 
Delegate.create(imageLoaded, id));

 */

 loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, 
ioErrorHandler);


 loader.load(new URLRequest(file));
}

private function imageLoaded(event:Event, id:String):void {
 var loader:Loader = LoaderInfo(event.target).loader;
 var bitmapData:BitmapData = Bitmap(loader.content).bitmapData;

 // Store the loaded bitmapData in an object
 // I need to have its id, so that I know which image I am storing, how to 
manipulate it (e.g. slice it)
 // and be able to use it later in my application by calling it with its 
id.

 bitmaps[id].bitmap = bitmapData;

 loadedImages++;

 if (loadedImages == totalImages)
  dispatchEvent(new Event(Event.COMPLETE));
}

}

}




Well, that's it.

I am puzzled. I tried to find help online but couldn't find anything useful.
I am somehow convinced that I can achieve what I'm after without using a 
Delegate,
(which is not the cleanest thing to do as I understand), and that the new 
Event model in AS3

provides all the tools I need.

Am I right?

Thank you,

Dimitrios


-
Dimitrios Bendilas
Game Designer/Lead Developer
Total Eclipse Games
www.totaleclipsegames.com

Web Consultant
ZEFXIS
www.zefxis.gr


___
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