The definition of base class FlxGame was not found - actionscript-3

I'm getting an error where FlxGame can't be found.
I am importing it and it's in the src folder. I copied the org folder from AdamAtomic-flixel-8989e50 into src. I'm writing this in FlashDevelop.
This is the error message:
C:\Users\***\Documents\Pong\src\Pong.as(8): col: 28 Error: The definition of base class FlxGame was not found.
Loading configuration file C:\Users\***\AppData\Local\FlashDevelop\Apps\flexsdk\4.6.0\frameworks\flex-config.xml
And this is my AS3 class:
package
{
import org.flixel.*;
/**
* ...
* #author ***
*/
public class Pong extends FlxGame
{
public function Pong()
{
super(320, 240, MenuState, 2);
}
}
}

I think the easiest solution would be to use the same file structure used in most Flixel example projects. You should keep it in your org folder.
Otherwise, maybe try changing your import statement to:
import src.flixel.*
It looks like you are in the early stages of making your game. If this is your first time with Flixel, I highly recommend this tutorial.
Download the tutorial files and open it as a project in FlashDevelop (look for the file ending in .as3proj).
Or look for any other Flixel example projects. If you're like me, you'll find it easier to start from a demo game and edit the existing code/build on it. This way you don't have to worry about configuring folder paths, etc. and the game runs from the very beginning. Makes it a lot less frustrating :)

Related

AS3 package issue

