what i would like to accomplish is creating a movie clip dynamically, based on its linkage, but not by calling it like an Object as AS 3 wants me too.
Example - AS 3 Creation:
Lets say i have a movie clip in my library with the linkage “fighterJet”.
Now to create it i would just say:
var tJet = new fighterJet();
thats all well and good and i understand it just fine. My problem occurs when i now wish to make a class that could be one of any number of jets.
So for example, in my library i have 3 movie clips of planes with the following linkages: “fighter”,“bomber”,“support”.
Now, when i call my constructor for my plane class i would like to pass in those linkages as strings and then create the new movieClip/Object using that string (as was possible in AS 2 using attachMovie).
Ex.
Constructor delaration for plane class - public function plane(szInstance,…);
which i would like to call as follows - tPlane = new plane(“fighter”,…); or new plane(“bomber”,…); etc.
the only way i could figure out how to then create the correct movieclip was to use a switch statement based on what szInstance would be and then create the clip as AS 3 would have me do.
Ex.
private function createPlane(szInstance:String) -- called from the constructor of Class plane
{
switch(szInstance)
{
case "fighter":
tPlane:Object = new fighter();
break;
case "bomber":
tPlane:Object = new bomber();
break;
case "support":
tPlane:Object = new support();
break;
};
};
i would much prefere to do something similar to:
var tPlane:Object = new movieClip(szInstance);
now i know the above doesnt work but thats something akin to what i would like to accomplish, simply put, creating a new movieClip/Object using the linkage as a string and not having to create it as you would a new class. any help would be appreciated.