AS3 package does not reflect location - actionscript-3

I have an fla class referencing 'com.poole.blackjack.game', and a folder path starting at the fla root of 'com\poole\blackjack\game'.
When I compile, I get:
'C:\Users\Stephen\Desktop\Blackjack\com\poole\blackjack\Game\Player.as, Line 1 5001: The name of package 'com.poole.blackjack.game' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. C:\Users\Stephen\Desktop\Blackjack\com\poole\blackjack\Game\Player.as'
I tried changing the reference and folder name to 'Game', but get:
'C:\Users\Stephen\Desktop\Blackjack\com\poole\blackjack\game\Player.as, Line 1 5001: The name of package 'com.poole.blackjack.Game' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. C:\Users\Stephen\Desktop\Blackjack\com\poole\blackjack\game\Player.as'
It's like flash is misinterpreting the filepath, though it has worked up until now. Very annoying!

It seems like your package is using 'game' - lowercase g
And you path in the error message is 'Game' - uppercase G
I'd verify that your folder structure case matches the package case.
your error :
When I compile, I get: 'C:\Users\Stephen\Desktop\Blackjack\com\poole\blackjack\Game\Player.as
your package :
'com.poole.blackjack.game'

Much later than the post, but we encountered a similar issue. It seems there is a bug with the buildsystem / IDE that if you have a file and a directory with the same name, things might get mixed up.
In our case, in the same directory we had a class called Util and a directory called util, and it didn't compile with the same error.
Our fix was changing the Util class to a different name.

Related

How can I use functions defined in other Code Repository?

