super() constructor not being called

View: New views
6 Messages — Rating Filter:   Alert me  

super() constructor not being called

by Diego Essaya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I'm working on a project using both the Flash IDE and the MTASC
compiler.  The problem is, I'm having different results when compiling
with MMC and with MTASC.

I have a derived class that calls super() in its constructor.
Something like this:

class Derived extends SomeBaseClass
{
    function Derived(param:Number)
    {
        super(someStaticFunction(), param);
        ...
    }
}

When I compile this with MMC, the super() function is not being
called.  When I compile it with MTASC it works correctly.

But there is another problem:  if I compile it with MMC first and then
with MTASC (using the swf file as input), the class does not seem to
be updated, thus the super() constructor is not called.  In order to
make it work I have to:

1) comment all references to the Derived class
2) compile the swf with MMC
3) uncomment
4) compile with MTASC

This is a pain in the ass... Has anyone had the same problem? Is there
something I'm doing wrong?

Thanks in advance,
Diego

--
MTASC : no more coffee break while compiling

RE: super() constructor not being called

by PiR Durand :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi

if your someStaticFunction is not overwritted in your sub-class, the just
call someStaticFunction(param)
else SomeBaseClass.someStaticFunction(param)... this works if it's actually
a static function
otherwise try super.someFunction(param)

hope it helps
++
PiR



-----Message d'origine-----
De : mtasc-bounces@...
[mailto:mtasc-bounces@...] De la part de Diego Essaya
Envoyé : mercredi 27 juin 2007 17:34
À : mtasc@...
Objet : [mtasc] super() constructor not being called

Hi all,

I'm working on a project using both the Flash IDE and the MTASC
compiler.  The problem is, I'm having different results when compiling
with MMC and with MTASC.

I have a derived class that calls super() in its constructor.
Something like this:

class Derived extends SomeBaseClass
{
    function Derived(param:Number)
    {
        super(someStaticFunction(), param);
        ...
    }
}

When I compile this with MMC, the super() function is not being
called.  When I compile it with MTASC it works correctly.

But there is another problem:  if I compile it with MMC first and then
with MTASC (using the swf file as input), the class does not seem to
be updated, thus the super() constructor is not called.  In order to
make it work I have to:

1) comment all references to the Derived class
2) compile the swf with MMC
3) uncomment
4) compile with MTASC

This is a pain in the ass... Has anyone had the same problem? Is there
something I'm doing wrong?

Thanks in advance,
Diego

--
MTASC : no more coffee break while compiling



--
MTASC : no more coffee break while compiling

Re: super() constructor not being called

by Diego Essaya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Uhm... this does not fix the problem.  The static function belongs to
the Derived class.  I tried these methods:

1)

class Derived extends SomeBaseClass
{
  function Derived(param:Number)
  {
    super(someStaticFunction(), param);
  }

  static function someStaticFunction():MovieClip
  {
     ...
     return someMovieClip;
  }
}

and somewhere else:  d = new Derived(3);

2) This other method also failed:

class Derived extends SomeBaseClass
{
  function Derived(mc:MovieClip, param:Number)
  {
    super(mc, param);
  }

  static function someStaticFunction():MovieClip
  {
     ...
     return someMovieClip;
  }
}

and creating the instance with:  d = new
Derived(Derived.someStaticFunction(), 3);

In both cases super() is not being called when compiling with MMC.

On 6/27/07, PiR Durand <mailinglists@...> wrote:

> hi
>
> if your someStaticFunction is not overwritted in your sub-class, the just
> call someStaticFunction(param)
> else SomeBaseClass.someStaticFunction(param)... this works if it's actually
> a static function
> otherwise try super.someFunction(param)
>
> hope it helps
> ++
> PiR
>
>
>
> -----Message d'origine-----
> De: mtasc-bounces@...
> [mailto:mtasc-bounces@...] De la part de Diego Essaya
> Envoyé: mercredi 27 juin 2007 17:34
> À: mtasc@...
> Objet: [mtasc] super() constructor not being called
>
> Hi all,
>
> I'm working on a project using both the Flash IDE and the MTASC
> compiler.  The problem is, I'm having different results when compiling
> with MMC and with MTASC.
>
> I have a derived class that calls super() in its constructor.
> Something like this:
>
> class Derived extends SomeBaseClass
> {
>     function Derived(param:Number)
>     {
>         super(someStaticFunction(), param);
>         ...
>     }
> }
>
> When I compile this with MMC, the super() function is not being
> called.  When I compile it with MTASC it works correctly.
>
> But there is another problem:  if I compile it with MMC first and then
> with MTASC (using the swf file as input), the class does not seem to
> be updated, thus the super() constructor is not called.  In order to
> make it work I have to:
>
> 1) comment all references to the Derived class
> 2) compile the swf with MMC
> 3) uncomment
> 4) compile with MTASC
>
> This is a pain in the ass... Has anyone had the same problem? Is there
> something I'm doing wrong?
>
> Thanks in advance,
> Diego
>
> --
> MTASC : no more coffee break while compiling
>
>
>
> --
> MTASC : no more coffee break while compiling
>

