List Info

Thread: limits to AS2 levels of OOP class inheritance?




limits to AS2 levels of OOP class inheritance?
user name
2007-01-08 06:34:14
Hi all,

A quick OOP question... is there a limit in AS2.0 on how
many levels of
inheritance can be done?
My latest class is not recognizing any of the methods from
it superclass',
even though the compiler doesn't raise any errors.

Here is the inheritance tree (I'm making a game, as you can
guess):

- MovieClip (Flash built-in class)
- Sprite extends MovieClip
- Player extends Sprite
- Enemy extends Player

Sprite has a method called "render", Player has a
method called "fire".
So I would expect that both render() and fire() are
accessible to Enemy
without having to redeclare them (actually, render() works
in Player without
defining it).

But nothing works in Enemy. I've tried redefining
"render" and calling other
functions from it (in case the Enemy instance wasn't
called).
And debugging I've found out that I do get to Enemy and my
new render()
method, but any calls to other methods are just ignored
[even using
super.method()].
Stranger still, every compiles without problems. So it seems
like a problem
at runtime.

Has anybody seen this before, and hopefully has a way to
work around it?

Thanks,
Gerard.
_______________________________________________
Flashcoderschattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.c
om
limits to AS2 levels of OOP class inheritance?
user name
2007-01-08 07:46:34
You might want to post some code.
At least from the start of the class with the imports to the
constructor 
and the method.
The code that calls the shows the error would help.

Ron

Newsdee wrote:
> Hi all,
>
> A quick OOP question... is there a limit in AS2.0 on
how many levels of
> inheritance can be done?
> My latest class is not recognizing any of the methods
from it 
> superclass',
> even though the compiler doesn't raise any errors.
>
> Here is the inheritance tree (I'm making a game, as you
can guess):
>
> - MovieClip (Flash built-in class)
> - Sprite extends MovieClip
> - Player extends Sprite
> - Enemy extends Player
>
> Sprite has a method called "render", Player
has a method called "fire".
> So I would expect that both render() and fire() are
accessible to Enemy
> without having to redeclare them (actually, render()
works in Player 
> without
> defining it).
>
> But nothing works in Enemy. I've tried redefining
"render" and calling 
> other
> functions from it (in case the Enemy instance wasn't
called).
> And debugging I've found out that I do get to Enemy and
my new render()
> method, but any calls to other methods are just ignored
[even using
> super.method()].
> Stranger still, every compiles without problems. So it
seems like a 
> problem
> at runtime.
>
> Has anybody seen this before, and hopefully has a way
to work around it?
>
> Thanks,
> Gerard.
> _______________________________________________
> Flashcoderschattyfig.figleaf.com
> To change your subscription options or search the
archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.c
om
>
>
_______________________________________________
Flashcoderschattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.c
om
Re: limits to AS2 levels of OOP class inheritance?
user name
2007-02-14 06:54:35
Newsdee or anyone ... any ideas concerning this kind of
problem ? im having
a similar inheritance problem where class B extends class A
and the compiler
ignores it. class A isnt class B.__proto__ and instead class
B.__proto__
equals Object ???
anyone ever encounter such a bug ?

On 10/01/07, Newsdee <newsdeegmail.com> wrote:
>
> Update... tried adding a get function, but it still
doesn't work. Here's
> my
> code:
>
> In Game.as:
> private static var mainGame:Game;
> static function getGame():Game {
>         if(mainGame == undefined) {
>             mainGame = new Game();
>         }
>         return mainGame;
>     }
>
> In Collider.as:
> var walls_mc:MovieClip =
Game.getGame().level.walls_mc;
>
>
> It looks like a Flash bug to me at this point... but
how can I work around
> it?
>
>
>
> On 1/10/07, Newsdee <newsdeegmail.com> wrote:
> >
> > Here's how mainGame is defined. Maybe I need to
make mainGame private
> and
> > use a get function?
> >
> >
> _______________________________________________
> Flashcoderschattyfig.figleaf.com
> To change your subscription options or search the
archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.c
om
>
_______________________________________________
Flashcoderschattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs

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

Re: limits to AS2 levels of OOP class inheritance?
user name
2007-02-14 17:06:35
Could be a related issue. You can try a few things:

- Clear the ASO cache and recompile.
- Force the type via a casting var a:ClassA =
ClassA(yourVar)
- Ensure your files are not on a network drive (had a weird
bug with classes
once and that fixed it!)
- Refactor to simpler class relationships (worst case but it
did the trick
for me - had to duplicate code, ewww).

Regards,
Newsdee.


On 2/14/07, Dani Bacon <danibacongmail.com> wrote:
>
> Newsdee or anyone ... any ideas concerning this kind of
problem ? im
> having
> a similar inheritance problem where class B extends
class A and the
> compiler
> ignores it. class A isnt class B.__proto__ and instead
class B.__proto__
> equals Object ???
> anyone ever encounter such a bug ?
>
> On 10/01/07, Newsdee <newsdeegmail.com> wrote:
> >
> > Update... tried adding a get function, but it
still doesn't work. Here's
> > my
> > code:
> >
> > In Game.as:
> > private static var mainGame:Game;
> > static function getGame():Game {
> >         if(mainGame == undefined) {
> >             mainGame = new Game();
> >         }
> >         return mainGame;
> >     }
> >
> > In Collider.as:
> > var walls_mc:MovieClip =
Game.getGame().level.walls_mc;
> >
> >
> > It looks like a Flash bug to me at this point...
but how can I work
> around
> > it?
> >
> >
> >
> > On 1/10/07, Newsdee <newsdeegmail.com> wrote:
> > >
> > > Here's how mainGame is defined. Maybe I need
to make mainGame private
> > and
> > > use a get function?
> > >
> > >
> > _______________________________________________
> > Flashcoderschattyfig.figleaf.com
> > To change your subscription options or search the
archive:
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
> >
> > Brought to you by Fig Leaf Software
> > Premier Authorized Adobe Consulting and Training
> > http://www.figleaf.com
> > http://training.figleaf.c
om
> >
> _______________________________________________
> Flashcoderschattyfig.figleaf.com
> To change your subscription options or search the
archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.c
om
>
_______________________________________________
Flashcoderschattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs

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

