29 December 2009

Thank you for 2009.

This year was successful for me both in my private life and outside of it. I got job promotion back in January and I didn't s... it up, which is kinda surprise for me :) When I think about it, now when this year is almost at its end, it was one of the best years recently.

My hobby in blogging and Flash has reached the point when I really feel I can advance very fast and learn new staff quickly, so for next year I'm making one extra step. Although, this road was bumpy and few times I almost dropped it all (blogging + Flash), somehow I always found my way back. I guess I'm more addicted than I realized it!

Actually, the main reason for constantly coming back is YOU! Thousands of readers every month is not something I can ignore, so thank you all for reading my blog. I wish you all happy New Year and good health.

See you in 2010.


17 December 2009

ActionScript TextFormat Animation Effect

Something I haven't seen around and I have need for is multiple selection tool. What is functionality of it? I want to paste any text inside TextField, than to be able to select one sentence from beginning of text with mouse drag action, then select another sentence from distant part of the text while selection of first sentence stays visible, and so on. After I select everything I wanted, button click action needs to copy multiple selected text inside new TextField, so I can use it in for something else. If I had to select 20 different sentences I'm saving time significantly. Anyone knows about such tool?

Problem is you can set background color only to entire TextField. Now, I'm not familiar with Text Layout Framework and I'm not sure if this can be resolve using it, but even if it can then I need to target only latest Flash Player.

Only solution left is to use TextFormat class to make selected text different from not selected one. Until I make it work, here is one example how to use TextFormat ActionScript class for animation effect.

First we need to do is import some stuff.

import flash.events.Event;
import flash.events.MouseEvent;

Next thing we do is to create our input text field and two text formats, default format and selected text format:

var txtFld:TextField = new TextField();

var defaultFormat:TextFormat = new TextFormat();
defaultFormat.color = 0x000000;
defaultFormat.underline = false;
defaultFormat.bold = false;

var selectedFormat:TextFormat = new TextFormat();
selectedFormat.color = 0x0000FF;
selectedFormat.underline = true;
selectedFormat.bold = true;

We set look and feel for our input text field, some random lorem ipsum text and we add the text field to the stage:

txtFld.name = 'input_field';
txtFld.width = 300;
txtFld.height = 400;
txtFld.x = 50;
txtFld.y = 50;
txtFld.alwaysShowSelection = true;
txtFld.border = true;
txtFld.borderColor = 0x000000;
txtFld.defaultTextFormat = defaultFormat;
txtFld.multiline = true;
txtFld.wordWrap = true;
txtFld.background = true;
txtFld.backgroundColor = 0xCCCCCC;
txtFld.type = TextFieldType.INPUT;
txtFld.text = "Lorem ipsum dolor sit ...";

In order to make multiple selection functionality work I'll need another output text field, but right now for this example we don't need it, so let's skip that step and write some code to animate our formats:

var i:int = 3;
addEventListener(Event.ENTER_FRAME, onEF, false, 0, true);

function onEF(evt:Event):void {
if (i < txtFld.length-1){
txtFld.setTextFormat(selectedFormat, i, i+1);
txtFld.setTextFormat(defaultFormat, i-2, i-1);

This on enter frame function means text format will change only for 2 characters at the time, while previously changed characters return to default format.


11 December 2009

Flash Builder 4 (almost there)

Not yet a final release, but Flash Builder 4 (artist previously known as Flex Builder) is in beta 2 stage of development and 60 days trial is available from Adobe Labs page. I guess this link will be valid for final release too :)

Flash Builder 4 preview screen
You can read about some of the new features in article written by Brian Rinaldi ,Edge December 2009 edition.


07 December 2009

Repetitive Flash Animation Effects Using FuseKit

Again about FuseKit. It is such wonderful animation tool once you start playing around with it you can't stop.

Because some animation effects are so common I had to write few lines of code to make them easier to use.

First of repetitive Flash animation effect I wanted to replicate is 'breathing effect'. This effect allows movie clip to change it's scale value so it looks like it breaths. I have dummy movie clip logo placed in the center of the stage and code to import FuseKit libraries:

import com.mosesSupposes.fuse.*;
ZigoEngine.simpleSetup( Shortcuts, PennerEasing, Fuse );

var f:Fuse = Fuse.open();
f.label = "animation";
// effect code

Now, one function solve everything and you put the code instead of commented line above with breath(x); where x is number of iterations. Here is the function:

function breath (a) {
while (a > 0) {
Fuse.addCommand("delay", .5);
logo.tween("_yscale", 200, .5, "easeOutCirc");
logo.tween("_xscale", 200, .5, "easeOutCirc");
logo.tween("_yscale", 100, 1, "easeOutCirc");
logo.tween("_xscale", 100, 1, "easeOutCirc");

Breath function can have more parameters if you like, one for delay amount, another for scale value, yet another for animation duration ...

flash animation effect with fusekit
Next repetitive Flash animation effect I wanted to create is 'Jump effect'. Again, I'm using same logo dummy movie clip and make it jump using this function:

function jump (b) {
while (b > 0) {
Fuse.addCommand("delay", .5);
logo.tween("_y", 50, .6, "easeOutCirc");
logo.tween("_y", Stage.height/2, .6, "easeInCirc");

If you want to make movie clip bounce when hits the ground you can use easeOutBounce (or some custom variation, perheps?) instead of easeInCirc.

That's all for now, more of these effects some other time.



template by blogger templates