PDA

View Full Version : Question about classes and objects


franklynd
07-11-2008, 07:14 AM
i'm trying rather desperately to import a class from the same package. i have the two files saved in the same folder , i have the root in the class path , i have them listed under the same package and yet when i type "import blah.classblah" i get no intelisense or formatting.

i tried instantiating an object of a class that was defined within the same file and that doesnt bring up intelisense either. so either intelisense just doesnt work or theres something wrong with my class definition :S .

heres what it looks like

Code:

package Game
{

public class rod
{
public function rod(){}
public function tie(){}
}

public class game
{
var rodObj:rod = new rod();
rodObj. //the function doesnt come up and i dont see "rod" highlighted.

}
}

thanks in advance for any help.

amarghosh
07-11-2008, 09:54 AM
u don't have to import classes in the same package; they are automatically available;

u can have only one public class per file; [and only one class per package declaration, remaining non public classes should be outside the package{}]

different classes in same package should be put in different AS files;
//games/Rod.as
package games
{
public class Rod
{
public function Rod(){}
}
}
//games/Tie.as
package games
{
public class Tie
{
public function Tie(){}
}
}
also note the CaseConventions that i have used.. classes use UpperCase while packages use lower case;

balanmanian
07-11-2008, 01:56 PM
hi

Two class cannot be with in a package, there must be only one class file should be with in a package


Package
{
public class A
{
public function A() { }
}

} // close the package here

class B extends A
{
function B() { }
}

check it with this structure