Re: [Flashcoders] accessing super fields

2007-08-20 Thread Pedro Taranto

I think you should use composition in this case, not inheritance.

--
Pedro Taranto

___
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] accessing super fields

2007-08-20 Thread Mark Winterhalder
Hi Hans,

'super' refers to the instance, but your static _test isn't part of
the instance, it is part of the class (technically, of the constructor
function). Imagine it as this.prototype.prototype, although it
technically isn't the same (well, maybe it is, I haven't tested it).
It behaves like super would, with the exception of the super() call of
the constructor.
To do what you want, super.constructor._test would probably work (but
again, I haven't tested it).

HTH,
Mark


On 8/20/07, Hans Wichman [EMAIL PROTECTED] wrote:
 Hi,

 lets say i have a superclass:

 class SuperClass {
  private var _test:String = null;
 }

 and a subclass:

 class SubClass {
 private function _testFunction () {
   super._test = foo;
 trace (super._test);
 }
 }


 this traces undefined.

 If I remove the super. it works, but I like to know when I'm referencing
 super class fields.

 It is fixed as well, when I nicely wrap the setting of _test in a function,
 as I should, but I'm still wondering why it fails.

 Any ideas?

 greetz
 JC
 ___
 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] accessing super fields

2007-08-20 Thread Hans Wichman
Hi Pedro,

the question is not about what is the best approach :), but about 'why the
heck isnt this working?'.
From a programming point of view my example is bad practice anyway

greetz
JC


On 8/20/07, Pedro Taranto [EMAIL PROTECTED] wrote:

 I think you should use composition in this case, not inheritance.

 --
 Pedro Taranto

 ___
 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] accessing super fields

2007-08-20 Thread Hans Wichman
Hi Mark,

why is it static? Its declared as private var not as private static var?

(if i remove super it works fine btw and for different instances with
different values).

greetz
JC


On 8/20/07, Mark Winterhalder [EMAIL PROTECTED] wrote:

 Hi Hans,

 'super' refers to the instance, but your static _test isn't part of
 the instance, it is part of the class (technically, of the constructor
 function). Imagine it as this.prototype.prototype, although it
 technically isn't the same (well, maybe it is, I haven't tested it).
 It behaves like super would, with the exception of the super() call of
 the constructor.
 To do what you want, super.constructor._test would probably work (but
 again, I haven't tested it).

 HTH,
 Mark


 On 8/20/07, Hans Wichman [EMAIL PROTECTED] wrote:
  Hi,
 
  lets say i have a superclass:
 
  class SuperClass {
   private var _test:String = null;
  }
 
  and a subclass:
 
  class SubClass {
  private function _testFunction () {
super._test = foo;
  trace (super._test);
  }
  }
 
 
  this traces undefined.
 
  If I remove the super. it works, but I like to know when I'm referencing
  super class fields.
 
  It is fixed as well, when I nicely wrap the setting of _test in a
 function,
  as I should, but I'm still wondering why it fails.
 
  Any ideas?
 
  greetz
  JC
  ___
  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] accessing super fields

2007-08-20 Thread Benny
Looks like you forgot to actually extend the superclass, try

class SubClass extends superclass {

- Benny

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Hans Wichman
Verzonden: maandag 20 augustus 2007 13:51
Aan: Flashcoders mailing list
Onderwerp: [Flashcoders] accessing super fields

Hi,

lets say i have a superclass:

class SuperClass {
 private var _test:String = null;
}

and a subclass:

class SubClass {
private function _testFunction () {
  super._test = foo;
trace (super._test);
}
}


this traces undefined.

If I remove the super. it works, but I like to know when I'm referencing
super class fields.

It is fixed as well, when I nicely wrap the setting of _test in a function,
as I should, but I'm still wondering why it fails.

Any ideas?

greetz
JC

___
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] accessing super fields

2007-08-20 Thread Hans Wichman
Hi Benny,

Sorry, copy paste error, of course the subclass looks like:  subclass
extends superclass etc

:)

Still no go :)

greetz
JC




