It's been a few months of hard work to get it done, but the new Gaia Framework Panel is almost here. I just have a few final touches to get it finished, and I thought I'd give everyone a preview of the new panel which should be ready for launch very soon. Without further ado, here are the screenshots.
First up is the main panel. Gaia now maintains a list of your projects. You can also import existing Gaia 2.x and 3.x projects, which makes it easy to load in any Gaia project.
Next up is the Gaia Project panel. You can name your project, select its path, see what version it's using, modify the dimensions and stage color, and also set up your own custom folder paths.
The Scaffold panel is next, where you can set the class package by typing it in. No more having to navigate a folder dialog. You can choose your template, turn on SEO, as well as update your bytes in the site.xml (no more issues with duplicate ids, either!), as well as optimize the main.swf by excluding any assets you aren't using.
And finally, the Publish panel, which replaces the Project panel which was removed in Flash CS4. The Gaia Publish panel lets you check which files you want to publish (main.fla will always test movie), and you can opt to leave the files open. There's also a handy tool for syncing with the site.xml if you add pages manually instead of using scaffolding or make other changes to your site.xml.
What you can't see from these screenshots is an improved and more logical workflow because the Gaia panel will disable features that cannot be used on the project until you've done the prerequisite action. For instance, you cannot Publish or Resize a project until you Scaffold, and you can't Scaffold a project until you Create it. These features and more not only make it easier to follow the work flow, but also prevent you from making mistakes.
As you can see, it uses the CS4 panel style to blend seamlessly with the Flash IDE. This new panel has been no small amount of work, but it's been worth it. Stay tuned to my blog and the Gaia forums for the upcoming launch. Gaia 3.0 has some great improvements to the framework, as well. More news on that later, though.
Thanks again to everyone on the alpha and beta testing teams for their great feedback! You guys rock.
Jesse Warden and I spent some time trying to figure out a workaround for the FLfile.write bug.
First, we tried opening a script document via fl.openScript(), which opens a text document in Flash as a script document. Interestingly enough, what we discovered is that this method is utterly useless. After you open the document, you cannot do anything with it. You can't read its contents, you can't modify it, you can't save it, and you can't even close it because it doesn't show up in the list of open documents (fl.documents). Very strange, indeed.
Then, Jesse noticed that the outputPanel.save() method allows you to specify what type of encoding you want to use when you save it. Ends up, this solution works great, with a little bit of tweaking. If only FLfile.write() had an option to choose encoding, we wouldn't have this issue.
Once you're done modifying the text, you convert Windows carriage returns into newlines, strip extra newlines off the end of the text, clear the output panel, trace the text to it, save it with UTF-8, and then clear the output panel again. This happens so fast you never see it in the output panel.
function saveTextViaOutput(filePath, text)
{
text = text.split("\r\n").join("\n");
while (text.charAt(text.length - 1) == "\n")
{
text = text.substring(0, text.length - 1);
}
fl.outputPanel.clear();
fl.outputPanel.trace(text);
fl.outputPanel.save(filePath, false, false);
fl.outputPanel.clear();
}
According to the JSFL documentation, FLfile.write() is supposed to save as UTF-8.
Description
Method; writes the specified string to the specified file (as UTF-8).
However, this is not the case. On Windows, all files that are written using FLfile.write() use ANSI encoding not UTF-8. This happens even when you FLfile.read() a UTF-8 encoded text file and modify it and then save it with FLfile.write().
Why is this a problem?
First and foremost, this means that international Flash developers can't compile class files that are modified using JSFL. Ouch. If they try to write text files with FLfile.write() they will not have "special" characters saved correctly because garbage gets injected in the files wherever those characters exist. If they use JSFL to write or modify a class, Flash will not compile the class correctly until they manually change the .as file encoding to UTF-8 in a text editor that can do that.
My framework is used internationally, and developers outside the US have to manually encode all scaffolded class files as UTF-8 after they are generated as ANSI, even though the original file being modified for scaffolding is UTF-8. I have had numerous reports from my international users that their scaffolded class files were ANSI not UTF-8, and, until today, I thought they had something wonky on their end, or there was something different about non-US versions of Windows. Ends up, it's a Flash bug.
The Flash player has an issue where it will not load a crossdomain.xml file on a redirect. What this means is that setting the load policy has no effect, since it will only load the crossdomain.xml from the first domain, not the redirected one.
A consequence of this is when loading images from CDNs such as Edgecast, Akamai, etc., you will get Security Error #2122 when you attempt to get the width/height of the image. Luckily, there is a simple and straightforward solution (via @jesterxl).
All you do is reload the image using the redirected url, which is available in the LoaderInfo.url in the onComplete event listener of the first load. The benefit of doing this is that the second load comes from the cache, so it's basically instantaneous (or however long it takes to load the crossdomain.xml from the redirected url). Here's some sample code on how to pull this off.
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
functionload(url:String):void
{
var sprite:Sprite = new Sprite();
var loader:Loader = newLoader();
sprite.addChild(loader);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
var lc:LoaderContext = new LoaderContext(true);
lc.checkPolicyFile = true;
loader.load(new URLRequest(url), lc);
}
function onComplete(event:Event):void
{
// the redirected url
var path:String = LoaderInfo(event.target).url;
var loader:Loader = newLoader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onReallyComplete);
// swap out the old loader with the new one into the same container
LoaderInfo(event.target).loader.parent.addChild(loader);
LoaderInfo(event.target).loader.parent.removeChild(LoaderInfo(event.target).loader);
var lc:LoaderContext = new LoaderContext(true);
lc.checkPolicyFile = true;
loader.load(new URLRequest(path), lc);
}
function onReallyComplete(event:Event):void
{
var w:int = LoaderInfo(event.target).content.width;
var h:int = LoaderInfo(event.target).content.height;
}
Blogo is a powerful Mac-based blogging application that makes writing posts a snap, and with its image manipulation and filtering, you can do all kinds of cool stuff to images when including them in your posts, including resizing, cropping and black-and-white processing. This video shows how easy it is to use this awesome feature.
YouTube has a query parameter to play videos in high quality. In order to set a video to play in high quality, you add &fmt=18 to the end of a YouTube url. I'm not sure how mono sound equates to "high quality", but YouTube is doing just that to some of their videos with &fmt=18. Sacrificing audio quality for video quality doesn't seem to me to be an acceptable trade off.
You can find evidence of this clearly by listening to the following video with headphones on. It's the video by The Fixx "Saved By Zero", uploaded by Universal Music Group.
If you're paying attention, you can hear the right speaker is delayed by about about 50ms. You'll also hear a clear separation of left and right channels because it is playing in stereo.
You can now clearly hear the delay without question because the audio is playing in mono so the delay is now playing equally in both speakers. Another tell-tale sign of mono is that the music sounds like it's coming from the center, not with the stereo spread like the "low quality" version.
Click the link on the bottom right corner of the video "watch in normal quality" to toggle back and forth between the two if you have trouble hearing it the first time.
YouTube videos playing in mono when set to high quality == Lame.
When you play an mp3 file from the web via the Sound class in AS3, the length property increases as the mp3 downloads, which causes headaches when creating scrub bars for audio.
The solution is simple. Estimate the duration by calculating the bytes per second (sound.bytesLoaded / sound.length) and divide sound.bytesTotal by that number. That gives you an estimated duration. Just call this script repeatedly until the sound is finished loading, such as a 10ms timer.
This equation divides by 1000 to return duration in seconds, but you could remove the / 1000 if you want it in milliseconds.
Last night, I installed Parallels Desktop 4 on my Macbook Pro. After installing, I found out the hard way that the Parallels team made an inane decision to set CMD+W as a keyboard shortcut to shut down a virtual machine.
In Windows, CMD+W is used to close windows in both applications and the OS. It's an extremely common shortcut, I use it constantly throughout the day. By contrast, the Parallels shortcut CMD+W shuts down a virtual machine, which is not recommended by Parallels themselves. You should always shut down Windows yourself using its own shutdown command in the Start Menu. Why they decided to make a keyboard shortcut to do this thing that you shouldn't do anyway is beyond me, and why they chose to make it one of the most common keyboard shortcuts in Windows is even more perplexing.
The solution is to remap the Close Window command to another keyboard combination. With Parallels running, open your OSX Keyboard Shortcuts preferences, scroll down to the bottom until you find Parallels Desktop.app. Select it, and press the + button. Type "Close Window" and assign it to some other keyboard command. I used CMD+ALT+CONTROL+SHIFT+W, since I will never use this command ever.
I'm excited to announce that I am presenting the Gaia Framework at MAX on Tuesday, Nov 18th from 4:00pm-5:30pm. It's going to be an in-depth exploration of Gaia, demonstrating its pragmatic and agile approach to Flash development, complete with real world examples, and a healthy amount of Q & A.
I'm also going to be showing a preview of the new and improved Gaia panel currently in development (built in Flex and, of course, open-source). It's got some great new project management tools, and includes some cool new features requested by Gaia users over the past year.
Looking forward to seeing everyone at MAX in two weeks!
I am a professional Flash developer with over 13 years of programming experience. I have consulted for high-profile agencies and companies in San Francisco, Los Angeles, Atlanta and New York, and developed numerous award-winning websites and rich internet applications for clients including Adobe, Fox Sports, FX Networks, Anheuser-Busch, GE, DirecTV, ESPN, The Weather Channel, Home Depot, and Coca-Cola.
I am the author of the open-source Gaia Framework for Adobe Flash, which dramatically reduces development time and makes developing Flash sites much easier.