--
MTASC : no more coffee break while compiling

RE: super() constructor not being called

by PiR Durand :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I don't really understand what you're trying to do... but the problem seems
to be in the order of instanciation of the class
did you try tu put it as a variable inside the constructor?


class Derived extends SomeBaseClass
{
  function Derived(param:Number)
  {
        var _clip:movieclip = someStaticFunction();
    super(_clip, param);
  }

  static function someStaticFunction():MovieClip
  {
     ...
     return someMovieClip;
  }
}



or to make a non static function to access the property?


class Derived extends SomeBaseClass
{
  function Derived(param:Number)
  {
    super(getClip(), param);
  }

   function getClip():MovieClip
  {
     return someStaticFunction();
  }

  static function someStaticFunction():MovieClip
  {
     ...
     return someMovieClip;
  }
}


I can't tell you more while I'm speed on my project and have to go now...
CU
PiR



-----Message d'origine-----
De : mtasc-bounces@...
[mailto:mtasc-bounces@...] De la part de Diego Essaya
Envoyé : mercredi 27 juin 2007 18:16
À : MotionTwin ActionScript2 Compiler List
Objet : Re: [mtasc] super() constructor not being called

Uhm... this does not fix the problem.  The static function belongs to
the Derived class.  I tried these methods:

1)

class Derived extends SomeBaseClass
{
  function Derived(param:Number)
  {
    super(someStaticFunction(), param);
  }

  static function someStaticFunction():MovieClip
  {
     ...
     return someMovieClip;
  }
}

and somewhere else:  d = new Derived(3);

2) This other method also failed:

class Derived extends SomeBaseClass
{
  function Derived(mc:MovieClip, param:Number)
  {
    super(mc, param);
  }

  static function someStaticFunction():MovieClip
  {
     ...
     return someMovieClip;
  }
}

and creating the instance with:  d = new
Derived(Derived.someStaticFunction(), 3);

In both cases super() is not being called when compiling with MMC.

On 6/27/07, PiR Durand <mailinglists@...> wrote:
> hi
>
> if your someStaticFunction is not overwritted in your sub-class, the just
> call someStaticFunction(param)
> else SomeBaseClass.someStaticFunction(param)... this works if it's
actually

> a static function
> otherwise try super.someFunction(param)
>
> hope it helps
> ++
> PiR
>
>
>
> -----Message d'origine-----
> De: mtasc-bounces@...
> [mailto:mtasc-bounces@...] De la part de Diego Essaya
> Envoyé: mercredi 27 juin 2007 17:34
> À: mtasc@...
> Objet: [mtasc] super() constructor not being called
>
> Hi all,
>
> I'm working on a project using both the Flash IDE and the MTASC
> compiler.  The problem is, I'm having different results when compiling
> with MMC and with MTASC.
>
> I have a derived class that calls super() in its constructor.
> Something like this:
>
> class Derived extends SomeBaseClass
> {
>     function Derived(param:Number)
>     {
>         super(someStaticFunction(), param);
>         ...
>     }
> }
>
> When I compile this with MMC, the super() function is not being
> called.  When I compile it with MTASC it works correctly.
>
> But there is another problem:  if I compile it with MMC first and then
> with MTASC (using the swf file as input), the class does not seem to
> be updated, thus the super() constructor is not called.  In order to
> make it work I have to:
>
> 1) comment all references to the Derived class
> 2) compile the swf with MMC
> 3) uncomment
> 4) compile with MTASC
>
> This is a pain in the ass... Has anyone had the same problem? Is there
> something I'm doing wrong?
>
> Thanks in advance,
> Diego
>
> --
> MTASC : no more coffee break while compiling
>
>
>
> --
> MTASC : no more coffee break while compiling
>

--
MTASC : no more coffee break while compiling



--
MTASC : no more coffee break while compiling

Re: super() constructor not being called

by Diego Essaya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, I tried doing that and didn't work.  In fact, the Actionscript
2.0 specification forbids the use of super() anywhere else but as the
first statement in the constructor.  (I think MTASC ignores this
specification)

On 6/27/07, PiR Durand <mailinglists@...> wrote:

