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

polkadotAsked:
Who is Participating?
 
DreammonkeyConnect With a Mentor Commented:
Try this:

go to publish Settings;
select the flash tab;
where it says Script: ActionScript 3.0 click Settings;
in the source path tab, add the location where both files are saved...
hit twice OK
publish
0
 
ugebCommented:
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.
0
 
DreammonkeyCommented:
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
0
 
DreammonkeyCommented:
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

0
 
polkadotAuthor Commented:
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?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.