Flash 11.2 sdk definition of base class Sprite was not found - actionscript-3

I'm trying to build a simple sample project using FlashDevelop using Flash 11.2. For some reason it wont let me extend Sprite. When I try to compile it just says:
col: 31 Error: The definition of base class Sprite was not found.
All I have in my code is:
public class Game extends Sprite
{
}

Make sure that you have the following setup in your Flex SDK installation correctly:
\frameworks\libs\player\11.2\playerglobal.swc
and that you have a compiler constant called "swf-version=15" set in FD.
If that doesn't solve it, you have an ambiguous path to your libs. May they have spaces or special characters in them.

Did you import the right package? flash.display.Sprite

You put starling-framework as a tag so if you're using Starling it should be:
import starling.display.Sprite;

Related

Type was not found or was not a compile-time constant: Custom Class after switching IDEs

It seems that this is a fairly common error, but I was not able to find a solution for my exact problem. I was originally working in FlashBuilder, but my free trial expired and so I am attempting to switch to flashDevelop. Everything would build just fine in FlashBuilder, but I keep getting errors in FlashDevelop I have a custom class called MyCustomClass which extends EventDispatcher. I'm not allowed to be too specific with code, as this is for work, but I have something similar to this:
package myPackage{
import myPackage.MyCustomClass;
public class SecondClass extends EventDispatcher{
private var _fields:Vector.<MyCustomClass>;
[Bindable("fieldsChanged")]
public function get fields(): Vector.<MyCustomClass> { return _fields.slice(); }
}
}
I get the error Type was not found or was not a compile-time constant: MyCustomClass
on the fourth line of code. Any ideas?
Probably your source path is not setup in Flash Develop. In the project panel (View > Project Manager) select your source root directory (probably "src" since that is what Flash Builder creates by default) and right click and choose "Add Source Path". You can also setup your source paths in Project > Properties.. > Classpaths.

Can't use import with package_as3

For some reason, when I use package_as3 in FlasCC I can't import any classes to use as a var.
package_as3
(
"#package private\n"
"import flash.system.MessageChannel;\n"
"var mc:MessageChannel;\n"
);
When I try to build anything that has this code in it, I get this:
Error: Type was not found or was not a compile-time constant: MessageChannel.
whenever I use the compiled SWC in Flex.
EDIT:
This doesn't just apply to flash.system.MessageChannel; it seems to happen to anything that gets imported.
A few things to try out
Syntax
I don't think you are supposed to wrap each line in quotes, nor add \n for string termination, so that's one thing that need mending.
SDK
The MessageChannel class requires SDK version 4.6 and above so did you select the correct SDK and add it to your buildpath?
Runtime
Also the MessageChannel interface did not get run-time support until version 14.0.0 (AIR or Player), so in project properties -> ActionScript Compiler, did you set the 'Require Flash Player Version' to version 14.0 or above?

Explicit reference to actionscript class in top level package

If you define a class in actionscript that has the same name as a class in the top level package (e.g. Array) there seems to be no way of explicitly referencing the class in the top level package.
UPDATE: This issue is only appearing in Flash Builder 4.7 with the new ASC 2.0 compiler, using Flash Builder 4.6 with an 'old' Flex SDK it works.
Example:
package
{
import flash.display.Sprite;
import mypackage.Array;
public class AS3Problem extends Sprite
{
public function AS3Problem()
{
var myOwnArray:mypackage.Array = new mypackage.Array();
// The line below will cause a compile error
// 'Ambiguous reference to Array'
var flashArray:Array = new Array();
}
}
}
I know the simple solution to this problem is to not create classes with a name that is the same as an as3 top level package class/function, but I'm intrigued as to how this could be 'fixed' in some way by explicitly referring to this package or some other means.
For those interested, I happened to accidentally import 'Array' from hamcrest-as3 while writing tests which caused a problem like this.
Try removing this line
import mypackage.Array;
so you do not import this custom Array and you always use the fully qualified name, I did not tested it but this should fix it.
EDIT:
I tested this and yes you have to add this import line, it will not work , but I can't reproduce the error, I can use and custom Array and the global Array fine with no issue/error or warrning.
EDIT2:
This also worked for me, can you test this too?
var globalArray:Class=(getDefinitionByName('Array') as Class);
var arr2:*=new globalArray();
arr2.push("test");
trace(arr2);

Source-path baseclass definition not found when compiling AS3 in mxmlc

As it's warmup time in Ludum Dare, I thought I'd make sure the Flex SDK I'd just downloaded works. Short answer: it doesn’t.
Every time I try to run
./mxmlc -compiler.source-path=../../../Flixel/org/flixel ../../../Flash/FindTheLight/src/FindTheLight.as
I get:
Config in /Users/jonatannoponen/Developer/Tools/flex_sdk_4.6/frameworks/flex-config.xml loading
/Users/jonatannoponen/Developer/Flash/FindTheLight/src/FindTheLight.as(7): sar.: 36 Error: Baseclass FlxGame definition not found.
public class FindTheLight extends FlxGame
^`
Obviously, SDK can't find the FlxGame class. Where does your FlxGame.as located?
Also, don't you think that using an IDE (FlashDevelop, for example) can solve your problem? Just curious.

how to force compiler compile all classes in my project?

im using Adobe® Flash® Builder™ 4.6,the problem also exist in previous versions.
for some reason ,i am using
cls = applicationDomain.getDefinition(name) as Class;
to get the object's constructor and then create the instance of my modules class.thus make compile ignore my module classes ,because they are not related from my main class.how to force else classes also compiled into my swf or swc file? i didn't find where i can adjust my compile option.
by now i use this way to solve my problem,at the very beginning of the program entry.
if(1+1==3){
//never be run but do make classes merge into swf files.
new MyModule();
}
i have hundreds of modules like this one,i do hope i can find a way to solve this problem permanently
You can try with this
package
{
public class IncludeClasses
{
import com.abc.db.Database;Database;
import com.abc.logs.RemoteLogTarget; RemoteLogTarget;
import com.abc.logs.LocalLogTarget; LocalLogTarget;
import com.abc.exception.GlobalExceptionHandler; GlobalExceptionHandler;
import com.abc.utils.NetConnectionMonitor;NetConnectionMonitor;
}
}
You need to use the class to get it to compile in the swf.
Not the best method but
private var someVar:someClass;
Using the "new" keyword will cause the run-time to allocate memory for the object so you don't want to use that.
This whole loading modules and compiling classes has a code smell to it.
You would be better off having your classes in the modules implement an interface.
You need at least one strict reference to your class to appear within the project. I use a static variable of type Array to stuff all of the classes I need, and never really reference that array, if I can.
private static var dummy:Array=[OneClass, AnotherClass, Class01, Etc];
You can also do this by setting your compiler flag.
About the application compiler options
See:
include-libraries library [...]
Include only classes that are inheritance dependencies of classes that
are included with the include-classes compiler option.
The default value is false.
This is an advanced option. You might use this compiler option if you
are creating a custom RSL and want to externalize as many classes as
possible. For example:
compc -include-classes mx.collections.ListCollectionView
-include-inheritance-dependencies-only=true
-source-path . -output lcv2 -directory