PDA

Click to See Complete Forum and Search --> : Build PROTOTYPE functions in AS2



Pippomusic
12-11-2003, 10:28 AM
Hello :)

In AS1, planning applications, I have been extending lots of built-in classes unsing prototype funcions.
Especially MovieClip.

How can I do the same in ActionScript 2.0?

thanks
Pippo

devnull_2k
12-18-2003, 06:28 PM
class ClassName extends MovieClip
{
var property1:Type;
var property2:Type;
function ClassName(arg1:Type, arg2:Type,...argN:Type)
{
//constructor
}

function SetSomething(arg:Type):Void
{
property1 = arg;
}

function GetSomething():Type
{
return property1;
}
}

Pippomusic
12-18-2003, 07:25 PM
thanks...
so, does every movieclip benefit from this?
or should I link something in the library?

I wish to find a way, as in AS1, to provide functionalities to all movieclips, not only the ones linked in the library...

Ones created with createEmptyMovieClip too....

thank you and wisdom
Pippo

gSOLO_01
12-18-2003, 07:43 PM
Something like this might work... Put an empty movieclip in the library with a linkage name of "Empty" - a AS 2.0 Class Name of EmptyMovieClip...

// EmptyMovieClip.as
class EmptyMovieClip extends MovieClip {
function EmptyMovieClip(t:MovieClip, n:String, d:Number) {
t.attachMovie("Empty", n, d);
}
}

// Movie.as
myMC = new EmptyMovieClip(this, "myMC");