On 8/20/07, Benny [EMAIL PROTECTED] wrote:

 Looks like you forgot to actually extend the superclass, try

 class SubClass extends superclass {

 - Benny

 -Oorspronkelijk bericht-
 Van: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Namens Hans Wichman
 Verzonden: maandag 20 augustus 2007 13:51
 Aan: Flashcoders mailing list
 Onderwerp: [Flashcoders] accessing super fields

 Hi,

 lets say i have a superclass:

 class SuperClass {
 private var _test:String = null;
 }

 and a subclass:

 class SubClass {
private function _testFunction () {
  super._test = foo;
 trace (super._test);
 }
 }


 this traces undefined.

 If I remove the super. it works, but I like to know when I'm referencing
 super class fields.

 It is fixed as well, when I nicely wrap the setting of _test in a
 function,
 as I should, but I'm still wondering why it fails.

 Any ideas?

 greetz
 JC

 ___
 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] accessing super fields

2007-08-20 Thread Benny
On a second look: first you don't need the super statement because
SuperClass' _test is already inherited by the SubClass and second super is
only supported with method members, see LiveDocs:
http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.h
tm?context=LiveDocs_Partsfile=1337.html

Greetz 
Benny

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Hans Wichman
Verzonden: maandag 20 augustus 2007 15:40
Aan: flashcoders@chattyfig.figleaf.com
Onderwerp: Re: [Flashcoders] accessing super fields

Hi Benny,

Sorry, copy paste error, of course the subclass looks like:  subclass
extends superclass etc

:)

Still no go :)

greetz
JC




On 8/20/07, Benny [EMAIL PROTECTED] wrote:

 Looks like you forgot to actually extend the superclass, try

 class SubClass extends superclass {

 - Benny

 -Oorspronkelijk bericht-
 Van: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Namens Hans Wichman
 Verzonden: maandag 20 augustus 2007 13:51
 Aan: Flashcoders mailing list
 Onderwerp: [Flashcoders] accessing super fields

 Hi,

 lets say i have a superclass:

 class SuperClass {
 private var _test:String = null;
 }

 and a subclass:

 class SubClass {
private function _testFunction () {
  super._test = foo;
 trace (super._test);
 }
 }


 this traces undefined.

 If I remove the super. it works, but I like to know when I'm referencing
 super class fields.

 It is fixed as well, when I nicely wrap the setting of _test in a
 function,
 as I should, but I'm still wondering why it fails.

 Any ideas?

 greetz
 JC

 ___
 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


__ NOD32 2470 (20070819) Informatie __

Dit bericht is gecontroleerd door het NOD32 Antivirus Systeem.
http://www.nod32.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] accessing super fields

2007-08-20 Thread Kerry Thompson
Hans Wichman wrote:
 lets say i have a superclass:
 
 class SuperClass {
  private var _test:String = null;
 }
 
 and a subclass:
 
 class SubClass {
 private function _testFunction () {
   super._test = foo;
 trace (super._test);
 }
 }
 
 
 this traces undefined.
 
 If I remove the super. it works, but I like to know when I'm referencing
 super class fields.

Actually, you're not referring to a superclass field in this instance. Your
subclass inherits all the methods and variables of the superclass, so _test
is a member of the object you create using SubClass.

You need to use super when you have overridden a method or variable. For
example, if you have an Init() method in both, and you want to run the
superclass's Init() first, you would call super.Init();

Otherwise, you treat inherited methods and vars as if they were part of the
subclass--which they are. They're just inherited, not declared.

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] accessing super fields

2007-08-20 Thread Hans Wichman
Hi,

okay thanks that comes as closest to an explanation as I'd like I
guess, but.

If I declare a method test() in superclass, i can call it from the subclass
using super.test().
Whether I have overwritten it or not.

So why doesnt the same go for fields.

I think its a bug to be honest.

As Benny said, you dont need to, no i know! But appearantly it works
different for fields than for methods.

greetz
JC


On 8/20/07, Kerry Thompson [EMAIL PROTECTED] wrote:

 Hans Wichman wrote:
  lets say i have a superclass:
 
  class SuperClass {
   private var _test:String = null;
  }
 
  and a subclass:
 
  class SubClass {
  private function _testFunction () {
super._test = foo;
  trace (super._test);
  }
  }
 
 
  this traces undefined.
 
  If I remove the super. it works, but I like to know when I'm referencing
  super class fields.

 Actually, you're not referring to a superclass field in this instance.
 Your
 subclass inherits all the methods and variables of the superclass, so
 _test
 is a member of the object you create using SubClass.

 You need to use super when you have overridden a method or variable. For
 example, if you have an Init() method in both, and you want to run the
 superclass's Init() first, you would call super.Init();

 Otherwise, you treat inherited methods and vars as if they were part of
 the
 subclass--which they are. They're just inherited, not declared.

 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] accessing super fields

