fallenturtle
01-14-2011, 09:26 PM
I'm trying to create a function to streamline the process of doing this (which works):
var myCCmc_cc:myCCmc;
myCCmc_cc = new myCCmc();
ccHolder.addChild(myCCmc_cc);
myCCmc_cc.x = 370;
myCCmc_cc.y = 450;
myCCmc represents the names of a MovieClips in my movie library. Basically its a bunch of movieclips for onscreen captions that are suppose to appear at specific times in the movie. While I could add the above code to every keyframe to trigger the new movieclip to appear I thought it would be a good exercise in ActionScript 3 to create a function so that instead of having to replace "mcCCmc" multiple times with the appropriate movieclip name I could instead do something more streamlined like this:
showCC(mcCCmc,370,450);
The function I created looks like this:
function showCC(ccName:Object, ccX:Number = 0, ccY:Number = 0):void {
var ccName_cc:ccName;
ccName_cc = new ccName();
ccHolder.addChild(ccName_cc);
ccName_cc.x = ccX;
ccName_cc.y = ccY;
}
Unfortunately, I'm getting this error: 1046: Type was not found or was not a compile-time constant: ccName.
Where I'm confused is that I thought ccName was declared by the ccName:Object portion of my code, but I guess I need to import some classes or create a custom one? Any help would be appreciated.
Thanks.
var myCCmc_cc:myCCmc;
myCCmc_cc = new myCCmc();
ccHolder.addChild(myCCmc_cc);
myCCmc_cc.x = 370;
myCCmc_cc.y = 450;
myCCmc represents the names of a MovieClips in my movie library. Basically its a bunch of movieclips for onscreen captions that are suppose to appear at specific times in the movie. While I could add the above code to every keyframe to trigger the new movieclip to appear I thought it would be a good exercise in ActionScript 3 to create a function so that instead of having to replace "mcCCmc" multiple times with the appropriate movieclip name I could instead do something more streamlined like this:
showCC(mcCCmc,370,450);
The function I created looks like this:
function showCC(ccName:Object, ccX:Number = 0, ccY:Number = 0):void {
var ccName_cc:ccName;
ccName_cc = new ccName();
ccHolder.addChild(ccName_cc);
ccName_cc.x = ccX;
ccName_cc.y = ccY;
}
Unfortunately, I'm getting this error: 1046: Type was not found or was not a compile-time constant: ccName.
Where I'm confused is that I thought ccName was declared by the ccName:Object portion of my code, but I guess I need to import some classes or create a custom one? Any help would be appreciated.
Thanks.