macromedia flash actionscript scripting, php, remoting, webservices, c#, javascript
I do not know if that is something new. But i allways have thought,
that i can use one libary-linkage with only one class, but the solution
is more than logically...;-)
MovieClip.prototype.attachMovieWithClass = function (pStrLinkage, pStrName, pIntDepths, pObjInit, pFuncClass) {
Object.registerClass(pStrLinkage, pFuncClass);
//
mc = this.attachMovie(pStrLinkage, pStrName, pIntDepths, pObjInit);
//
Object.registerClass(pStrLinkage, null);
return mc;
}
ASSetPropFlags(MovieClip.prototype, null, 1, 0);
// test
MoveRightClass = function () {}
MoveRightClass.prototype.onEnterFrame = function () {
this._x += 10;
}
MoveDownClass = function () {}
MoveDownClass.prototype.onEnterFrame = function () {
this._y += 10;
}
this.attachMovieWithClass('mcBall', 'mcBall1', 1, null, MoveRightClass);
this.attachMovie('mcBall', 'mcBall2', 2);
this.attachMovieWithClass('mcBall', 'mcBall3', 3, null, MoveDownClass);
Posted by hOk at May 14, 2003 05:16 PM
Comments (10)
Small modification inside your prototype: Return the return value from the attachMovie. IE:
mcp = this.attachMovie(pStrLinkage, pStrName, pIntDepths, pObjInit);
Object.registerClass(pStrLinkage, null);
return mcp;
:)
Posted by mike j at May 14, 2003 07:17 PM
hehe, thank you,
i have corrected this,
regards, hOk
Posted by hOk at May 15, 2003 03:13 PM
ctrl+alt+v:
Variable _level0.mc = [Movieclip:_level0.mcBall3]
a small "var" would help :-)
greets
micha
Posted by michael kneib at July 29, 2003 05:44 PM
It seems like class registration is work once when you attach/duplicate object. Say, can you re-register class for movieclips already attached onto the stage?
Posted by Rostik at July 29, 2003 06:10 PM
It seems like class registration is work once when you attach/duplicate object. Say, can you re-register class for movieclips already attached onto the stage?
Posted by Rostik at July 29, 2003 06:10 PM
there seems to be a flaw with this
MovieClip methods are being deleted as the
new Class is inherited: try giving your library asset a 10 frame timeline then calling this.stop() from within the onEnterFrame method
Posted by stefan at July 31, 2003 01:51 PM
Yes, thanks for the comment,
our classes have to inherit from MovieClip,
i have forgotten that. Add the following line
MoveRightClass.prototype = new MovieClip();
after the constructor-function.
regards, Holger
Posted by hOk at July 31, 2003 02:39 PM
ahh, of course
glad to be of help ;)
cheers, stefan
Posted by stefan at August 3, 2003 01:45 PM
Is there anyway to add dynamically created movieclips to the linkage table?
Posted by JLM at November 11, 2003 09:16 PM
wow, this just saved me loads of time. i am creating an economics graphing program that has about 50 classes; one for each type of line (demand, supply...). i am using external classes in MX2004 and because each line drawn by the drawing API is represented in a separate mc i had to make a blank mc in the library for each class and add the actionscipt 2.0 class linkage. Using this attachMovieWithClass prototype i have one movie in my library called "blank" so to create a new type of line all i have to do is:
graph.attachMovieWithClass(name, depth, iObj, class);
note: i took out the "pStrLinkage" argument and change the prototype to always attach "blank".
Thanks a million
Mike
Posted by mike at December 20, 2003 09:52 PM
|
You can use <code>code that should be highlightned</code> to highlight code! Optionally you can use the attribut language="php|perl|java" within the code tag, otherwise actionscript-highlightning will be used. |
