How to import actionscript library and call function? - actionscript-3

I need to develop something with data structure and how do I import the library as3ds (http://code.google.com/p/polygonal/wiki/DataStructures) and call the function of the library? It is in swc file format for the new version. While the older as3ds is in as format. I've no idea how to call using the swc. Anyone can help me please?

just place the .swc file where ever you want (usually in your own developer library) and target its path in ActionScript 3.0 Settings of Flash CS5: File > ActionScript Settings... (see attached screen shot).
you could also just place it in with your other library swcs. Flash CS5/Common/Configuration/ActionScript 3.0/libs/
if it's a component, create a folder for it and place the folder in the components folder: Flash CS5/Common/Configuration/Components/

Related

How does one import symbols from a .fla file to an AIR project in FlashDevelop?

This is my first time working with AIR. In previous AS3 projects in FlashDevelop, I would create a .fla file with Flash Professional in the same directory as my source files and link my main class as the document class. I used Flash to create symbols and export them for actionscript and then wrote the definitions in FlashDevelop. That isn't working with AIR.
I have the .fla file in the same directory with all of my source files. FlashDevelop AIR Mobile compiles the project fine, but the application is a white screen. Compiling the same project with the same compiler in Flash Professional works perfectly, showing all of the symbols.
How do I access the symbols in my .fla file if I am compiling from FlashDevelop?
Try the following.
In Flash Professional, go to your publish settings. Check the .swc box to export a swc when you publish (and make sure the export location is in one of your flash develop project sub folders. A subfolder called 'lib' is common practice). Also, if desired, uncheck other outputs in your publish settings.
Publish your .fla.
In Flash Develop, find the .swc in the project panel directory tree, right click it, and choose "Add to Library" You may also need to right-click again and choose "options" and tell it to "Include completely".
Now all the symbols from your .fla are available to your FlashDevelop project.

AS3: How can I use TweenMax in a different package

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;

Do you need the linked AS files after publishing .fla into .swf in flash professional?

I want to link external ActionScript file with my current fla project file so I can get the advantage of using classes in Adobe Flash professional CS6 in ActionScript 3.0.
But I am wondering if I can delete the AS file once the fla file has been published into swf?
Or even better would be if somebody could suggest me how to create classes in Flash CS6 without creating external files.
Thanks
When you publish a SWF file - all the source code (.as class files, library objects) are embedded into the SWF. (With the exceptions of Runtime Shared Libraries or any other assets you load at runtime).
This means that your SWF is not dependent on those .as files to run.
However, if you want to be able to re-publish or edit your project, you'll definitely need those .as files for that.
In regards to FlashPro, you cannot create class files that embedded in the .fla, they have to be separate .as files. You can however edit the .as class files in FlashPro.

Flash directories

Is it possible to make code in actionscript-3 to parse the virtual directories that are constructed in the flash library?
I mean that if i add a folder on the library of CS4 called 'graphics' can i write code that parse the elements of that folder in order to fill an array with folder's elements(which are BitmapData classes) ?
No, not as far as I know.
One way of looking at it is that the library is part of the fla file, the source document, and not of the compiled swf. Assets in the library that are not "exported for ActionScript" are not included in the swf. ActionScript doesn't have access to the library as such, there is no object in ActionScript for it.

How does the Gaia Flash Framework access the scaffold.as file?

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.