Archive for the 'ActionScript' Category
Experiments in the Gaia Framework
I’ve recently discovered the joys of the Gaia Framework for Flash. It’s an awe inspiring framework designed to allow Flash designers or developers to rapidly develop really complex applications very easily. One of the best things about it is an adherence to accepted best programming standards. An application built in Gaia kind of takes care of itself. My current project features hundreds of videos and pages. Gaia managed to make short work of organising them all into something that not only solved the problem but also kept everything neat and tidy. I could preload / cache / transition and bookmark, pages, video, content, elements, everything! It implements swfObject, swfFit, swfAddress and Greensock automatically putting every library you could need at your finger tips.
It also makes you think about how you could use it in other projects. It is just made for presentations.
Next time somebody asks me for a Powerpoint presentation done in Flash. I’ll be using the Gaia Framework.
If you were putting together a presentation in Gaia you could build your slides first and bring them all together before the client has time to approve them. Leaving you free to do the alterations rather than finding yourself torn between finishing the application and polishing the content.
One of the best features of Gaia is the XML Scaffolding feature. You write an XML schema describing your application, import the XML into the Gaia panel in the Flash IDE and press the button. Hey Presto! All your Flash files, AS3 classes, symbols, swf, pre loaders, AS imports etc, all get built automatically.
I’ve had a few issues with open Flash files crashing the Flash IDE during a Gaia export but this has never really bothered me. It just encourages me to avoid putting code on any timelines. It’s all open source and free to use. The support and documentation on the website are second to none. Steven Sacks has done an amazing job.
No commentsAnti-alias when scaling images and video in Flash
Here’s one of those tips that you stumble upon, and feel embarrassed that you didn’t know this years ago.
Notice when scaling a bitmap or video up and down the image is subject to serious aliasing. Especially with a transparent background. Everything looks pixelated and choppy. Right?
Here’s the solution. In the properties of your image in the Flash library you will see the following setting.

Note that “Allow smoothing” is checked. This allows Flash to re-sample the image when it is scaled up or down, naturally there is some quality loss but essentially it solves your problem. Used sparingly it may help with your bitmap manipulation.
What about video? No problem. The same principle applies, but you have to use ActionScript.
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
myVideo.attachVideo(ns);
ns.setBufferTime(0);
ns.play(“mymovie.flv”);
myVideo.smoothing=true;
The last line is the killer!
No commentsTextMate for ActionScript
Wow! I’ve been exploring the various features of TextMate and how it’s use relates to Flash / ActionScript development. There are some great built in features and lively communities offering excellent bundles for extending TextMate.
Here’s how I set it all up.
Essentially you install the ActionScript bundle and use the Bundle Editor to point everything in the proper direction.
class test {
function test() {
// Empty constructor
}
// Hook for MTASC. This method will be called to start the application
static function main() {
var myVar:String;
myVar=” Patrick”
_root.createTextField(“hello_txt”,1,0,0,800,30);
_root.hello_txt.text = “Hello, World!”+myVar;
_root.Button1._alpha=50;
_root.Button1.onRelease = function(){
_root.Button1._alpha=100;
trace(“Hello World!”);
}
}
};
I copied the above .as file from the one that’s automatically generated by selecting file>New from template>ActionScript>MTASC sample and fiddled with it.
If you stick a .yaml file in the same directory as your .as and .swf file you can pass parameters to your preview like, trace, in my case through console, and the SWF header.
——————
# Name of your output file:
swf: test.swf
# Name of your main class:
app: test.as
# Folder/URL/file to open when compilation succeeds. Use ‘textmate’ to preview in TextMate:
preview: textmate
# SWF Header:
player: 8
width: 800
height: 600
fps: 31
bgcolor: 000000
# Optional, use it to send additional MTASC parameters (i.e: -strict)
params: -main -mx
# If you want to use Console.app (see
trace: console
——————
No commentsVariables in objects
How come I never knew the following?
I’ve got a lot on fun ahead of me.
var myObject = {
firstname: “Patrick”,
lastname: “Wall”
getlastname: function(){return this.lastname;}
}
trace(myObject.firstname);
trace(myObject.getlastname());
Class in classes
In an attempt to learn classes and ratchet up my knowledge to the next level of useage I’m going to add some entries to my blog as I learn. So that I can chart my progress.
By declaring a GenericObject an external actionscript class of the same name is automatically called when the movie plays. For instance:
var myGenericObject:GenericObject=new GenericObject();
trace (myGenericObject);
will trace [object Object] from .as file with the name of GenericObject.as.
For instance:
class GenericObject{
}
The player automatically looks for it in the root directory and hey presto – you have created a class!
No commentsgetURL – Trash the target!
How many times must I try my _self targeted Flash links in IE only to discover that they open in new browser windows rather than into _self.
The following:
getURL(“http://www.google.com”, “_self”);
…doesn’t work in IE.
For future referrence – trash the target!
The following:
getURL(“http://www.google.com”);
…works!!