I have a set of functions defined in a Code Repository (A). Code Repository A has the following structure with my class objectController defined in 'objectController.ts' :
src
index.ts
objectController.ts
How can I use the functions defined in objectController.ts in another Code Repository (B)?
I would actually recommend working within the same Code Repository where possible, but this may in some cases be unavoidable
Steps for setting up the source repository:
Modify package.json to publish the package properly.
Set a new name field to define what the package name should be in other repos. It might make sense to prefix this with something use case specific to avoid conflicts.
Update the main field to "dist/Functions.bundle.js" and the types field to "src/dist/index.d.ts".
(Optional) Set a description.
Commit the package.json changes and publish a tag on this repository.
Validate that the checks pass.
Steps in the destination repository:
Import your source repository.
Go to Settings > Artifacts.
Click + Add
Select your source repository and import it as a backing repository.
Go to package.json. Under dependencies, add the package name you set in the Source repository above (step 1.1), and set the version to the tag that you published (step 2).
Import any exported classes from your package and use them in your code as normal.
Note : You'll have to restart Code Assist after step (2) above in order to have the newly added package show up properly.
Caveats
All code must live in index.ts in the source repository for this to work.
Unit tests in the destination repository that use the imported package will fail. (This may actually be fixable, but I didn't get it to work)
You need to ensure that you have imported all Ontology objects and relations that the source repository relies on into the destination repository.
I also ran into a typing issues in my destination repository.
Error Message:
Errors:
src/index.ts(6,21): error TS7016: Could not find a declaration file for module '{module_name}'. '{redacted}/repo/functions-typescript/node_modules/{module_name}/dist/Functions.bundle.js' implicitly has an 'any' type.
Try `npm install #types/{module_name}` if it exists or add a new declaration (.d.ts) file containing `declare module '{module_name}';`
Solution:
Create a folder called typings.
Create a file within typings called index.d.ts.
Declare the module as shown below in the file created in (2) index.d.ts.
declare module '{module_name}';
Add the path to the file created in (2)index.d.ts in tsconfig.json under the typeRoots element.
"typeRoots": [
"./typings",
"./node_modules/#types/"
]

Compile error Flash CC 1017

Hi all I am trying to modify some flash files provided as part of a training package supplied on a DVD.
The DVD contains the final training packages as well as all the source files.
I have opened one of the source FLA files in Flash CC and fixed some typos in the text, then republished the SWF.
When republishing I get two errors.
1 Symbol 'noteBtn1' 1017: The definition of base class RolloverCursor was not found.
2 , Line 1, Column 1 5000: The class 'RolloverCursor' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type.
I have looked at the noteBtn1 Symbol and cannot see any script attached to it ?
I have assumed that by simply hacking the original fla file all the correct paths and setting should be inherited from the FLA file.
If I try and run the resulting SWF file it doesn't initailise correctly leaving all the assets visible simultaneously.
The FLA file has a single scene in it with the first layer being a script layer.
There is only one frame in the scene
It has been a long time since I touched Flash so a little help would be gratefully appreciated !!
Regards
Gus
There must some Action Script along with it in a folder which you probably didn't copy along. This happened to me as well a lot of times. Just search for the folder containing the 'as' file of RolloverCursor.as (most probably) and make sure it is in the same folder as your flash file.
The original object in the Flash project causing the error was not used. I have removed it from the compile. This caused another error about a missing library
The missing library was a 3rd party actionscript library. This was then downloaded and installed in the same directory as the FLA file.
Import statements updated to reflect the correct package structure, the object has now compiled.
I still cannot see how to set the global class path in the Adobe CC 2014 version of Flash professional

Collision Detection Kit package error

I am making a top-down walk around game in flash, and am using the Collision Detection Kit to handle collisions. When I try to run my game, it gives me this error message in the compiler error box:
5001: The name of package 'com.coreyoneil.collision' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. /Users/student/Google Drive/School/Game for Mr Crawford/CollisionGroup.as
What is wrong, and what should I do to fix this?
It means you have a package declaration which does not match the location of the .as file. For example, if you have an .as file with the following:
package my.sub.pack.name
{
//
}
It needs to be found in the folder SOURCE_PATH/my/sub/pack/name/. Note a default SOURCE_PATH is the same directory as your FLA.

How to import own packages in Flash Builder?

I am new to Flash Builder so this is an easy question for anybody who has some experience with flash builder and actionscript 3.0.
So basically I have a folder with .as files. The directory of it is -
...\src\assets\Stadium\MyClass
Now I want to use it in my Flash Builder Project, but when I import like this -
import assets.Stadium.MyClass.PrefabProject;
There are warnings ... look in the image below.
How can I possibly use the contents of the folder in my as3 code.
How can I use the folder as a package?
EDIT: I went ahead and tried to use the stuff from the package in the code - This is the error I got -
A file found in a source-path must have the same package structure 'assets.Stadium.MyClass', as the definition's package, ''. MyClass.as /proj_away_alpha_new/src/assets/Stadium/MyClass Unknown Flex Problem
The error you have posted in your edit seems to imply that your package statement in MyClass is empty. The package statement should contain the same path that your class is in.
Since MyClass.as resides at the path (relative to your project): assets/Stadium/MyClass
The package statement (at the top of MyClass.as) should be the same:
package assets.Stadium.MyClass
I may have interpreted that error incorrectly. Just make sure that the package statement in MyClass.as is the same as the location of the class file on disk (relative to the project's src directory).
PS: The only time you use an empty package statement is when your class resides in that special "default package" (where your main app is).

difficulty with package definition

i have the .fla file in a folder named sample.In sample i have another folder named one which contains the classes.i have set the source path for classes to this one folder.Now in the class file i have
package one
{ // code
}
but i m geting the error "C:\Users\gaurav\Documents\sample\one\CDK.as, Line 1 5001: The name of package 'one' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. C:\Users\gaurav\Documents\sample\one\CDK.as" ... can someone plz help me with it...
Packages reflect an identical folder structure to your project.
If your project is in:
C:\Users\gaurav\Documents\sample\sample.fla
package one would be in:
C:\Users\gaurav\Documents\sample\one
If your package namespace root is the same as your FLA, there's no need to set a source path for classes.
If you set a source path for classes as a folder, one must be a child of that folder.
ie: setting source path to one implies one\one would define package one, as in:
C:\Users\gaurav\Documents\sample\one\one
Otherwise, you can add a source path to your Flash for classes at a different folder location than your FLA, such as a common source folder.