Skip navigation

Bluring a clip with Fuse and Fuse FMP filter shortcuts

Yet another post on getting stuff off my hard drive and into the public domain in the effort that it may help someone with AS, Fuse or filter tweening. This example just moves and blurs a clip using Fuse and FMP.

[kml_flashembed movie=”/wp-content/uploads/fuse/Filter-Blur-Tween.swf” width=”700″ height=”300″ /]

And here is the code:

[as]
/*****************************************************************************
=============================================================================
EXAMPLE FILE:
Create a box. Move it and blur it.
=============================================================================
EXAMPLE CREDIT:
Ryan Potter
www.ThoughtWillRise.com
License: Same as Fuse.
=============================================================================
FUSE CREDIT:
Fuse Kit 2
Copyright (c) 2006 Moses Gunesch, MosesSupposes.com
Distributed under MIT Open Source License, see Fuse-Kit-License.html (in fuse package directory)
Easing Equations (c) 2003 Robert Penner used by permission, see PennerEasing
Visit http://www.mosessupposes.com/Fuse
=============================================================================
EXPLANATION:
Load in the Fuse, and Filter Classes.
Register Penner’s easing equations, and FuseFMP filter shortcuts.
Draw a box on the stage.
Initialize the target to use filter shortcuts.
Write a filter on the target to force it to be set to high quality.
Blur the box and move it to the right over 3 seconds.
=============================================================================
*****************************************************************************/
// IMPORT THE CLASSES
import com.mosesSupposes.fuse.*;
import flash.filters.*;
init();

function init(){
this.box = this.drawClip(this, “box”, this.getNextHighestDepth(), 50, 50, 0xFFCC00);
this.box._x = 10;
this.box._y = 100;
this.drawStartButton();
this.drawResetButton();
ZigoEngine.register(FuseFMP, PennerEasing);
FuseFMP.initialize(this.box);
this.box.writeFilter(BlurFilter, {blurX:0, blurY:0, quality:3});
}

function tweenIt(){
this.blur.stop();
this.blur = new Fuse();
this.blur.target = this.box;
this.blur.push([{Blur_blurX:50, Blur_blurY:50, ease:”easeOutExpo”, seconds:3},
{x:400, ease:”easeOutExpo”, seconds:3}
]);
this.blur.start();
}

function drawStartButton(){
this.startBtn = this.drawClip(this, “box”, this.getNextHighestDepth(), 20, 20, 0xffffff);
this.startBtn._x = 10;
this.startBtn._y = 10;
this.drawLabel(this.startBtn, “Start Animation”, 25, 0);
this.startBtn.onRelease = function(){ this._parent.tweenIt(); }
}

function drawResetButton(){
this.resetBtn = this.drawClip(this, “box”, this.getNextHighestDepth(), 20, 20, 0xffffff);
this.resetBtn._x = this.startBtn._x+this.startBtn._width+10;
this.resetBtn._y = this.startBtn._y;
this.drawLabel(this.resetBtn, “Reset Animation”, 25, 0);
this.resetBtn.onRelease = function(){
ZigoEngine.removeTween(this._parent.box);
this._parent.box._x = 10;
this._parent.box._y = 100;
this._parent.box.writeFilter(BlurFilter, {blurX:0, blurY:0, quality:3});
}
}

function drawClip(target, clip, depth, w, h, color){
var c = target.createEmptyMovieClip(clip+depth, depth);
c.beginFill(color, 100);
c.moveTo(0,0);
c.lineTo(w,0);
c.lineTo(w,h);
c.lineTo(0,h);
c.lineTo(0,0);
c.endFill();
return c;
}

function drawLabel(target, text, x, y){
target.createTextField(”tf”, target.getNextHighestDepth(), x, y, 10, 10 );
target.tf.autoSize = true;
target.tf.multiline = false;
target.tf.wordWrap = false;
target.tf.text = text;
var my_fmt:TextFormat = new TextFormat();
my_fmt.bold = true;
my_fmt.color = 0xffffff;
my_fmt.font = “_sans”;
target.tf.setTextFormat(my_fmt);
}
[/as]

One Comment

  1. Posted July 30, 2007 at 1:16 pm | Permalink

    Thanks for this.

Post a Comment

You must be logged in to post a comment.