OK, super () is used in subclasses . when you extend a class and set some of
it's functions to be public or protected you can then access them and modify
in the subclass . What super() super does , it actually calls the original
function in the superclass that is the class being extended.
Example:
 I for example have a class for my personal use that is called AwayTemplate
. I wrote it so I can setup Away3D scene quickly without the need each time
to write all the regular setup code . So i created AwayTemplate where all
the function like onEnterFrame are protected . now when I create a subclass
using this template and want to add some additional stuff into onEnterFrame
function that runs on enter frame event I should overrride the super
function becasue by default it does only the stuff I set in super class that
is to render view .
So you should do it like that:
override protected function onEnterFrame(e:Event):void{
  super.onEnterFrame(e);

}

the thing is that when you override a function you need to call it on super
class if you wish it still to initiate the way it was defined in super class
. OK ? Here in the example I call the onEnterFrame  in super class by
super.onEnterFrame(e). so all the code that was defined in that function on
super class is still executed . That is essential part of inheritance
approach . Now many times you can see just super() in constructor . Telling
you the truth you don't really need it there . it would work fine without it
there .


Hope it cleared things out

Cheers


On Mon, May 10, 2010 at 1:14 AM, CyberHawk <[email protected]> wrote:

> I do have a few books on AS3 but i did not find a decent explination
> on the super() function or when to use it. As far as event listeners
> go, i saw it on some post here i believe. I was just trying to
> everything i can to optimise the code and find simple answers and the
> questions i ask are related to actionscript AND since Away3D is
> written to use actionscript, the questions are related... :)
>
> Anyways thank you....i will search around and see what i can find....
>
>
> On May 9, 4:54 pm, Michael Iv <[email protected]> wrote:
> > Doode, the questions you ask are related to ActionScript language in
> > general . super() is inheritance related stuff. I suggest you to by a
> > book by name Object Oriented ActionScript. There you will find all the
> > answers.
> >
> > Sent from my iPhone
> >
> > On May 9, 2010, at 10:07 PM, CyberHawk <[email protected]> wrote:
> >
> >
> >
> > > Just a few questions that is more geared toward optimizing the AS3 and
> > > Away3D in any way possible:
> >
> > > I read somewhere where someone said the general rule of thumb about
> > > even listeners is when you add an even listener, you should also
> > > remove it if you are done with it otherwise you could get into the
> > > issue of memory leaks.
> >
> > > So, my question is if you add the following event listeners to the
> > > stage for example:
> >
> > >    stage.addEventListener(KeyboardEvent.KEY_DOWN,     someFunction());
> > >    stage.addEventListener(KeyboardEvent.KEY_UP,     someFunction());
> > >    stage.addEventListener(MouseEvent.MOUSE_WHEEL, someFunction());
> > >    stage.addEventListener(MouseEvent.MOUSE_DOWN,  someFunction());
> > >    stage.addEventListener(MouseEvent.MOUSE_UP,        someFunction());
> >
> > > If that rule of thumb is true, than does it mean it is mainly
> > > applicable when event listeners are added to objects and removing it
> > > when not used as removing it from the stage means you remove the
> > > ability to interact with flash??
> >
> > > One other SIDE question, I have seen the function "super()" used in
> > > several classes, I believe at the top inside the constructor of that
> > > class, what is it for, where and when would you use it, and how do you
> > > use it?
> >
> > > Thank you very much....- Hide quoted text -
> >
> > - Show quoted text -
>



-- 
Michael Ivanov ,Programmer
Neurotech Solutions Ltd.
Flex|Air |3D|Unity|
www.neurotechresearch.com
Tel:054-4962254
[email protected]
[email protected]

Reply via email to