I’ve tried out various animation/tweening packages and one of the features I really liked with one or two was the ability to put in a delay before the tween. Many times I’ll list out several tweens, one after another, but I’d like to stagger them. Not sure how other people handle it but I like when its built into whatever tweening package I’m using.

Recently I switched to using Macromedia’s Tween class since the one I was using at the time seemed to be unstable. I converted all the tweens over to mx.transitions.Tween and everything has been working much better ever since.

My only complaint? There’s no delay parameter to pass with a new tween. My solution? I played around with extending the class and ended up with TweenDelay. The only new param is “delay” which will cause the tween to wait before executing. I thought about wrapping the Tween class in my own class, but then I’d have to expose all the API’s to the Tween class so I went this route.

Here are two examples, one using Tween, the other using TweenDelay:

Tween:

 

TweenDelay:

 

You can use TweenDelay the same way you use Tween. There’s just a new param to pass in. Set it to zero if you don’t want a delay.

Actionscript
new TweenDelay(obj, prop, func, begin, finish, duration, delay, useSeconds);

new TweenDelay(box3_mc, "_x", Regular.easeOut, box3_mc._x, 320, 2, .5, true);

The above line would move box3_mc along the x-axis to 320. It would take 2 seconds, but wouldn’t start for half a second.

There’s a good intro to using Macromedia’s tweening classes here:
http://www.macromedia.com/devnet/mx/flash/articles/tweening.html

You can download TweenDelay here.

There’s a sample fla included. Please feel free to give me any feedback, especially bugs. This was my first time extending a Macromedia class.

Posted this in the FlashLite mailing list but thought it would be nice to get some feedback from others not on the list.


In my J2ME reading so far I’ve seen that incorporation of an opensource obfuscator called ProGuard into the build process is fairly common. Reduction in file size being the desired side affect for many people. Obfuscating code can sometimes get you decreases in file size, I think it all depends on your coding style.

I thought I’d take a look around the web to see if there were any similar tools which may help flash lite developers optimize their apps. I’ve never been fond of the idea of running my swf’s through an obfuscation/optimization tool because I worry about the unknowns that you’re introducing. Will my app work correctly still? etc… Still I thought it was worthy of some discussion. Here are two apps I played around with a little.

ASO Lite - freeware
http://www.genable.com/aso/index.html

Comes in two forms, command line or GUI version. I ran a project I’m working on now through this just to see if I could see any reduction in file size as a side effect. Original swf was 90kb, after running through ASO it was 92kb. So in that case it didn’t help.

Flash Optimizer - commercial ($99 I believe)
http://www.flashoptimizer.com

This has a free trial so I installed it and ran the same project through it. Went from 90kb to 75kb. Very promising. This program has a ton of optimization tweaks you can customize. Not sure what it does with your code. On the site they state the following optimizations.

# Vectors optimization
# Curves optimization
# Z-buffer optimization
# Shapes optimization
# Morphing optimization
# Fonts optimization
# Zero-objects optimization

Thought it was something worth looking into. Any thoughts on the subject? Anyone play with any similar tools?

Updated Ant build files

June 7th, 2005

I made some quick changes based on comments from James. This updated file only has one build file and using the gui in eclipse you can set the targets for the build so you can decide if you want to do a simple precompile using swfmill or full compile using swfmill and mtasc. In case you haven’t used Ant much in eclipse here are some screenshots:

Right click on the build.xml, but instead of click on Ant Build, click on Ant Build…

build menu

There are lots of options here, but the only thing we’re interested in here is the Targets tab.

build menu

Just check off the tasks you’d like to do. The clean task removes the target swf you define before the compiling occurs to make sure its a clean build. Note the order of the targets here. You can re-order them if you don’t click on them in order. You want clean, precompile, compile otherwise it won’t work correctly.

The updated zip file is here.

Ant builds with FAMES

June 6th, 2005

Well it’s actually more like AMES depending on what you decide to take from this. Ant, MTASC, Eclipse, and Swfmill.

I’ve been using eclipse as my actionscript authoring tool for a little while now, not compiling any work projects in mtasc, just using it since a lot of my development is made easier with the cvs and ant integration.

I decided to take a stab at using Ant to help compile a library in swfmill instead of relying on a batch file or typing it on the command line. I know that may not be a common task since you only need your library compiled once but it became more of a challenge just to see how close to a typical java project I could take actionscript.

Here’s a screenshot of the folder setup I quickly put together for this:

folder view in eclipse

I wrote a build.xml file which you can right click on in Eclipse and have the integrated Ant execute the file. The library.xml file is the swfmill file you can setup for your library. There are a few params I setup in the build file, basically pointing to the folder structure I have, classpath, path to swfmill and mtasc, and one or two other things. I think it should be self-explanatory.

I’m including two build files. I don’t want to get in the way of what Flashout and ASDT is already providing compiling wise so I know some people may just want to use the swfmill only portion of the build file. The build.xml file I’ve included by default does a full build by first compiling the library with swfmill, then compiling your project with mtasc. The build-swfmill-only.xml file just does a library build in swfmill for you. You’ll need to rename it to build.xml if you decide to use it.

I’m outputting the swf to a build directory but you can easily customize all of this. I just wanted to get the ball rolling as far as playing with Ant and some of these open source flash tools and also just wanted to try it out as a proof of concept.

Download example with build files here

Suggestions and changes are welcome. I put this together after looking up a few things regarding Ant so it may not be the best implementation. I’m sure plenty of tech departments would love to finally get flash compiling integrated into their workflow and build process.