Reputation: 1853
Hello I have a air for android project going and I am wanting to import a actionscript class for use in the main timeline. I wrote the class and imported it, but I get the following errors:
Line 1 5001: The name of package 'com' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file.
Here is from the timeline
import com.networkScores;
var network:networkScores = new networkScores();
addChild(network);
trace(network.arr[0]);
Here is from the class file
package com
{
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.display.MovieClip;
public class networkScores extends MovieClip
{
public function networkScores()
{
}
}
}
Anyone have any idea what i am doing wrong here?
Upvotes: 1
Views: 3911
Reputation: 1
There may be unwanted project path, I had same problem.
I just copy pasted my frames to a new file and it worked.
Upvotes: 0
Reputation: 1350
I'm guessing your class is in the wrong directory, folder. Package names, essentially define how classes are distributed between your source directories. This is done to ensure various, same named classes compatibility. I'm guessing, you're putting that networkScores
class in the same directory that your main application is in. In that case, you should rename the package definition to be empty, like this:
package
{
public class networkScores extends MovieClip
{
public function networkScores()
{
}
}
}
Or, you should put the networkScores
class into a "com" named directory / folder in your project's main directory.
You can read more about packages here.
Upvotes: 1
Reputation: 11590
Make sure to have your .as class file saved in the com folder as name spaces are essentially folder structures. Then ensure class path is pointing to the right place.
For example, "c:/as3dev/projectname/com/networkScores.as
" , you can add a class path of "c:/as3dev/projectname/
". Then of course in your project properties set class to com.networkScores, if you have not yet done so.
Upvotes: 3