Friday, July 25, 2008

Tweener and onEnterFrame

Today I figured out how to use Tweener and onEnterFrame together to create tweens of dynamically drawn content. This allows you to easily change the nature of the tween via the transition equation.

Like this (three transition equations shown here):

The code:
 public function animateLine(e:MouseEvent){   
   var easeType:String =;
   addEventListener(Event.ENTER_FRAME, drawLine);
   lineLength = 0;
   //the ease outs work much better here
   Tweener.addTween(  this, 
                      {  lineLength:stage.stageWidth, 
                         time:2, transition:easeType, 
                         onCompleteParams:[Event.ENTER_FRAME, drawLine]
  public function drawLine(e:Event){;, 0xff0000);, 0);
   line.x = (stage.stageWidth - line.width)/2;
(Sorry about the formatting, I'm still working on that.)

The animateLine function first sets up an enterFrame event listener. This event listener (drawLine) will redraw a line each time it is called using the variable lineLength for the length of the line.

Next we use Tweener.addTween to update the value of lineLength. So the value of lineLength is now changing based on a transition equation over time. Tweener.addTween also allows you to set a callback function (and the arguments). So I used this feature to call the removeEventListener function when lineLength has finished tweening.

Click here to download full source.

Saturday, March 29, 2008

DataProvider Issues

So today I decided to learn about the DataProvider as I need to use it with a TileList in my current project. The Adobe documentation was lacking (no big surprise there) so I turned to my handy Essential ActionScript 3.0. I found nothing. WTF Colin Moock? His previous AS books totally helped me learn AS 2.0. The only thing this book has been good for is the XML section.

I'll bet you though that this post was going to contain something useful about the DataProvider class didn't you? Well it's not. The whole point of this post is to say don't buy the Colin Moock Essential AS 3.0 book.

(I'll try to post more on the DataProvider later.)

Sunday, February 17, 2008

Javascript test

This is just a test post. Please ignore.

Friday, November 16, 2007

Context Menu

In the past I was pretty much against using Flash components. But now I'm working professionally and the components save time. So I've been using them. On my last project I used the scrollpane. After that experience I though maybe the components don't save time. (Maybe I'll explain that one is another post.) So to get the subject at hand -- the context menu. This post is mostly a rant. My beef with the context menu:
  • I can't add submenus.
  • I can't add items with certain names. (ContextMenuItem objects named 'B' or 'M' don't show up. Why?)
  • I can't explicitly control when the ContexMenu appears or disappears. (So I can't use right click for anything else.)
  • I can't skin it. (Or can I?)

First Post!!

So I was just reading one of Lee Brimelow's blogs and he said that "blogging about a technology is one of the fastest ways to get good at it." So I'm going to blog about Flash to learn about it. In fact I don't care if anyone even reads this blog.