Re: [Flashcoders] overwriting a class

2007-01-16 Thread Thomas Fowler

Yes, but it's actually, overRIDING ;)

- Original Message -
From: Merrill, Jason [EMAIL PROTECTED]
To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com
Sent: Tuesday, January 16, 2007 12:32 PM
Subject: RE: [Flashcoders] overwriting a class

Flash allows deleting classes. But maybe I am not 
aware of some resulting problems.

Is is ok in terms of good programing practices ?


No, don't delete anything.  Why not use method overwriting?

class myBaseClass(){
function speak(){
trace(greeting)
}
}

class myHelloClass extends myBaseClass{
function speak(){
trace(Hello)
}
}

class myWhatsUpClass extends myBaseClass{
function speak(){
trace(What's Up?)
}
}

then create instances of the ones you want to use


Jason Merrill
Bank of America 
Learning  Organizational Effectiveness









-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf 
Of BlackMail

Sent: Tuesday, January 16, 2007 1:05 PM
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] overwriting a class

Hi,

I am looking for advice about swapping classes of the same 
name but using different methods.


Let's consider three classes:

class SomeClass
{
   public function meth()
   {
  trace(meth of skin SomeClass VERSION 0);
   }
}
//
class SomeClass
{
   public function meth()
   {
   trace(meth of skin SomeClass VERSION 1);
   }
   
}

//
class SomeClass
{
   public function meth()
   {
   trace(meth of skin SomeClass VERSION 2);
   someNewMethod();
   
   }

   private function someNewMethod()
   {
   trace(something new...);
   }
   
}


The first of those is imported into a main.swf file. I can make an
instance:

var Q:SomeClass = new SomeClass();
Q.meth()   // traces :  meth of skin SomeClass VERSION 0

The next two classes are imported in: one storage1.swf and 
the other, storage2.swf 

Both .swf files are loaded into the main.swf. First the 
storage1.swf and next storage2.swf. But before loading, I 
delete the class:


trace(SomeClass) // out: [type Function] delete SomeClass
trace(SomeClass) // out: undefined

And after loading the storage1.swf I can make again an 
instance of SomeClass:


var Q1:SomeClass = new SomeClass();
Q1.meth() // traces:   meth of skin SomeClass VERSION 1

It uses a new version of meth().

Now I delete the SomeClass class:

delete SomeClass

... and load somewhere into the stage of main.swf the 
storage2.swf file. After loading the first one I can make a 
new instance of

SomeClass:

var Q2:SomeClass = new SomeClass();
Q2.meth() // traces:   meth of skin SomeClass VERSION 2
 //   something new...


and so on, deleting an loading a new version

Now the question:
The same class name, the same method name, eventually other, 
new methods of the same class and deleting the class 
Could this be a good way to overwrite classes ? I tested it 
and works. Flash allows deleting classes. But maybe I am not 
aware of some resulting problems.

Is is ok in terms of good programing practices ?

Thanks,

Greg






--
Lufa dla generala. Zobacz  http://link.interia.pl/f19e1


___
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] overwriting a class

2007-01-16 Thread slangeberg

I would suggest implementing interfaces, as a good practice:

interface ISpeakable
{
   function speak();
}

class myClass implements ISpeakable
{
   function speak() {}
}

this lets you pass around instances that implement your interface and to
change behaviors at runtime, such as:

class TestClass
{
   private var speaker:ISpeakable;

  public function setSpeaker( spkr:ISpeakable ) {
 speaker = spkr;
  }
}

Not sure it's close to what you're looking for, but can be good practice in
large apps.

-Scott

On 1/16/07, Merrill, Jason [EMAIL PROTECTED] wrote:


Flash allows deleting classes. But maybe I am not
aware of some resulting problems.
Is is ok in terms of good programing practices ?

No, don't delete anything.  Why not use method overwriting?

class myBaseClass(){
function speak(){
trace(greeting)
}
}

class myHelloClass extends myBaseClass{
function speak(){
trace(Hello)
}
}

class myWhatsUpClass extends myBaseClass{
function speak(){
trace(What's Up?)
}
}

then create instances of the ones you want to use


Jason Merrill
Bank of America
Learning  Organizational Effectiveness







-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of BlackMail
Sent: Tuesday, January 16, 2007 1:05 PM
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] overwriting a class

Hi,

I am looking for advice about swapping classes of the same
name but using different methods.

Let's consider three classes:

class SomeClass
{
public function meth()
{
   trace(meth of skin SomeClass VERSION 0);
}
}
//
class SomeClass
{
public function meth()
{
trace(meth of skin SomeClass VERSION 1);
}

}
//
class SomeClass
{
public function meth()
{
trace(meth of skin SomeClass VERSION 2);
someNewMethod();

}
private function someNewMethod()
{
trace(something new...);
}

}

The first of those is imported into a main.swf file. I can make an
instance:

var Q:SomeClass = new SomeClass();
Q.meth()   // traces :  meth of skin SomeClass VERSION 0

The next two classes are imported in: one storage1.swf and
the other, storage2.swf

Both .swf files are loaded into the main.swf. First the
storage1.swf and next storage2.swf. But before loading, I
delete the class:

trace(SomeClass) // out: [type Function] delete SomeClass
trace(SomeClass) // out: undefined

And after loading the storage1.swf I can make again an
instance of SomeClass:

var Q1:SomeClass = new SomeClass();
Q1.meth() // traces:   meth of skin SomeClass VERSION 1

It uses a new version of meth().

Now I delete the SomeClass class:

delete SomeClass

... and load somewhere into the stage of main.swf the
storage2.swf file. After loading the first one I can make a
new instance of
SomeClass:

var Q2:SomeClass = new SomeClass();
Q2.meth() // traces:   meth of skin SomeClass VERSION 2
  //   something new...


and so on, deleting an loading a new version

Now the question:
The same class name, the same method name, eventually other,
new methods of the same class and deleting the class
Could this be a good way to overwrite classes ? I tested it
and works. Flash allows deleting classes. But maybe I am not
aware of some resulting problems.
Is is ok in terms of good programing practices ?

Thanks,

Greg






--
Lufa dla generala. Zobacz  http://link.interia.pl/f19e1


___
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





--

: : ) Scott
___
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] overwriting a class

2007-01-16 Thread Hans Wichman

Hi,

because in some large systems you have to load a ton of swfs, classes get
updated in ways you did not forsee, and thus you have different versions of
the same class hanging around, if you did not think about preventing this
upfront. That is different from an architecture in which you wish to add new
features by subclassing etc.

greetz
JC


On 1/16/07, Merrill, Jason [EMAIL PROTECTED] wrote:


(I meant method overriding not method overwriting)

Jason Merrill
Bank of America
Learning  Organizational Effectiveness




___
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] overwriting a class

2007-01-16 Thread Merrill, Jason
because in some large systems you have to load a ton of swfs, 
classes get updated in ways you did not forsee, and thus you 
have different versions of the same class hanging around,

That's why I don't have tons of swfs in my projects, at least not ones
that all use the same class.  Why would you have tons of swfs in the
same project which all call the same class?  Wouldn't you just want to
have a base .swf that has all the class definitions?  I guess what
you're describing is a problem I haven't encountered before.  I usually
have one .swf which has class definititions, then load in other external
media as necessary.

Jason Merrill
Bank of America 
Learning  Organizational Effectiveness
 
 
 
___
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