2007-08-20 Thread Benny
 As Benny said, you dont need to, no i know! But appearantly it works
different for fields than for methods.
It actually doesn't work *different* but it doesn't work *per design* for
fields. 
The docs (see the link I provided) clearly state that it is only supported
with methods. There is no mention of that it should only work with
overridden methods but that's of course the logical place where you would
use super (and of course in the constructor). 

- Benny 


___
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] accessing super fields

2007-08-20 Thread Hans Wichman
sorry i missed that part, thanks benny:)

On 8/20/07, Benny [EMAIL PROTECTED] wrote:

  As Benny said, you dont need to, no i know! But appearantly it works
 different for fields than for methods.
 It actually doesn't work *different* but it doesn't work *per design* for
 fields.
 The docs (see the link I provided) clearly state that it is only supported
 with methods. There is no mention of that it should only work with
 overridden methods but that's of course the logical place where you would
 use super (and of course in the constructor).

 - Benny


 ___
 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] accessing super fields

2007-08-20 Thread Mark Winterhalder
On 8/20/07, Hans Wichman [EMAIL PROTECTED] wrote:
 Hi Mark,

 why is it static?

Uhm... because I didn't read properly, sorry. :/

 Its declared as private var not as private static var?

I could swear it read 'static var' when I first read the mail. Now you
made Gmail change it some how. :)

Anyway, interesting question. I think Kerry's explanation is
conceptually right, and even technically correct for AS3 as far as I
understand the inner workings so far.
But in AS2, when you do

class SuperClass {
 private var _test:String = null;
}

technically you set SuperClass.prototype._test = null. So to do what
you want to do, you can access it as this.prototype.prototype._test
from within your child class instance.

HTH,
Mark
___
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] accessing super fields

2007-08-20 Thread Kerry Thompson
Hans Wichman wrote:
 
 okay thanks that comes as closest to an explanation as I'd like I
 guess, but.
 
 If I declare a method test() in superclass, i can call it from the
subclass
 using super.test().
 Whether I have overwritten it or not.
 
 So why doesnt the same go for fields.
 
 I think its a bug to be honest.

Not really. Methods and variables are different. The code for an overridden
method still exists, and can be accessed with super. 

At the end of the day, a variable is just a place in memory--the compiler
controls how much and where, but it's still just memory. When you override a
variable, you are replacing the superclass's variable.

There is one rather odd way of accessing an overridden superclass variable,
though. If a property is initialized in the superclass body, outside of a
method or constructor, then that value is accessible via super. Here's an
untested e-mail example:

class foo
{
   public var x:Number = 10;
   public var y:Number;

   public function foo //constructor
   {
  y = 10;
   }
}

class bar extends foo
{
   public var x:Number = 20;
   public var y:Number;

   public function bar //constructor
   {
  y = 20;
  trace x;   // shows 20
  trace super.x; // shows 10
  trace y;   // shows 20
  trace super.y; // undefined
   }
}


___
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] accessing super fields

2007-08-20 Thread Ron Wheeler



Hans Wichman wrote:

Hi,

okay thanks that comes as closest to an explanation as I'd like I
guess, but.

If I declare a method test() in superclass, i can call it from the subclass
using super.test().
Whether I have overwritten it or not.

So why doesnt the same go for fields.

  

Think about what this would mean.

How would the methods in the superclass ever reference any variable?. 
Which _test would it use? How would the super class know that you had 
overriden _test?


You would have to override every method to make such an idea work. Then 
you do not have extends anymore.


Take a second and think about this. It can not work any other way.

Ron



I think its a bug to be honest.

As Benny said, you dont need to, no i know! But appearantly it works
different for fields than for methods.

greetz
JC


On 8/20/07, Kerry Thompson [EMAIL PROTECTED] wrote:
  

Hans Wichman wrote:


lets say i have a superclass:

class SuperClass {
 private var _test:String = null;
}

and a subclass:

class SubClass {
private function _testFunction () {
  super._test = foo;
trace (super._test);
}
}


this traces undefined.

If I remove the super. it works, but I like to know when I'm referencing
super class fields.
  

Actually, you're not referring to a superclass field in this instance.
Your
subclass inherits all the methods and variables of the superclass, so
_test
is a member of the object you create using SubClass.

You need to use super when you have overridden a method or variable. For
example, if you have an Init() method in both, and you want to run the
superclass's Init() first, you would call super.Init();

