How can IntelliJ and Flash symbol library work together? - actionscript-3

If I'm using IntelliJ Idea as my IDE for code that's being used by an fla that I'm compiling with Flash, is there a way I can tell IntelliJ what objects exist in the symbol that I'm writing a class file for so it doesn't treat references to these objects as undefined?
Example:
I have a Flash project in Flash CS5 with a MovieClip in the library which is linked to MyClass, an external class file. The MovieClip has a TextField named myTextField.
When I edit the class file in IntelliJ, it complains about references to myTextField because it has no way of knowing about it.
Is there a way to clue in IntelliJ? Can I just declare myTextField in the class file, or will that interfere with the instance that's already in the MovieClip?

You need to set your FLA publish settings to allow you to declare your instances in your class files. Try this:
http://www.wastedpotential.com/flash-as3-stop-using-automatically-declare-stage-instances/
If you follow these steps, you can declare your instances as properties in your classes. Your FLA will compile and IntelliJ will stop choking on them.

Related

Play sound from library by its name in Actionscript3

Is it possible to play a sound from the library by its name and not Class Linkage in actionscript3?? Meaning if I have a sound named "mysound.mp3" in library and does not have a linkage name, can I play it dynamically in my code by any means?? I hope my question is clear.
In general it's not possible, because if you don't use your sound in some timeline it will not even be exported to swf.
If you are using it in timeline (so it's exported to swf) it's possible to extract it in run-time with some third-party libraries/as3 decompilers by parsing raw swf bytes, but I don't advice to go with that way - it's not stable and system resources consuming.
It's much more easy to set linkage, btw why you don't want to do that?
If you want to create an instance of a Class dynamically, you must call it by its AS Linkage. Why proceed in any other way?
How to proceed?
Right-click the sound file in your library and make it available for ActionScript by editing its Linkage properties: select Linkage to open up the linkage window > ActionScript > ActionScript Linkage : MySound (select Export for ActionScript and Export in frame 1). That will export your sound file as an ActionScript Class called MySound.
You can also select Linkage from the Library Panel menu and create or modify your AS Linkage:
So you can create a new instance of your sound Class and play it:
var s:MySound = new MySound();
s.play();

Execution life cycle of MXML+actionScript files

I know that When we compile a Java class then it will convert it into .class file and then through this .class file we have been able to run our code
Now I am new to Flex4 and ActionScript3 and I want to know what happened when I create a MXML file in flex builder and run it.Is MXML file first convert to .as file and the able to run or some other conversions happen?
Is MXML file first convert to .as file and the able to run or some other conversions happen?
Yes, the mxml compiler will convert MXML files into Actionscript classes. The mxml compiler generates a lot of code, which by default is not saved in your project. You can, however, add the -keep-generated-actionscript option (or just -keep) to the compiler options of your project you can see the generated code.
Here is a reference to the various compiler options. Right click your project in Flash Builder, select "Properties", and select "Flex Compiler" to see/edit the compiler options.

AS3 - Add Object from library with class property example.exampleClass

I have a question:
I have in Fla Library a object with the Class property like: com.tool.zoom linked to external as.
In timeline i call with:
mainApp.iniZoom("com.tool.zoom");
This fla is loaded in another FLA on I call iniZoom function.
It is posible? I get error 1007.
I hope you understand me, my english is not really good.
Thanks!
As I understand you, you are trying to instantiate a class exported from a FLA file. You select that object, do Export for Actionscript, and name class "com.tool.zoom", right? If so, you should use "new" clause like this:
var iniZoom:com.tool.zoom = new com.tool.zoom();
Obviously you need to have the AS file available at compile time.
Edit: given that you load the SWF, here is the solution that might work for you. Note you have to load all the classes you want to export from the SWF for your parent SWF to be available.

How to effectively load SWF libraries?

I am making an AS3 project in FB4. In our workflow, we have artists compile art into SWC files which the I then link as 'Referenced Libraries' in FB4.
Then I set the "Link Type" of the SWC files to "external" instead of merged into code. This should create SWFs corresponding to the SWC files in the output folder, right?
This doesn't seem to be the case. I am only seeing one SWF file: the main_app's.
I was trying to make it so that I can use a library manager to load the files dynamically.
I tried extracting the swfs manually, but it seems the main_app still compiles all the swcs to itself. I made sure the Link Type was set to external. The file size for the main_app between "external" and "merged to code" seem to be the same.
I've made a simple project in Flash Builder 4 and the only way I got the SWC->SWF happening is by creating a Flex Project instead of an ActionScript Project and selecting "Runtime shared library (RSL)" instead of "External". This is because the Flex framework have some classes that work out the loading of those libraries for you. It also automate the conversion (I should say extraction) process.
Now, if you don't want to create a Flex project just for this, you can extract the SWF yourself. The SWC file format is just a Zip containing a SWF and an XML file describing the content. You can then load dynamically this extracted SWF file using a Loader and setting the correct Application Domain. Here's a snippet of my sample project.
public class Web extends Sprite
{
public function Web()
{
//you will not be able to instantiate classes of your library until it's loaded
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
loader.load(new URLRequest("library.swf"), new LoaderContext(false, ApplicationDomain.currentDomain));
}
protected function onLoadComplete(event:Event):void
{
//here you can create instances of classes defined in your library
new Asset();
}
}
You might think that's a pretty tedious job to unzip+copy every time your designers update the library. You could automate this process with a script or an Ant file. Unfortunately, unless I'm missing something, it looks like Flash Builder doesn't want you to extend your build process, so you will still need a bit of hand work or completely convert to Ant (or something similar) to build.
Good luck!
From the moment the SWC is added to your Library, you should be able to access the SWC's assets by directly calling their specific class names . There's no need to try to get a SWF and load it with the Loader class. This actually defeats the purpose of using a SWC in the first place!
Let's say that , in your SWC, you have a MovieClip with a class name of GraphicAsset, to create a new instance , you simply do this:
var mc:MovieClip = new GraphicAsset();
In FB4's folder structure , have a look at your SWC in the Referenced Libraries folder & check the default package, you should see a list of all your assets.

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.