anyone ? i need to figure out how to run a classes constructor after it was
dynamically linked to a MovieClip on stage ?
On 11/24/06, Dani Bacon <[EMAIL PROTECTED]> wrote:
hey eka. thx it seems to almost do the trick
it changes the class prototype but errors when i try to initialize the
constructor using the call method.
on stage i have a MC called testMC
and the code im using-
class Main
{
static function main()
{
_root.testMC.__proto__ = classes.testClass.prototype ;
classes.testClass.call(_root.testMC);
_root.testMC.action();
}
}
class classes.testClass {
public function testClass() {
trace("test");
}
public function action() {
trace("some action");
}
}
errors with - type error classes.testClass have no static field call
commenting put the .call() line compiles and prints "some action"
any ideas how i can get the constructor to be called?
thanks for all your help :)
On 11/23/06, eka <[EMAIL PROTECTED]> wrote:
>
> Hello :)
>
> You must use the __proto__ reference to change the inherit of yours
> movieclips :)
>
> example 1 : you create an empty movieclip and you want attach a new
> class
> who extends MovieClip !
>
> import myPackage.MyClass ;
>
> var mc = createEmptyMovieClip("mc", 1) ;
> mc.__proto__ = MyClass.prototype ; // i change the default __proto__
> reference(MovieClip.prototype) with the prototype of MyClass.
> MyClass.call (mc) ; // if you want launch the constructor of the class
> and
> initialize the movieclip
>
> example 2 : your movieclip is allready on the stage, it's the same
> operation
> :)
>
> mc.__proto__ = MyClass.prototype ; // i change the default __proto__
> reference(MovieClip.prototype) with the prototype of MyClass.
> MyClass.call(mc) ; // if you want launch the constructor of the class
> and
> initialize the movieclip
>
> You can create a function to lauch this hack ... it's more easy.
>
> eKA+ :)
>
> 2006/11/23, Dani Bacon <[EMAIL PROTECTED]>:
> >
> > hi marijan
> >
> > yeah thats exactly it, im using exactly that - "inject code", to
> attach my
> > classes to assets in a SWF file. but what happens is that any MC in
> that
> > SWF
> > that is linked to a class via the symbols properties panel, is
> ignored.
> > ive
> > used registerClass in Main to correct that, which does but not for
> > instances
> > that are already on stage. so im looking for another way to attach a
> class
> > to a MovieClip instance in runtime ?
> >
> > thx .. dani
> >
> > On 11/22/06, Marijan Miličević < [EMAIL PROTECTED]> wrote:
> > >
> > >
> > > as far as I know, FD ignores anything on the stage unless you
> > > choose "inject code" compile method, see compiler options within
> FD,
> > > hth
> > > -m
> > >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED] [mailto:
> > [EMAIL PROTECTED]
> > > On Behalf Of Dani Bacon
> > > Sent: Wednesday, November 22, 2006 5:50 PM
> > > To: Flashcoders mailing list
> > > Subject: Re: [Flashcoders] changing a MovieClip instance class at
> > runtime
> > > inAS2 ?
> > >
> > > hey TMK. thank you for your interest :)
> > >
> > > i started working with FlashDevelop + mtasc and would like to
> compile my
> > > projects solely via FlashDevelop. this way i would have the design
> team
> > i
> > > work with set up the symbols and stage with all the visual assets
> > needed,
> > > and set up linkageIDs to them. then i would be able to set up those
> > symbols
> > > functionality via external code.
> > > i wouldnt mind linking classes to MCs using the symbols properties
> > panel,
> > > but FlashDevelop ignores those links. so using registerClass in Main
> i
> > can
> > > link linkageIDs to classes but that only works for dynamic
> attachments
> > of MC
> > > instances.
> > >
> > > any ideas ?
> > >
> > > [snip..]
> > > _______________________________________________
> > > [email protected]
> > > 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
> > >
> >
> > _______________________________________________
> > [email protected]
> > 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
> >
> >
>
> _______________________________________________
> [email protected]
> 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
>
>
_______________________________________________
[email protected]
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