So I'm trying to build a separate package. In that package I would like to reference TweenMax, however I'm having trouble linking to it (error Definition com.greensock:TweenMax could not be found).
Here is my dir structure:
myApp
--com
----greensock
------Tweenmax etc
----myPackage
------packageClass.as
--------elements
----------elementClass.as (this is the one trying to access tweenmax)
--src
----Main.as
main.as is the document class, just so I can test myPackage. Doesn't do anything except instantiate myPackageClass and stick it in the displayList.
In the elementClass.as I have:
import com.greensock.TweenMax;
which flashDevelop seems to see within the ide, but when I compile I get the ...could not be found error.
So how can I reference tweenmax from my elementClass file (I have src and com dirs in the classpaths.
I'm using flashDevelop with flash player 11.7 and Flex 4.6.0 SDK.
Am I going about this all wrong?
I'm going to ask the hopefully obvious question, did you import the greensock folder?
import com.greensock.TweenMax
Ok let's say you did that already. Maybe you need to tell your code where your libraries are. Go to File > ActionScript Settings, or, on the stage's property panel, click the wrench icon next to the Script drop down menu.
You should see a dialog with three tabs, the first two of which are labeled Source path and Library Path. Forget about the third.
In the Source path tab, you should at least have a dot - (.) - as one of the choices. That tells flash to look for any actionscript classes it can't find at compile time in the same directory as the source FLA. From there you can list any number of other library paths that contain supporting files.
The second tab is for SWC files. If you have a SWC library, you can tell your FLA where to find it by pathing to it here, just as you pathed to your libraries in the Source path tab.
The images below presume that there is a folder, in the same directory as the source FLA, named library. In this folder are sub folders named src and swc. Inside src are sub folders containing the greensock and facebookAPI com folders, (the latter used here for example). Inside the swc folder there is a SWC named exampleSWC.swc.
The paths shown in the pics below would allow the FLA to see the following imports:
import com.greensock.TweenMax;
import com.facebook.someFacebookAPIClass;
import com.somePackageInTheSWC.someClassFromExampleSWC;
Related
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).
I have inherited an Actionscript file from an old project and I've been told that it's possible to generate a SWF from it, though I don't have a corresponding FLA file.
The code within the file follows this form:
package {
import flash.display.LoaderInfo;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
// additional import statements
[SWF(width="640", height="480", frameRate="30", backgroundColor="#FFFFFF")]
public class MyClass extends Sprite {
// code, code, code
}
}
I have tried bringing this into Flash Builder and using "Run as Web Application" but I get a bunch of errors I don't understand (calls to undefined methods, definitions that can't be found).
I have done quite a bit of AS2 coding but not so much AS3 and zero Flex. I'm not sure if I am just not up to date on some of the latest methods for compiling SWFs without a corresponding FLA.
Is there a way to compile this type of file into a SWF? Or am I going about it the correct way but possibly just missing some dependent files?
Is it possible to generate a swf from an .as file without the original .fla:
Yes, IF you have all the dependencies.
When using flashBuilder, and you look at all your imports, anything that doesn't start with flash. or mx. is another file you'll need. This includes all imports within those class files as well.
Also, many .fla's use display objects that are in the library. If this is the case, those would need to be exported to another swc/swf and then linked/loaded to your flashBuilder project. That includes components (the 'fl' package).
So to sum it up:
If the original.fla is just an empty project with a document class linked, then you'll be fine if you have all the needed class files that are imported.
If the original .fla has library assets that are linked or dropped onto the timeline, then you will have issues if you can't get the original .fla.
How To Do This In Flash Builder
In flash builder, create a new ActionScript Project.
Put all the dependent files in the src folder of the project it just created - keeping their folder structure/hierarchy (the package name represents the folder it expects the .as file to be in relative to the src folder).
In the tree view, find the main .as file (documentClass), right click and tell it that it is the default application file (if you want, you can delete the file that was automatically generated when you created the project - projectname.as).
Run the project and it will put the swf in the bin (or bin-debug) folder with the same name as the project.
I have a lot of library assets linked to external as3 classes. I would like to change the structure of the packages containing the linked classes, but if I do so, all links will get broken.
Is there any way to automatically or at least easily tell the FLA file where to get the new class files from? Could a FLA file be configured to read this sort of information from a configuration file?
You can add a folder to the source paths in ActionScript Settings. So if you had linked all your classes relative to the 'myClasses' folder, and then you moved everything to a different folder, you'd just have to update that one source path and it would find all the classes again.
Also, maybe this obvious, but I didn't realize it for a long time:
You can edit the class linkage right in the Library panel (without having to open the Properties for each symbol). Just double-click the linkage path.
I'm having trouble accessing content in an SWC. The main project compiles without error, but the assets (sound, music) aren't displayed or played.
My workflow:
i. Using Flash CS5
1. Create MAsset.fla
2. Import sounds, art
3. Assign class names, check export in frame 1
4a. Write out the classes in the actions panel in frame 1
4b. OR. Add a document class and write out the classes there
5. Export SWC. Filesize is similar to what it is when I directly import assets in the main project library.
6. Create Project.fla and document class Project.as
7. Import SWC into main project through the Actionscript panel.
8. Add code, which calls the class names from the SWC (e.g. DCL_UI_MOUSE)
9. Compile.
No compiler errors, but nothing doing. And the resulting SWF filesize doesn't reflect anything more than the compiled code from the main project.
Regarding step 4, if I just write the class name in the root timeline or document class, the compiler error will go away and the asset appear to be compiled in the SWC. But I have also tried:
var asset0000:DCL_UI_MOUSE;
And:
var asset0000:DCL_UI_MOUSE = new DCL_UI_MOUSE();
Regardless the assets don't make it into the final SWF.
What am I doing wrong?
What exactly do you mean when you say "Import SWC into the main project through the ActionScript panel" and "Add code, which calls the class names from the SWC"?
If you want to use an SWC as an asset library, you have to
add the SWC to the library path, and
always add the appropriate import statements to your ActionScript code.
There's no step threeâ„¢.
You can also use it as a runtime shared library by linking to individual library objects in the properties panel.
To get your library items to compile into the the SWC, check "export for ActionScript" and "export in frame 1", then write your fully qualified class name into the "class" field. "Base class" should be set to flash.display.MovieClip or flash.display.Sprite (for MovieClip items), or flash.display.SimpleButton (for Button items)- whichever fits the object best.
Also, note that it is customary to use camel case for class names (eg: DclUIMouse). The all caps DCL_UI_MOUSE would be used when naming a constant.
In the Gaia Flash Framework, a file called 'Scaffold.as' is used to make each page a scaffold page. This is accessed by the code,
new Scaffold(this);
But the class itself does not appear to be imported. Am I missing something about the way flash handles external classes? Or is there something else pulling it in?
Any help appreciated.
This all depends on how you are compiling. I'll assume you are using Flash IDE to compile. Flash has a source path lookup mechanism. This can be accesed through the fla (under File->Publish Settings->Flash (tab)->ActionScript). If the file Scaffold lives at the root level of a class path then there is no need to import it. The default class path includes the directory the Flash file resides in and some Adobe directories. There is a mechanism for managing class packages ... I think it was the old Macromedia Extension Manager. It would copy classes into the default class paths when the package was installed - so that could be the case. I have no familiarity with Gaia itself.
So there are 3 options. First the file Scaffold.as is in the same directory as your fla. Second the file Scaffold.as is in a default Adobe include directory. Finally the file is in a directory referenced in the fla's class path.