> I don't really understand what you're trying to do... but the problem seems
> to be in the order of instanciation of the class
> did you try tu put it as a variable inside the constructor?
>
>
> class Derived extends SomeBaseClass
> {
>   function Derived(param:Number)
>   {
>         var _clip:movieclip = someStaticFunction();
>     super(_clip, param);
>   }
>
>   static function someStaticFunction():MovieClip
>   {
>      ...
>      return someMovieClip;
>   }
> }
>
>
>
> or to make a non static function to access the property?
>
>
> class Derived extends SomeBaseClass
> {
>   function Derived(param:Number)
>   {
>     super(getClip(), param);
>   }
>
>    function getClip():MovieClip
>   {
>      return someStaticFunction();
>   }
>
>   static function someStaticFunction():MovieClip
>   {
>      ...
>      return someMovieClip;
>   }
> }
>
>
> I can't tell you more while I'm speed on my project and have to go now...
> CU
> PiR
>
>
>
> -----Message d'origine-----
> De: mtasc-bounces@...
> [mailto:mtasc-bounces@...] De la part de Diego Essaya
> Envoyé: mercredi 27 juin 2007 18:16
> À: MotionTwin ActionScript2 Compiler List
> Objet: Re: [mtasc] super() constructor not being called
>
> Uhm... this does not fix the problem.  The static function belongs to
> the Derived class.  I tried these methods:
>
> 1)
>
> class Derived extends SomeBaseClass
> {
>   function Derived(param:Number)
>   {
>     super(someStaticFunction(), param);
>   }
>
>   static function someStaticFunction():MovieClip
>   {
>      ...
>      return someMovieClip;
>   }
> }
>
> and somewhere else:  d = new Derived(3);
>
> 2) This other method also failed:
>
> class Derived extends SomeBaseClass
> {
>   function Derived(mc:MovieClip, param:Number)
>   {
>     super(mc, param);
>   }
>
>   static function someStaticFunction():MovieClip
>   {
>      ...
>      return someMovieClip;
>   }
> }
>
> and creating the instance with:  d = new
> Derived(Derived.someStaticFunction(), 3);
>
> In both cases super() is not being called when compiling with MMC.
>
> On 6/27/07, PiR Durand <mailinglists@...> wrote:
> > hi
> >
> > if your someStaticFunction is not overwritted in your sub-class, the just
> > call someStaticFunction(param)
> > else SomeBaseClass.someStaticFunction(param)... this works if it's
> actually
> > a static function
> > otherwise try super.someFunction(param)
> >
> > hope it helps
> > ++
> > PiR
> >
> >
> >
> > -----Message d'origine-----
> > De: mtasc-bounces@...
> > [mailto:mtasc-bounces@...] De la part de Diego Essaya
> > Envoyé: mercredi 27 juin 2007 17:34
> > À: mtasc@...
> > Objet: [mtasc] super() constructor not being called
> >
> > Hi all,
> >
> > I'm working on a project using both the Flash IDE and the MTASC
> > compiler.  The problem is, I'm having different results when compiling
> > with MMC and with MTASC.
> >
> > I have a derived class that calls super() in its constructor.
> > Something like this:
> >
> > class Derived extends SomeBaseClass
> > {
> >     function Derived(param:Number)
> >     {
> >         super(someStaticFunction(), param);
> >         ...
> >     }
> > }
> >
> > When I compile this with MMC, the super() function is not being
> > called.  When I compile it with MTASC it works correctly.
> >
> > But there is another problem:  if I compile it with MMC first and then
> > with MTASC (using the swf file as input), the class does not seem to
> > be updated, thus the super() constructor is not called.  In order to
> > make it work I have to:
> >
> > 1) comment all references to the Derived class
> > 2) compile the swf with MMC
> > 3) uncomment
> > 4) compile with MTASC
> >
> > This is a pain in the ass... Has anyone had the same problem? Is there
> > something I'm doing wrong?
> >
> > Thanks in advance,
> > Diego
> >
> > --
> > MTASC : no more coffee break while compiling
> >
> >
> >
> > --
> > MTASC : no more coffee break while compiling
> >
>
> --
> MTASC : no more coffee break while compiling
>
>
>
> --
> MTASC : no more coffee break while compiling
>

--
MTASC : no more coffee break while compiling

Parent Message unknown Re: super() constructor not being called

by drunkencop :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here's a wacky idea for a workaround -- is it possible that the prototype object for the superclass hasn't been created yet when you're calling your Derived constructor?

If so, then you could try this rather nutty idea:

s = new SomeBaseClass();
d = new Derived(Derived.someStaticFunction(), 3);

By gratuitously creating an unnecessary object of the base class, you might (as a side effect) force the creation of the base class's prototype object.

