Flex Builder: Not picking up new files - apache-flex

I have a working AS3 project and it compiles fine to a SWF. I added a new file (via various means: import, drag-drop, new), but it doesn't compile this new file. I'm using Flex Builder 3. I've tried a clean an rebuild. I've tried renaming. It picks up the existing files fine, but not the new one. The project is set to use a HTML wrapper. I see some build files (I think). The new file is in an existing folder and package.
Any idea what could be wrong?

First, the SWF Compiler will optimize your end code. If you never use a class or create an instance of it anywhere in your application; that code will never be compiled in your application. this is a common occurrence if you're using Flex Remoting with some backend; and a VAlue Object is never instantiated directly, instead you're always returning arrays of it. You'll find you get a lot of "Generic Objects" without the backend object-to- AS3 object translation of the Flex Remoting Gateway.
You didn't specify what type of file you are adding. If it is an ActionScript file it won't automatically be compiled in the swf. You'll have to 'include' it in another class somehow. IF it is an ActionScript class or MXML Component, make sure you are using that class somehow in your code. If it is another file type, such as an image or other asset you'll have to embed that file into your code somehow.
We might be able to offer more help if you were to tell us what type of file is not being added to the final SWC. Also tell us how you can tell.

Related

Unable to use playn JSON classes in Eclipse

I'm not able to access the playn.core.json.* classes inside eclipse even though everything else works in general. I have used this http://code.google.com/p/playn/wiki/GettingStarted in setting up my eclipse project.
However the following classes are visible -
JsonImpl
JsonParserException
JsonSink
JsonTypedArray
JsonWriterException
When I go to the referenced libraries in Eclipse, I can see playn.core.json and
can see all classes inside it. I'm just not able to use them inside my
code.
Thanks!
Just saw the samples.
You're supposed to use the interface Json.Object/Json.Array.
Use PlayN.json().createObject() to create a new Json.Object instance, and PlayN.json().createArray() to create a new Json.Array instance.
Make sure you have statically imported playn.core.PlayN.*

Force compile-time linking of all classes in a SWC

Using Flash CS4, I am making a game that has a dozen or so sounds and a couple of music tracks. To cut down on publish/compile time, I have moved the sounds and music into an (external) SWC, which is located in a "Library Path" for the project. This works, but with a caveat...
Until before I externalised the assets, I had been dynamically instantiating the Sound objects of the embedded sound by getting their classes with getDefinitionByName.
// something like...
var soundSubClass:Class = Class(getDefinitionByName(soundClassName));
var mySound:Sound = new soundSubClass();
But now that they're located in an external SWC, I need to have "concrete" references to the classes in order to load them like this, otherwise they are not included in the published SWF, and there is a runtime error when getDefinitionByName tries to get a class that doesn't exist.
So, my question: in Flash Professional CS4, is there any way to force a library's assets to be included, regardless of whether they are statically linked?
FlashDevelop has a compiler option "SWC Include Libraries", which is exactly what I want, and is distinct from the "SWC Libraries" option. The description of the "SWC Include Libraries" option is "Links all classes inside a SWC file to the resulting application SWF file, regardless of whether or not they are used."
(Also, it's important to me that all the assets are contained within the one compiled SWF. Linking at runtime isn't what I'm after.)
Unfortunately, I don't think so. I hope this is fixed in CS5, but I wouldn't bet on it...
The current (aggravating) standard is to have a manifest class in your SWC that references all the root classes in the rest of the library:
public class MyLibManifest {
public static function manifest():void {
var class1:Class = Class1;
var class2:Class = Class2;
// etc...
}
}
Then, somewhere in your main .fla...
import com.mylibrary.MyLibManifest;
...
var myLibrary:Class = MyLibManifest;
There's no way to pull in and embed every class in an SWC by default in Flash CS4/CS5, but you may be able to do this with:
FlashDevelop
As you already know, this program's project properties has compiler options that differentiate between:
SWC Libraries: "Links SWC files to the resultin gapplication SWF file. The compiler only links in those classes for the SWC file that are required."
SWC Include Libraries: "Links ALL classes inside a SWC file to the resulting application SWF file, regardless of whether or not they are used."
That second option "SWC Include Libraries" could be useful, because if you simply compile your FLA as-is into a SWC, then put that SWC and your other SWC into FlashDevelop as SWC Include Libraries, it should compile/merge them into a single SWF that will work like you want.
FlashDevelop could also simply help you build a hard-coded list of Classes in an SWC, because if you link in the SWC as a SWC Library, it will show up in the project explorer, and you can see a list of all the classes in the SWC. You can also right click each class and choose "Insert Into Document", and it will insert the full class name. If you do that, then press semi-colon enter, you will have your first class reference. Keep your mouse over the class list in the project settings and repeat this for every class in the list. It only takes a few minutes to do this for hundreds of classes, which makes creating such a list easier. It would be even faster if the thing would let you insert more than one at once, but it doesn't seem to.
Your only other option, which you said you weren't interested in for no given reason, is Runtime Shared Libraries (RSLs). It's really not that big a deal to load the file in separately, but only if you properly handle the load process and any errors that might occur. It will add some complexity to your project, and may require some extra thought, but I'd seriously consider it as an option. See the "Application Domain Inheritance" section at www.senocular.com/flash/tutorials/contentdomains/?page=2 for more information.
I am probably missing something but isn't it a case of using -include-libraries rather than library-path option of the compiler, this is what the adobe doc says about the option
Links all classes inside a SWC file to the resulting application SWF file, regardless of whether or not they are used.
Contrast this option with the library-path option that includes only those classes that are referenced at compile time.
Adobe Documentation
I am new to all this so be gentle when you shoot me down in flames :)
You can supply the path of your assets.swc file, in ActionScript Properties, and that should work and load assets at runtime.
in flex, and whenever you have access to compiler options, you can use: -include YourClass to force the linking of the class from swc even if its not referenced from the main swf.
but i dont know if you can change compiler options from flash cs4...