Really want to refactor and re-architect my project, it's become basically an 11k line monobloc that desperately needs to be split into multiple classes (and class files) inside a single package.
Yes I know I should have figured all this out when I started, but this is play not work and I was brand new to AS3 when I started. And I've kept building and building and it all works, it's just become very hard to manage.
My immediate goal is to define a package and then start breaking out function groups from the current main class into subclasses that extend the base. But I'm having a problem with the first step - defining the package.
I'm getting:
C:\Users\Vossie\Documents\Fex Line of Battle Project\trunk\line_of_battle\LOB_Core.as, Line 1, Column 1 5001: The name of package 'line_of_battle' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. C:\Users\Vossie\Documents\Fex Line of Battle Project\trunk\line_of_battle\LOB_Core.as
So I've checked:
package line_of_battle {
public class LOB_Core extends flash.display.MovieClip {
Filename is LOB_Core.as.
Path:
I explicitly added it to the class search path:
So:
Name of package agrees with name of folder (I actually pasted it from folder to .as file)
Package file is within that folder.
Class search path includes that folder
Shouldn't matter for this but filename and public class name match
I've searched stack overflow and one similar case involved a text case mismatch that I don't see here. One other related question the guy's question turned into just how to make classes and name the files correctly.
According to the documentation I read, this should work fine. Can someone tell me what I am missing?
Edit - This is the code that's triggering the error, LOB_Core.as:1102 -
var test:LOB_Scenario_Data = new LOB_Scenario_Data();
And the class that is calling:
package line_of_battle {
import line_of_battle.LOB_Core.*;
public class LOB_Scenario_Data extends LOB_Core {
public function LOB_Scenario_Data() {
// constructor code
trace("BIG MONKEYS");
}
}
}

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.

Problems with compiling multiple AS3 packages w/ant and mxmlc

I'm trying to extend the BigBlueButton client with some proprietary classes. Specifically the phone module, where I added a file with my own code. When I write my own package name (org.mydomain.module.test ...) within the file, the compiler fails because it can't find my class from the mxml file. But when I use the original package name (org.bigbluebutton.module.phone ...) it compiles fine. Obviously when I use a different package name, the file is not included in the compilation. How can I change this?
This fails:package org.mydomain.module.test
{
public class MyTestClass
{
// code here
}
}
But this works:package org.bigbluebutton.modules.phone.test
{
public class MyTestClass
{
// code here
}
}
FYI: BigBlueButton uses ant to compile the client.
You didn't say where you put the files on disk, the package name should match the file's path in your project. Is that the case in both examples?
So when the package name is: org.mydomain.module.test
The class file should be saved in the path:
my_project_path/src/org/mydomain/module/test

Issue Using Flex SDK in Flash Professional (for as3corelib)

I recently found Mike Chambers' as3corelib when looking for ways to render the stage to a file. Works great in my ActionScript 3.0 project in Flash Professional (CS6 if it matters).
I decided to look at some of Mike's utility classes, notably the date related ones. However, his DateUtil class imports mx.formatters.DateBase, and when I attempt to use some of the methods, I'm getting lots (and lots) of "Access of undefined property DateBase."
I'm assuming that's because some reference to the Flex SDK is missing or wrong. I've added $(FlexSDK)/frameworks/libs/flex.swc to my project's Library path, but that's not helping.
I've used Flash for years, but this is my first truly code-centric project, and still learning through the school of hard knocks. No idea what's going wrong here. Ideas?
Example from as3corelib
package com.adobe.utils
{
import mx.formatters.DateBase;
/**
* Class that contains static utility methods for manipulating and working
* with Dates.
*/
public class DateUtil
{
/**
* Returns a date string formatted according to RFC822.
*/
public static function toRFC822(d:Date):String
{
var date:Number = d.getUTCDate();
var hours:Number = d.getUTCHours();
var minutes:Number = d.getUTCMinutes();
var seconds:Number = d.getUTCSeconds();
var sb:String = new String();
sb += DateBase.dayNamesShort[d.getUTCDay()];
sb += ", ";
...
The line:
sb += DateBase.dayNamesShort[d.getUTCDay()];
...generates the mentioned error, as does any other DateBase reference in the class. Again, this code is directly from the latest as3corelib, located on GitHub: https://github.com/mikechambers/as3corelib
Don't know whether you got this one licked or not, but I hit the same thing. Love the library, hate the error messages.
I downloaded the Flex SDK from here:
Adobe Flex SDK Download
Then, I unzipped that into a temporary folder.
Then, since I didn't want the whole flex framework lurking about, I created a ./lib directory inside the directory where the .fla file lives. I then moved these swcs from here (Inside the unzipped file structure):
mv ~/Downloads/flex_sdk_4.6/frameworks/libs/framework.swc ./lib
mv ~/Downloads/flex_sdk_4.6/frameworks/libs/core.swc ./lib
mv ~/Downloads/flex_sdk_4.6/frameworks/libs/mx/mx.swc ./lib
Not sure why all three were required, but it stopped the compiler complaining (and got the date conversions working).
You need to add them to the .fla's library list as well (under ActionScript Settings); but I'm betting you already knew that.
Perhaps useful, perhaps not.

Importing a Package in Adobe Flash CS3 - Pointless Messages from "Access of Undefined Property" to none at all

I inherited a Flash CS3 legacy app and I am trying to refactor it a little. Eventually everything is supposed to be moved over to JS, but for now I would like to start working with what I have rather than attempting a complete rewrite. First I would like to install a little regression test.
I am trying to setup the test in it's own package in order to reducing the seams it has with the original app. The app uses a lot of global variables and I wish not to interfere with those.
I can't get my regression test to work, since I can't figure out how to import the package properly. I am pretty certain that I am overseeing something obvious.
My folderstructure looks as follows:
+- ascripts
| +-- dependencies.as
|
+- root.fla
+- initialize.as
+- regressiontest.as
root.fla is my one and only fla file. It just contains:
stop();
include "initialize.as" // Let's go outside!
initialize.as contains all the magic. I am using this external file so I don't have to use the Flash IDE (since it is the worst IDE for coding). In there I have this:
// ...
import fl.controls.ComboBox;
include "ascripts/dependencies.as"
var t = new regressiontest.TestRunner(); // 1.
// ...
At 1. I am trying to instantiate my regression test class. It can be found in the file regressiontest.as and looks like this:
package regressiontest {
public class TestRunner {
public function TestRunner() {
trace('Hello');
// Actual Test Code Here ...
}
}
}
So now when I go to flash and debug the movie using Strg+Shift+Enter, I get the following error messages. I tried every way I could think of, so here is an overview of what I achieved so far:
var t = new TestRunner();
Message: 1180: Call to a possibly undefined method TestRunner.
var t = new regressiontest.TestRunner();
Messages:
root.as: 1120: Access of undefined property regressiontest.
regressiontest.as: 5001: The name of package 'regressiontest' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. folder\regressiontest.as
regressiontest.as: 5008: The name of definition 'TestRunner' does not reflect the location of this file. Please change the definition's name inside this file, or rename the file. folder\regressiontest.as
import regressiontest.TestRunner;
var t = new TestRunner();
root.as, Line 19: 1172: Definition regressiontest:TestRunner could not be found.
root.as, Line 20: 1180: Call to a possibly undefined method TestRunner.
What is most confusing to me is that Flash appears to be picking up the class definition in regressiontest.as somehow. When I put an obvious error, such as
public function TestRunner() {
shoelace('Hello');
}
and use this to instantiate an object of the class:
var t:TestRunner = new regressiontest.TestRunner();
then I get the Message:
regressiontest.as: 1180: Call to a possibly undefined method shoelace.
One might think now that the instantiation causes the problem. But when I set the code from shoelace to trace and leave the instantiation I get the following messages:
Messages
Scene 1, Layer 'AS', Frame 1: 1046: Type was not found or was not a compile-time constant: TestRunner.
root.as: 1120: Access of undefined property regressiontest.
regressiontest.as: 5001: The name of package 'regressiontest' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. folder\regressiontest.as
regressiontest.as: 5008: The name of definition 'TestRunner' does not reflect the location of this file. Please change the definition's name inside this file, or rename the file. folder\regressiontest.as
I tried renaming the file within the package, I tried renaming the package, I tried importing with import regressiontest.*; and so on. What am I missing?
What do I need to set my filename to? Does it need to match the PACKAGE NAME or the CLASS NAME?
Am I missing some crazy camel case rule?
Is there a maximum length to package names or something crazy like that?
Did I forget to configure flash or the FLA file correctly?
Am I missing some magic keyword?
Might there be sideeffects from the includes or imports at the beginning of my script?
I can reproduce these steps and I can provide the package via github.
Thank you in advance, with clueless greetings from Heidelberg, Germany
Johannes
As I see it, TestRunner is the class and regressiontest is the package, so you need import the class.
import regressiontest.TestRunner;
var t:TestRunner = TestRunner();
Also, you must do this changes.
The filename must be exactly the same of the class, replace regressiontest.as by TestRunner.as
Create a folder for the package and call it regressiontest, put inside TestRunner.as.