0

I've got several Movieclips from Flash that I'm embedding in a swc. I've got the swc included in my Flash Builder project and am able to use the classes just fine.

The problem I have is that I'm creating a function that grabs a specific movieclip by number (named FX01 through FX05) and I want to get these classes by using an int. I want to avoid a set of if statements, and I've run into this problem before, but settled for the aforementioned if statements. So, for future reference, I'd like to learn how to do this.

I want to essentially do something similar to this["myVar" + i.toString]; except for the swc classes

I've tried getDefinitionByName("FX01") but I get the error ReferenceError: Error #1065: Variable FX01 is not defined. which leads me to believe I'm using it incorrectly. Here is what I have so far

public var powerupFXType:int = 1;
state function powerupFX_onStart():void 
{   
    fx.usingMovieClip(getDefinitionByName("FX01"), 30).attach(); //this line doesn't work
    fx.usingMovieClip(FX01, 30).attach(); //this line works
    fx.usingMovieClip(getDefinitionByName("FX0" + powerupFXType.toString()), 30).attach(); //this is what I want the line to look like
}

Also note: the state function is something of our own design and it cannot take parameters in it, so I must hold the type outside.

Premier Bromanov
  • 429
  • 6
  • 15

0 Answers0