Can't find compiled resource bundles

I am using Adobe Flash Builder 4.
I've run into this issue with my latest project, but I was able to re-create it with an almost empty project.
Here is what I've done.
Created a new Flex Project
Created a locale/en_US folder within this project.
Added a class that extends SparkDownloadProgressBar. All this class does is attempt to create a Label.
When I try to debug this application, I get the following error.
Error: Could not find compiled resource bundle 'components' for locale 'en_US'.
at mx.resources::ResourceManagerImpl/installCompiledResourceBundle()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\resources\ResourceManagerImpl.as:340]
at mx.resources::ResourceManagerImpl/installCompiledResourceBundles()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\resources\ResourceManagerImpl.as:269]
at mx.resources::ResourceManagerImpl/processInfo()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\resources\ResourceManagerImpl.as:387]
at mx.resources::ResourceManagerImpl()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\resources\ResourceManagerImpl.as:122]
at mx.resources::ResourceManager$/getInstance()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\resources\ResourceManager.as:111]
at mx.core::UIComponent()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:3728]
at spark.components.supportClasses::TextBase()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\components\supportClasses\TextBase.as:154]
at spark.components::Label()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\components\Label.as:384]
at Preloader()[C:\SVN\Games\Social\Test\src\Preloader.as:21]
at mx.preloaders::Preloader/initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\preloaders\Preloader.as:253]
at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:1925]
at mx.managers::SystemManager/initHandler()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:2419]
The Flex Compiler/Additional Compiler Arguments section does contain "-locale en_US", but I do not want to just remove this as I am planning to have this load different property files based on the localization region at run-time and how I understand it, I will need to add each locale that I am planning to use on the compile argument line.
I am at a loss as to how to attack this problem. If you need anymore information from me to help with this, I will be more than happy to provide it. Thanks ahead of time for the help!
This might be caused by the fact, that Preloader loads the actual framework, so you can't use the Flex's classes until it loads. Use standard TextField for it and it should work fine.

Flex AS3 Project Convert to CS4

