overridden function not being called

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

overridden function not being called

edA-qa mort-ora-y
I have a situation where an overridden function is simply not being
called in Flash 9 -- the base class version is called.  I am unable to
recreate a small example, and have never seen this behaviour before.

Essentially:

class Base { public function func() { return "hello"; } }
class Derive { override public function func() { return "bye"; } }

...
var b = new Derive();
trace( b.func() ); //prints "hello" !!!
...

Anybody have any ideas on what could be wrong, or have you seen this
problem before?!

The function definitely has the correct name, since otherwise override
complains. It also certainly has the same signature -- just testing if
it doesn't an error at compile time is produced.  There is no other
class with the same name laying around -- if I change something in
another function, or add a trace, it works, so it is certainly using the
correct file!

Even within the constructor of "Derive" the error is present!

Any clues, tips, hints or anything would be helpful as this is obviously
driving me insane.

--
edA-qa mort-ora-y
http://disemia.com/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Have a look in my brain:
        http://brainbrain.eu/
       
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Sign: Please digitally sign your emails.
Encrypt: I'm also happy to receive encrypted mail.


--
haXe - an open source web programming language
http://haxe.org

signature.asc (260 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: overridden function not being called

Ian Thomas
On Sat, Nov 22, 2008 at 2:44 PM, edA-qa mort-ora-y <[hidden email]> wrote:

>
> Even within the constructor of "Derive" the error is present!

I haven't encountered that in haXe, but actually in C++ (casting my
memory back!) the wrong version of the function being called in the
constructor is a common issue, due to virtual function tables not
being properly set up at that point. Good C++ style suggests you don't
call any of the class's methods in the constructor to get around that
very problem.

I doubt that's the issue here - but even so, do you get the same
problem _outside_ the constructor?

Ian

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: overridden function not being called

Ali Jaya Meilio Lie
In reply to this post by edA-qa mort-ora-y
edA-qa mort-ora-y wrote:

> I have a situation where an overridden function is simply not being
> called in Flash 9 -- the base class version is called.  I am unable to
> recreate a small example, and have never seen this behaviour before.
>
> Essentially:
>
> class Base { public function func() { return "hello"; } }
> class Derive { override public function func() { return "bye"; } }
>
> ...
> var b = new Derive();
> trace( b.func() ); //prints "hello" !!!
> ...
>
> Anybody have any ideas on what could be wrong, or have you seen this
> problem before?!
>
> The function definitely has the correct name, since otherwise override
> complains. It also certainly has the same signature -- just testing if
> it doesn't an error at compile time is produced.  There is no other
> class with the same name laying around -- if I change something in
> another function, or add a trace, it works, so it is certainly using the
> correct file!
>
> Even within the constructor of "Derive" the error is present!
>
> Any clues, tips, hints or anything would be helpful as this is obviously
> driving me insane.
>
>  
try change this code "class Derive" to "class Derive extends Base"
hope it helps :D

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: overridden function not being called

edA-qa mort-ora-y
In reply to this post by Ian Thomas
Ian Thomas wrote:
> On Sat, Nov 22, 2008 at 2:44 PM, edA-qa mort-ora-y <[hidden email]> wrote:
>> Even within the constructor of "Derive" the error is present!
> I doubt that's the issue here - but even so, do you get the same
> problem _outside_ the constructor?

Yes, that is where the problem originally occurred (outside the
constructor), testing within the constructor was just a test.

I finally got it working again, but I'm no entirely sure how: I just
kept moving functions around and rebuilding my SWFs and it worked.  I
suppose if it happens again I'll try harder to find our what the problem
was.


--
edA-qa mort-ora-y
http://disemia.com/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Have a look in my brain:
        http://brainbrain.eu/
       
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Sign: Please digitally sign your emails.
Encrypt: I'm also happy to receive encrypted mail.


--
haXe - an open source web programming language
http://haxe.org

signature.asc (260 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: overridden function not being called

Baluta Cristian
maybe your swf was from cache, if you test them in localhost like i always do, but i also add a random number after ".swf?" to not have this problem.

On Sun, Nov 23, 2008 at 9:47 AM, edA-qa mort-ora-y <[hidden email]> wrote:
Ian Thomas wrote:
> On Sat, Nov 22, 2008 at 2:44 PM, edA-qa mort-ora-y <[hidden email]> wrote:
>> Even within the constructor of "Derive" the error is present!
> I doubt that's the issue here - but even so, do you get the same
> problem _outside_ the constructor?

Yes, that is where the problem originally occurred (outside the
constructor), testing within the constructor was just a test.

I finally got it working again, but I'm no entirely sure how: I just
kept moving functions around and rebuilding my SWFs and it worked.  I
suppose if it happens again I'll try harder to find our what the problem
was.


--
edA-qa mort-ora-y
http://disemia.com/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Have a look in my brain:
       http://brainbrain.eu/

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Sign: Please digitally sign your emails.
Encrypt: I'm also happy to receive encrypted mail.


--
haXe - an open source web programming language
http://haxe.org



--
Cristi
www.ralcr.com

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: overridden function not being called

edA-qa mort-ora-y
I had thought of that. I was making other changes to the class which
were being seen however.

I usually test in the standalone player's anyways, they don't use any
caching.

In any case it works now.  But if I do see it again I'll try to track it
down -- I hope it was just a dumb mistake on my part though.


Baluta Cristian wrote:

> maybe your swf was from cache, if you test them in localhost like i
> always do, but i also add a random number after ".swf?" to not have this
> problem.
>
> On Sun, Nov 23, 2008 at 9:47 AM, edA-qa mort-ora-y <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Ian Thomas wrote:
>     > On Sat, Nov 22, 2008 at 2:44 PM, edA-qa mort-ora-y
>     <[hidden email] <mailto:[hidden email]>> wrote:
>     >> Even within the constructor of "Derive" the error is present!
>     > I doubt that's the issue here - but even so, do you get the same
>     > problem _outside_ the constructor?
>
>     Yes, that is where the problem originally occurred (outside the
>     constructor), testing within the constructor was just a test.
>
>     I finally got it working again, but I'm no entirely sure how: I just
>     kept moving functions around and rebuilding my SWFs and it worked.  I
>     suppose if it happens again I'll try harder to find our what the problem
>     was.
>
>
>     --
>     edA-qa mort-ora-y
>     http://disemia.com/
>     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>
>     Have a look in my brain:
>            http://brainbrain.eu/
>
>     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>     Sign: Please digitally sign your emails.
>     Encrypt: I'm also happy to receive encrypted mail.
>
>
>     --
>     haXe - an open source web programming language
>     http://haxe.org
>
>
>
>
> --
> Cristi
> www.ralcr.com <http://www.ralcr.com>
>

--
edA-qa mort-ora-y
http://disemia.com/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Have a look in my brain:
        http://brainbrain.eu/
       
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Sign: Please digitally sign your emails.
Encrypt: I'm also happy to receive encrypted mail.


--
haXe - an open source web programming language
http://haxe.org

signature.asc (260 bytes) Download Attachment