Re: limits to AS2 levels of OOP class inheritance?
user name
2007-02-15 02:20:34
Hey Steven / Newsdee. Thx.

Newsdee : i tried deleting cache [FlashDevelop] / ASOs
[Flash IDE] before
and it didn't help. I don't see how casting can solve the
problem, it looks
like the compiler itself is not acknowledging an inheritance
connection, and
i am not using any special drive config.

Steven: you guys seem to be doing great work . I can
refactor into
composition but that would probably be my last resort.
especially since
these classes extends MovieClip and the movie clips
themselves sit on stage
already [to simplify design issues .. lots of mcs on a world
map kinda
thing].

heres more info on my code:

i am trying to compile a flash8 project and the compiler
seems to break an
inheritance connection between 2 classes.
movieclips are on stage and their library symbols are linked
to the Country
class.
this worked but after making a few minor changes to
AbstractMarker [added a
method] the compiler suddenly stopped recognizing the
inheritance connection
between BoundedMarker and AbstractMarker.
code :

class marker.AbstractMarker extends RadioButton implements
Marker {

    function AbstractMarker() {
    }

    // methods

    public function testMethodBaseClass() {}

}

import org.as2lib.env.reflect.ReflectUtil; // just so you
know ReflectUtil
is from as2lib

class marker.BoundedMarker extends AbstractMarker {

    function BoundedMarker() {
        super();

       
trace(ReflectUtil.getTypeNameForInstance(this.__proto__));
                 // traces BoundedMarker [since
movieclips are based on Country]

       
trace(ReflectUtil.getTypeNameForInstance(this.__proto__.__pr
oto__));
// traces Object [!! ignores AbstractMarker]

        trace(this.test2);
// traces [type Function]

        trace(this.testMethodBaseClass);
// traces undefined

        // more code of course ...

    }

    public function test2() {}

}

class marker.Country extends BoundedMarker {

    private function Country() {
    }

}

and

trace(mc instanceof Country) is true
trace(mc instanceof BoundedMarker) is true

but

trace(mc instanceof AbstractMarker) is false

im using FlashDevelop and MTASC but compiling via the flash8
env as well.

I have actually made some wierd progress last night. What i
did is moved
AbstractMarker out of its package. compiling it using MMC
[flash ide]. then
compiling it using MTASC [through FlashDevelop], this time
it worked. and
then moving it back into the marker package and recompiling
with MMC and
then MTASC and it worked.

so i believe the solution is a combination of the following
: a compiler /
a bug /  flashdevelop /  packages /  imports.

anyone any ideas ? how do i even start finding the problem ?
is this some
kind of flash bug ?

regards and sorry for the long post
Danix


On 15/02/07, Steven Sacks | BLITZ <ssacksblitzagency.com> wrote:
>
> > - Refactor to simpler class relationships (worst
case but it
> > did the trick for me - had to duplicate code,
ewww).
>
> You could use Composition instead, which reduces the
need for normal
> class inheritance.
> _______________________________________________
> Flashcoderschattyfig.figleaf.com
> To change your subscription options or search the
archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.c
om
>
_______________________________________________
Flashcoderschattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs

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

RE: limits to AS2 levels of OOP class inheritance?
country flaguser name
2007-02-15 16:14:05
I was going to recommend trying to compile with MTASC as its
strictness
often exposes mistakes that the IDE won't catch.  Since
you're already
doing that, I suggest you do some Debugging 101 and make a
trivial
example to see if you can replicate it outside your
application
environment.

_______________________________________________
Flashcoderschattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs

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

Re: limits to AS2 levels of OOP class inheritance?
user name
2007-02-18 03:55:38
hey Steven thanks for you help. well right now the problem
happened only
once more. This time it broke the inheritance connection
between [Country]
and [BoundedMarker]. I went through the same bizzar process
of moving the
[BoundedMarker] class out of its package .. compiling with
MMC, then MTASC
and back into the package and compiling again and it fixed
it again. Since
then it hasnt happened again, so i am crossing my fingers
for now.

If anyone has encountered anything of the sort, i am very
interested to hear
about it.
THX

On 2/16/07, Steven Sacks | BLITZ <ssacksblitzagency.com> wrote:
>
> I was going to recommend trying to compile with MTASC
as its strictness
> often exposes mistakes that the IDE won't catch.  Since
you're already
> doing that, I suggest you do some Debugging 101 and
make a trivial
> example to see if you can replicate it outside your
application
> environment.
>
> _______________________________________________
> Flashcoderschattyfig.figleaf.com
> To change your subscription options or search the
archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.c
om
>
_______________________________________________
Flashcoderschattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs

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

[1-7]

about | contact  Other archives ( Real Estate discussion Medical topics )