Otherwise, you treat inherited methods and vars as if they were part of
the
subclass--which they are. They're just inherited, not declared.

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


  

___
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] accessing super fields

2007-08-20 Thread elibol
In as3, variables (properties and methods) that are private are not visible
to subclasses, protected are accessible with this and super (as should be),
and public are accessible with this and super too (kind of obvious). as3
definitely rocks when it comes to variable scoping.

On 8/20/07, Mark Winterhalder [EMAIL PROTECTED] wrote:

 On 8/20/07, Hans Wichman [EMAIL PROTECTED] wrote:
  Hi Mark,
 
  why is it static?

 Uhm... because I didn't read properly, sorry. :/

  Its declared as private var not as private static var?

 I could swear it read 'static var' when I first read the mail. Now you
 made Gmail change it some how. :)

 Anyway, interesting question. I think Kerry's explanation is
 conceptually right, and even technically correct for AS3 as far as I
 understand the inner workings so far.
 But in AS2, when you do

 class SuperClass {
 private var _test:String = null;
 }

 technically you set SuperClass.prototype._test = null. So to do what
 you want to do, you can access it as this.prototype.prototype._test
 from within your child class instance.

 HTH,
 Mark
 ___
 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] accessing super fields

2007-08-20 Thread Hans Wichman
yep they should have copied that from java years ago :))

On 8/20/07, elibol [EMAIL PROTECTED] wrote:

 In as3, variables (properties and methods) that are private are not
 visible
 to subclasses, protected are accessible with this and super (as should
 be),
 and public are accessible with this and super too (kind of obvious). as3
 definitely rocks when it comes to variable scoping.

 On 8/20/07, Mark Winterhalder [EMAIL PROTECTED] wrote:
 
  On 8/20/07, Hans Wichman [EMAIL PROTECTED] wrote:
   Hi Mark,
  
   why is it static?
 
  Uhm... because I didn't read properly, sorry. :/
 
   Its declared as private var not as private static var?
 
  I could swear it read 'static var' when I first read the mail. Now you
  made Gmail change it some how. :)
 
  Anyway, interesting question. I think Kerry's explanation is
  conceptually right, and even technically correct for AS3 as far as I
  understand the inner workings so far.
  But in AS2, when you do
 
  class SuperClass {
  private var _test:String = null;
  }
 
  technically you set SuperClass.prototype._test = null. So to do what
  you want to do, you can access it as this.prototype.prototype._test
  from within your child class instance.
 
  HTH,
  Mark
  ___
  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] accessing super fields

2007-08-20 Thread Hans Wichman
well just to be clear, i wasnt planning on overriding _test :) the example
was bad enough practice in itself.
It was more about a readability issues, like some like to do this. etc for
every variable.

On 8/20/07, Ron Wheeler [EMAIL PROTECTED] wrote:



 Hans Wichman wrote:
  Hi,
 
  okay thanks that comes as closest to an explanation as I'd like I
  guess, but.
 
  If I declare a method test() in superclass, i can call it from the
 subclass
  using super.test().
  Whether I have overwritten it or not.
 
  So why doesnt the same go for fields.
 
 
 Think about what this would mean.

 How would the methods in the superclass ever reference any variable?.
 Which _test would it use? How would the super class know that you had
 overriden _test?

 You would have to override every method to make such an idea work. Then
 you do not have extends anymore.

 Take a second and think about this. It can not work any other way.

 Ron


  I think its a bug to be honest.
 
  As Benny said, you dont need to, no i know! But appearantly it works
  different for fields than for methods.
 
  greetz
  JC
 
 
  On 8/20/07, Kerry Thompson [EMAIL PROTECTED] wrote:
 
  Hans Wichman wrote:
 
  lets say i have a superclass:
 
  class SuperClass {
   private var _test:String = null;
  }
 
  and a subclass:
 
  class SubClass {
  private function _testFunction () {
super._test = foo;
  trace (super._test);
  }
  }
 
 
  this traces undefined.
 
  If I remove the super. it works, but I like to know when I'm
 referencing
  super class fields.
 
  Actually, you're not referring to a superclass field in this instance.
  Your
  subclass inherits all the methods and variables of the superclass, so
  _test
  is a member of the object you create using SubClass.
 
  You need to use super when you have overridden a method or variable.
 For
  example, if you have an Init() method in both, and you want to run the
  superclass's Init() first, you would call super.Init();
 
  Otherwise, you treat inherited methods and vars as if they were part of
  the
  subclass--which they are. They're just inherited, not declared.
 
  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
 
 
 
 ___
 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] accessing super fields

