Link to home
Start Free TrialLog in
Avatar of polkadot
polkadot

asked on

definition for the document class could not be found in classpath, actionscript 3.0

"definition for the document class could not be found in the classpath" is the error I'm getting when I try to access the .as file by clicking on the pencil in the property inspector.

Also the code doesn't result in anything, not even an error.

I don't understand what I'm doing wrong.  Can someone guide me as to how to create a simple Hello World TextField through an external as file.

Below is my HelloWorld.as code.
I have a blank HellowWorld.fla file in the same directory.
package{
	
	import flash.display.*;
	import flash.text.*;
	public class HelloWorld extends MovieClip{
		public function FlashTry(){
			var myText:TextField = new TextField();
			myText.text = "Hello World!";
			addchild(myText);
		}
	}
}

Open in new window

Avatar of ugeb
ugeb
Flag of United States of America image

Hi,

Are the .fla and .as files in the same directory?

If not, then you will have to alter the publish settings so that the directory that contains the .as file is in the path.

I've never had a problem accessing the document class when the fla file is in the same directory, though.  But, make sure you have saved your fla file first, before adding a document class.
Hi there,

Did you assign the Document Class in to HelloWorld in the FLA ?

You can set the Documents class in the main properties panel (mouse click somewhere on the stage and then select the properties panel, you'll see an input field named Document Class; that's where you should provide the name of the (main) document class (without .as).

Mind, and I quote :
>>>
Below is my HelloWorld.as code.
I have a blank HellowWorld.fla file in the same directory.

Could it be the w is the nature of this trouble?
The FLA and the as should have the exact same name (only different extensions) + assign the document class in the FLA's properties.

DM
BTW,

your CLASS should have at least ONE public function with the same name as the Class itself your code should look like this :
package
{       //import as few classes as possible, the minimum needed :
        import flash.display.MovieClip;
        import flash.text.TextField;
 
        public class HelloWorld extends MovieClip
{
                public function HelloWorld(){ //Same as class name !
                        var myText:TextField = new TextField();
                        myText.text = "Hello World!";
                        addchild(myText);
                }
        }
}

Open in new window

Avatar of polkadot
polkadot

ASKER

The fla filie is in the same directory as the as file. It was created and saved first.
The as file is set in the properties of the fla file.
Everything is spelled right and case correct in all the actual files.

None of these suggestions are working.

But I have no trouble opening using and running files created from samples. Could there be something wrong with my installation of Flash?
ASKER CERTIFIED SOLUTION
Avatar of Dreammonkey
Dreammonkey
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial