get in touch

** I am unavailable for freelance work until January 2014 **

If you'd like  to get in touch about a freelance project or just to say hi, please send me a message using the form or via twitter at @ivonnekn.

~ Ivonne

 

 

 

If you have a budget in mind, please let me know.
Do you have a timeline for your project or a hard deadline for launch?


Milton

Designer and illustrator specializing in brand identity design, web design and UI/UX design, based in Toronto via Milton.

Blog

ActionScript 3.0: getDefinitionByName & getQualifiedClassName

Ivonne Karamoy

Occasionally I'll post a developer tip/note. As an interactive designer and developer, I use Flash and ActionScript often. These are two methods that I find useful and indispensable when working with dynamic movieclips.

getDefinitionByName

Imagine you need to find a MovieClip in your library or dynamically reference a Class and all you have is the linkage/class String name. You can create an instance of that MovieClip or Class using getDefinitionByName.

This method returns an instance of a Class Object from the Class name you provide. It is defined in the support docs as:

public function getDefinitionByName(name:String):Object

Let me show you an example. To get an instance of a MovieClip or a Class Object with the name "Class_Name" and add it to the stage:

var myClass:Class = getDefinitionByName("Class_Name") as Class; var classInstance:MovieClip = new myClass as MovieClip; addChild(classInstance);

This is equivalent to

var classInstance:MovieClip = new Class_Name();

getQualifiedClassName

Now, to do the reverse - to get the name of a MovieClip that you've dynamically created, use getQualifiedClassName.

This method returns a String which is the name of the Class instance you provided. It is defined in the support doc as:

public function getQualifiedClassName(value:*):String

Back to our example. Suppose we've created the instance classInstance and we want to get the linkage name or the name of the Class:

var className:String = getQualifiedClassName(classInstance);

The result would be, className = "Class_Name".

That's it! Oh and don't forget to import these two methods:

import flash.utils.getDefinitionByName; import flash.utils.getQualifedClassName;