2007-08-20 Thread elibol
Seems to perfect sense in as3...

On 8/20/07, Ron Wheeler [EMAIL PROTECTED] wrote:



 Hans Wichman wrote:
  Hi,
 
  okay thanks that comes as closest to an explanation as I'd like I
  guess, but.
 
  If I declare a method test() in superclass, i can call it from the
 subclass
  using super.test().
  Whether I have overwritten it or not.
 
  So why doesnt the same go for fields.
 
 
 Think about what this would mean.

 How would the methods in the superclass ever reference any variable?.
 Which _test would it use? How would the super class know that you had
 overriden _test?

 You would have to override every method to make such an idea work. Then
 you do not have extends anymore.

 Take a second and think about this. It can not work any other way.

 Ron


  I think its a bug to be honest.
 
  As Benny said, you dont need to, no i know! But appearantly it works
  different for fields than for methods.
 
  greetz
  JC
 
 
  On 8/20/07, Kerry Thompson [EMAIL PROTECTED] wrote:
 
  Hans Wichman wrote:
 
  lets say i have a superclass:
 
  class SuperClass {
   private var _test:String = null;
  }
 
  and a subclass:
 
  class SubClass {
  private function _testFunction () {
super._test = foo;
  trace (super._test);
  }
  }
 
 
  this traces undefined.
 
  If I remove the super. it works, but I like to know when I'm
 referencing
  super class fields.
 
  Actually, you're not referring to a superclass field in this instance.
  Your
  subclass inherits all the methods and variables of the superclass, so
  _test
  is a member of the object you create using SubClass.
 
  You need to use super when you have overridden a method or variable.
 For
  example, if you have an Init() method in both, and you want to run the
  superclass's Init() first, you would call super.Init();
 
  Otherwise, you treat inherited methods and vars as if they were part of
  the
  subclass--which they are. They're just inherited, not declared.
 
  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
 
 
 
 ___
 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] accessing super fields

2007-08-20 Thread elibol
make*...

On 8/20/07, elibol [EMAIL PROTECTED] wrote:

 Seems to perfect sense in as3...

 On 8/20/07, Ron Wheeler [EMAIL PROTECTED] wrote:
 
 
 
  Hans Wichman wrote:
   Hi,
  
   okay thanks that comes as closest to an explanation as I'd like I
   guess, but.
  
   If I declare a method test() in superclass, i can call it from the
  subclass
   using super.test().
   Whether I have overwritten it or not.
  
   So why doesnt the same go for fields.
  
  
  Think about what this would mean.
 
  How would the methods in the superclass ever reference any variable?.
  Which _test would it use? How would the super class know that you had
  overriden _test?
 
  You would have to override every method to make such an idea work. Then
  you do not have extends anymore.
 
  Take a second and think about this. It can not work any other way.
 
  Ron
 
 
   I think its a bug to be honest.
  
   As Benny said, you dont need to, no i know! But appearantly it works
   different for fields than for methods.
  
   greetz
   JC
  
  
   On 8/20/07, Kerry Thompson [EMAIL PROTECTED] wrote:
  
   Hans Wichman wrote:
  
   lets say i have a superclass:
  
   class SuperClass {
private var _test:String = null;
   }
  
   and a subclass:
  
   class SubClass {
   private function _testFunction () {
 super._test = foo;
   trace (super._test);
   }
   }
  
  
   this traces undefined.
  
   If I remove the super. it works, but I like to know when I'm
  referencing
   super class fields.
  
   Actually, you're not referring to a superclass field in this
  instance.
   Your
   subclass inherits all the methods and variables of the superclass, so
 
   _test
   is a member of the object you create using SubClass.
  
   You need to use super when you have overridden a method or variable.
  For
   example, if you have an Init() method in both, and you want to run
  the
   superclass's Init() first, you would call super.Init();
  
   Otherwise, you treat inherited methods and vars as if they were part
  of
   the
   subclass--which they are. They're just inherited, not declared.
  
   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
  
  
  
  ___
  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] accessing super fields

2007-08-20 Thread Kerry Thompson
Hans Wichman wrote:
 
 yep they should have copied that [private and protected] from java years
ago :))

Or from C++ years before Java was born ^_^

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