My Flash Resource – New Ideas and News for Applying Flash to Complex Gaming Apps

Latest News and Developments

April 17, 2008

2 ways to Instantiate an Object into a Project

by @ 2:38 pm. Filed under Actionscript 2.0 OOP, Flash Articles

In this example I want to make an instance of the object GenericObject() that is contained in the ‘’ file.

You will start by including the .as file that contains the class myGenericObject();

#include “”;

1. To include this in your .fla file you need to use the ‘new’ command in Actionscript.

var myGenericObject:GenericObject = new GenericObject();

2. You can make a movieClip instance a member of a class by right-clicking it in your library and selecting “Linkage…”. Once the window is open select “Export for Actionscript” and enter in the class name in the input field labeled “AS 2.0 Class:”. Click “OK” and now your movieClip will be a member of that class.

Use “instance of”to indicate whether your object is a instance of a class.

trace (myGenericObject instance of GenericObject); // yeilds true

Comments are closed.

My Flash Resource - A continually growing collection of tutorials, thoughts and interests of a Flash Animator and/or Developer.



New Feedburner Feed!

Feel free to syndicate.

Learning Material

Flash Resources:

Listed on BlogShares
  • Resources