(And anyone out there, please feel free to correct me if I'm getting any aspect of the process horribly wrong.)

Another crazy thought: have you checked the output of

Derived.someStaticFunction()

to make sure it's returning a valid value at the time you're using it? Not that I think it's likely, but it's something to check....

------
Peter Balogh



----- Original Message ----
From: Diego Essaya <dessaya@...>
To: MotionTwin ActionScript2 Compiler List <mtasc@...>
Sent: Wednesday, June 27, 2007 1:24:17 PM
Subject: Re: [mtasc] super() constructor not being called

Yes, I tried doing that and didn't work.  In fact, the Actionscript
2.0 specification forbids the use of super() anywhere else but as the
first statement in the constructor.  (I think MTASC ignores this
specification)

On 6/27/07, PiR Durand <mailinglists@...> wrote:

> I don't really understand what you're trying to do... but the problem seems
> to be in the order of instanciation of the class
> did you try tu put it as a variable inside the constructor?
>
>
> class Derived extends SomeBaseClass
> {
>   function Derived(param:Number)
>   {
>         var _clip:movieclip = someStaticFunction();
>     super(_clip, param);
>   }
>
>   static function someStaticFunction():MovieClip
>   {
>      ...
>      return someMovieClip;
>   }
> }
>
>
>
> or to make a non static function to access the property?
>
>
> class Derived extends SomeBaseClass
> {
>   function Derived(param:Number)
>   {
>     super(getClip(), param);
>   }
>
>    function getClip():MovieClip
>   {
>      return someStaticFunction();
>   }
>
>   static function someStaticFunction():MovieClip
>   {
>      ...
>      return someMovieClip;
>   }
> }
>
>
> I can't tell you more while I'm speed on my project and have to go now...
> CU
> PiR
>
>
>
> -----Message d'origine-----
> De: mtasc-bounces@...
> [mailto:mtasc-bounces@...] De la part de Diego Essaya
> Envoyé: mercredi 27 juin 2007 18:16
> À: MotionTwin ActionScript2 Compiler List
> Objet: Re: [mtasc] super() constructor not being called
>
> Uhm... this does not fix the problem.  The static function belongs to
> the Derived class.  I tried these methods:
>
> 1)
>
> class Derived extends SomeBaseClass
> {
>   function Derived(param:Number)
>   {
>     super(someStaticFunction(), param);
>   }
>
>   static function someStaticFunction():MovieClip
>   {
>      ...
>      return someMovieClip;
>   }
> }
>
> and somewhere else:  d = new Derived(3);
>
> 2) This other method also failed:
>
> class Derived extends SomeBaseClass
> {
>   function Derived(mc:MovieClip, param:Number)
>   {
>     super(mc, param);
>   }
>
>   static function someStaticFunction():MovieClip
>   {
>      ...
>      return someMovieClip;
>   }
> }
>
> and creating the instance with:  d = new
> Derived(Derived.someStaticFunction(), 3);
>
> In both cases super() is not being called when compiling with MMC.
>
> On 6/27/07, PiR Durand <mailinglists@...> wrote:
> > hi
> >
> > if your someStaticFunction is not overwritted in your sub-class, the just
> > call someStaticFunction(param)
> > else SomeBaseClass.someStaticFunction(param)... this works if it's
> actually
> > a static function
> > otherwise try super.someFunction(param)
> >
> > hope it helps
> > ++
> > PiR
> >
> >
> >
> > -----Message d'origine-----
> > De: mtasc-bounces@...
> > [mailto:mtasc-bounces@...] De la part de Diego Essaya
> > Envoyé: mercredi 27 juin 2007 17:34
> > À: mtasc@...
> > Objet: [mtasc] super() constructor not being called
> >
> > Hi all,
> >
> > I'm working on a project using both the Flash IDE and the MTASC
> > compiler.  The problem is, I'm having different results when compiling
> > with MMC and with MTASC.
> >
> > I have a derived class that calls super() in its constructor.
> > Something like this:
> >
> > class Derived extends SomeBaseClass
> > {
> >     function Derived(param:Number)
> >     {
> >         super(someStaticFunction(), param);
> >         ...
> >     }
> > }
> >
> > When I compile this with MMC, the super() function is not being
> > called.  When I compile it with MTASC it works correctly.
> >
> > But there is another problem:  if I compile it with MMC first and then
> > with MTASC (using the swf file as input), the class does not seem to
> > be updated, thus the super() constructor is not called.  In order to
> > make it work I have to:
> >
> > 1) comment all references to the Derived class
> > 2) compile the swf with MMC
> > 3) uncomment
> > 4) compile with MTASC
> >
> > This is a pain in the ass... Has anyone had the same problem? Is there
> > something I'm doing wrong?
> >
> > Thanks in advance,
> > Diego
> >
> > --
> > MTASC : no more coffee break while compiling
> >
> >
> >
> > --
> > MTASC : no more coffee break while compiling
> >
>
> --
> MTASC : no more coffee break while compiling
>
>
>
> --
> MTASC : no more coffee break while compiling
>

--
MTASC : no more coffee break while compiling




--
MTASC : no more coffee break while compiling