Has anyone got experience in converting AS3 projects (no mxml) in Flex, to Flash CS4? Are there any resources out there as to what works in Flex Builder that doesn't work in Flash, and how to get the project running? I read somewhere that (for instance) certain Metadata tags don't work.
If I've got all my code in the src folder, should I just create the .fla file in that folder and basically copy all code from the .as file which launched the Flex project? Or create the .fla file somewhere else and point assign that src folder in the classpath? Also, not being familiar with the CS4 IDE, do I create a new Flash Project?
Thanks!
So here's the issue I'm having. The code in the Flex AS3 looks like this:
[Embed(source='C:/WINDOWS/Fonts/ArialBD.TTF', fontWeight = 'bold', fontName='ArialBold', unicodeRange='U+0020-U+0020,U+0021-...')] //a bunch of other unicode
public static var _VerdanaFontBold:Class;
[Embed(source='C:/WINDOWS/Fonts/Arial.TTF', fontWeight = 'regular', fontName='Arial', unicodeRange='U+0020-U+0020...')] //a bunch of other unicode
public static var _VerdanaFont:Class;
And in constructor of the extended textfield in which my text appears I have:
Font.registerFont(_VerdanaFontBold);
Font.registerFont(_VerdanaFont);
CS4 doesn't allow use of the Embed metadata. So I've commented that out. In CS4, I understand that I'm supposed to create a blank textfield in design mode, which I've done. I then can select fonts to embed. I've selected verdana (upper and lower case, punctuation, number, etc).
When I run the app in CS4, the textfield is blank.
What am I doing wrong? Do I need to give the verdana font an instance name of _VerdanaFont? I wouldn't think so, since I've had to comment out the Font.registerFont as well. The fact that I'm embedding the font in a blank textfield, and not the one that's called by the document class I've set, shouldn't matter, right -- the font should just be embedded in the swf and available for use. But it's blank.
Does anyone know what to do here?
Edit: Well given that the apparent reason this isn't working now has to do with fonts not showing up correctly, I better create that as a new Question. Also, there's a clearer description than the one in the link provided above regarding the document class, here: http://www.heaveninteractive.com/weblog/2008/03/04/introduction-to-the-document-class-in-actionscript-30-tutorial/
It really depends. If it's just a pure AS3 project that relies only on playerglobal.swc it should be fairly easy. Just copy your .as files and add them to your new project as Cameron has suggested.
If however you've written a pure AS3 Flex app that relies on any of the other SWCs (flex.swc, framework.swc, etc) it's not really possible, as CS4 can't use SWC files. If you google around you might find somebody who's disassembled the SWC into various .abc files and a SWF full of resources, but you'll probably end up having to embed the entire Flex framework and all support code into your final SWF, which will bloat it big-time.

How about using FLEX 3 component inside Flash file?

Is it possible to use Flex 3 component/code inside Flash (cs4) SWF file ?
I know its possible in the opposite direction.
With my minimal testing it seems you can't use Flex components when building a "pure AS3" project. (Can we start calling it PAS3 or something? Like "passé". Or "pastry". :)
I did this admittedly limited testing by creating a test project with one AS class as the "document class", which would instantiate and addChild one mx.controls.Button. I copied the whole mx package from the path mentioned by hasseg into the project source path.
This is what I found out:
By removing the use of mx_internal from a certain Version.as file, I got Flash IDE to compile my test project without warning. Nothing showed up on the stage though.
Using Flex Builder (and the flex compiler, obviously) I also managed to compile the project without errors. I put breakpoints in the code and watched it build itself in the debugger. The components were instantiated flawlessly, but still nothing showed up on the stage. This swf also crashed the browser numerous times.
I haven't used Flex code in a "pure AS3" project myself, but I don't see why you couldn't do that.
You can download the Flex SDK and get the Flex components from there, both as an swc file (under /frameworks/libs) and as AS3 source code (under /frameworks/projects/framework/src).
It looks like this can be done after all: http://labs.wichers.nu/2007/12/25/using-flex-compiled-code-within-flash/
In general you need to use MXML to initialise the Flex framework and use Flex components.
Mike Chambers from Adobe says:
There is not support for using the Flex Framework in an AS only project. While it is theoretically possible, you would have to manually bootstrap a lot of the application initialization code that Flex handles (something which would be rather complex). - Source
To see how complex, you can tell the compiler to keep the intermediate AS3 files that it generates from the MXML. Open your AS3 project properties and set -keep-generated-actionscript as an argument to the compiler. Compile your project then look in the obj/generated folder. Using Flex 4, I get 13 small files the main of which extends spark.components.Application and overrides a few methods.
So it's possible but you probably wouldn't want to do it. Flex is meant to make your life easier, not harder.

Resources