0

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.
2
  • Is you as file in the same directory as your fla file? Commented Jan 16, 2014 at 19:15
  • @putvande yup, it is. Do I have to manually set the classpath somehow? Commented Jan 16, 2014 at 19:17

1 Answer 1

1

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 );
Sign up to request clarification or add additional context in comments.

11 Comments

hm okay I updated what my new AS code is. It now gives an error saying "Type was not found or was not a compile-time constant: Shape" and it says "Call to a possibly indefined method createCircle"... shouldn't these work since I imported "flash.display.MovieClip" and since I changed the class to "public class CircleExample extends MovieClip"
can't find the type because you did not import the class.
@The_asMan which class? I did "import flash.display.MovieClip;"
@Nambew Awesome, thanks.. Also, what exactly does calling 'super()' do in this situation?
"Type was not found or was not a compile-time constant: Shape" means you did not import the Shape class. help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/… import flash.display.Shape
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.