Question

EDIT: In addition to Nambew's answer, make sure that the default program which opens .as files is set to Flash rather than anything else (my default program was set to Dreamweaver which might've also been causing problems as well.

I am using flash CS5 and went to

File -> Publish settings

to pick the Document class. My flash file is called

CircleExample.fla

and is in a folder called

CircleExample

. In the same folder and same directory as the flash file, I have my actionscript file which is called

CircleExample.as

which is just this:

package {
    import flash.display.MovieClip;

    public class CircleExample extends MovieClip {

        public function CircleExample() {
                // constructor code
            var red:Shape = createCircle( 0xFF0000, 10 );
            red.x = 10;
            red.y = 20;
        }

    }

}

Now, for some reason, when I make

CircleExample.as

my document class and click "validate class definition" it says

A definition for the document class could not be found in the classpath, so one will be
automatically generated in the SWF file upon export.
Was it helpful?

Solution

Your class CircleExample contain error, you can't call the method addChild because your class need to extend Sprite or MovieClip

To see the current class path of your Fla, just go in File -> Publish settings, near Script : Actionscript 3, click the Actionscript settings icon.

Normally the classpath contain "." for current file directory.

The class file sample.

package  {

    import flash.display.MovieClip;

    public class CircleExample extends MovieClip {

        public function CircleExample() {
            super();

            graphics.beginFill( 0xFF0000 );
            graphics.drawCircle( 0, 0, 10 );
        }

    }

}

In your FLA

var circle:CircleExample = new CircleExample();

circle.x = 20;
circle.y = 30;

addChild( circle );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top