Flash AS3: Classpath of Package

I just received a Flash/AS3 error message:

1172: Definition could not be found

After many years of developing websites using Flash/AS2, I abandoned Flash web development for the new world of Ajax development (actually, Flash was the first Ajax/Web 2.0 framework).

I recently began to convert some of my AS2 class packages to AS3. I upgraded to Flash CS3 a couple of years ago, but because I have recently been doing a lot of Ajax development (primarily JQuery, YUI, and Dojo), I have only done minor Flash development, limited to Flash banners and other animation projects.

After a lot of frustration, I figured out why I was receiving errors when converting my flash AS2 classes to AS3 packages.

Error 1172: Definition could not be found

While I generally do all of my development on my Mac (and Ubuntu), I have Flash installed on my Windows PC. I store all of my development/design projects under a directory named projects (F://Projects). A few years ago, I began to store all of the AS2 classes that I created under a com directory (F://Projects/com/). I had set my Classpath (Edit->Preferences->ActionScript->Language – ActionScript 2.0 Settings) to F:/Projects/com. I could then import my class from any Flash AS2 application by inserting:

?View Code ACTIONSCRIPT
import com.shared.utils.imShapes;

And my Flash AS2 class file was set up as:

?View Code ACTIONSCRIPT
class com.shared.utils.imShapes extends MovieClip {
        public function imShapes(target_mc:MovieClip) {
 
        }
}

AS3

When I converted my imShape Class to an AS3 Package, I ran into quite a few problems. The first error that I encountered was:

1172: Definition com.shared.utils.imShapes could not be found

First, I changed my Classpath (Edit->Preferences->ActionScript->Language – ActionScript 3.0 Settings) to F:/Projects.

Then I changed my AS2 Class into an AS3 Package and changed the movieClip to a Sprite:

?View Code ACTIONSCRIPT
package com.shared.utils {
        public class imShapes extends Sprite {
                public function imShapes() {
 
               }
        }
}

Note: Changing from a MovieClip to a Sprite is not necessary when converting from AS2 to AS3.

Calling AS3 Package

So now to call the package in an application, I first have to import it:

?View Code ACTIONSCRIPT
import com.shared.utils.imShapes

Now I instantiate it:

?View Code ACTIONSCRIPT
var shape1:imShapes = new imShapes();
addChild(shape1);

Converting from Flash AS2 to AS3 is not complicated – as long as you remember to change the Classpath, you should do fine. Enjoy.

Be Sociable, Share!

Checkout My New Site - T-shirts For Geeks