Three Flash Pieces

OK, now it’s time for the final instalment of the Nine Words saga that has been ongoing for a while. This time, the brief was to create three interactive pieces using Flash, triggered by words chosen from the nine. My AS3 programming is not very advanced so I’ve not been able to get as conceptual as I did with the Processing pieces, but so it goes. All three rely to varying degrees on the rather nice Hype Framework, which simplifies some aspects of AS3 to let you get going a bit more easily. Click on the pictures to play with the pieces.

1: Loop
Loop

Move the mouse to control how the balls move. I was quite pleased at how simple the “physics” (such as they are) were to implement. Think of this as an analogy for life if you like…

2: Diaphanous
diaphanous

Again, move the mouse and see how the shapes react. This is an extension of one of the Hype Framework tutorials, but the springiness in the way the balls react to mouse movement is very engaging to me.

3: Ambiguity
ambiguity
This is ambiguous on a number of levels: what do the words say? What do they reveal? How do the different parts react to the movements of the mouse? I’ve applied the movement principles from the previous two pieces to the different parts here which creates an intriguing and sometimes frustrating interface. This piece needs more on the stage than the other two which can be entirely scripted, thanks to the masking used.

What’s that? You want some code? OK then… First up is Loop:

import hype.framework.display.BitmapCanvas;
import hype.extended.rhythm.FilterRhythm;
import hype.framework.core.TimeType;

var container:Sprite = new Sprite();
var lastX:Number=0;
var lastY:Number=0;
var speedX:Number=0;
var speedY:Number=0;

var ball1:MovieClip = new Ball();
var ball2:MovieClip = new Ball();
ball1.x=stage.stageWidth/2;
ball1.y=stage.stageHeight/2;
ball2.x=stage.stageWidth/2;
ball2.y=stage.stageHeight/2;

container.addChild(ball1);
container.addChild(ball2);

addChild(container);

stage.addEventListener(MouseEvent.MOUSE_MOVE, ballMove);
ball1.addEventListener(Event.ENTER_FRAME, updateX);
ball2.addEventListener(Event.ENTER_FRAME, updateY);


function ballMove(event: MouseEvent):void {
	speedX+=((lastX-mouseX)/3);
	speedY+=((lastY-mouseY)/3);
}

function updateX(event:Event):void {

	ball1.x+=speedX;

	speedX*=0.95;

	if (ball1.x>stage.stageWidth||ball1.xstage.stageHeight||ball2.y<0) {
		speedY*=-1;

	}
	lastY=mouseY;
}

var canvas:BitmapCanvas=new BitmapCanvas(800,600);
canvas.startCapture(container, true);

addChild(canvas);

var blur:BlurFilter=new BlurFilter(8,8,3);
var blurRhythm:FilterRhythm=new FilterRhythm([blur], canvas.bitmap.bitmapData);
blurRhythm.start(TimeType.ENTER_FRAME, 1);

Next is Diaphanous:

import hype.extended.behavior.MouseFollowSpring;
import hype.framework.display.BitmapCanvas;
import hype.extended.rhythm.FilterRhythm;
import hype.framework.core.TimeType;

var container:Sprite = new Sprite();

var circle:MovieClip = new Circle();
var circle2:MovieClip = new Circle2();
var circle3:MovieClip= new Circle3();

container.addChild(circle);
container.addChild(circle2);
container.addChild(circle3);

addChild(container);


var b:MouseFollowSpring=new MouseFollowSpring(circle,0.9,0.2);
var c:MouseFollowSpring=new MouseFollowSpring(circle2,0.8,0.1);
var d:MouseFollowSpring=new MouseFollowSpring(circle3,0.9,0.05);


b.start();
c.start();
d.start();

var canvas:BitmapCanvas=new BitmapCanvas(800, 600);
canvas.startCapture(container, true);

addChild(canvas);

var blur:BlurFilter=new BlurFilter(10,10,3);
var blurRhythm:FilterRhythm=new FilterRhythm([blur], canvas.bitmap.bitmapData);
blurRhythm.start(TimeType.ENTER_FRAME, 3);

And finally, ambiguity…

import hype.extended.behavior.MouseFollowSpring;

var container:Sprite = new Sprite();

var speedX:Number=0;
var speedY:Number=0;
var lastX:Number=0;
var lastY:Number=0;

stage.addEventListener(MouseEvent.MOUSE_MOVE, ballMove);
backg.addEventListener(Event.ENTER_FRAME, updateX);
backg.addEventListener(Event.ENTER_FRAME, updateY);

var c:MouseFollowSpring=new MouseFollowSpring(ambig.innerOne, 0.8, 0.05);
var d:MouseFollowSpring=new MouseFollowSpring(ambig.innerTwo, 0.85 ,0.15);
var e:MouseFollowSpring=new MouseFollowSpring(ambig.innerThree, 0.9 ,0.25);

c.start();
d.start();
e.start();

function ballMove(event: MouseEvent):void {
	speedX+=((lastX-mouseX)/4);
	speedY+=((lastY-mouseY)/4);
}

function updateX(event:Event):void {

	backg.x+=speedX;
	speedX*=0.95;

	if (backg.x>=stage.stageWidth+ (backg.width/2)) {
		backg.x=-(backg.width/2);
	} else if (backg.x=stage.stageHeight+ (backg.height/2)) {
		backg.y=-(backg.height/2);
	} else if (backg.y<=-backg.height/2) {
		backg.y=stage.stageHeight+(backg.height/2);
	}
	lastY=mouseY;
	
}

Man, that’s some ugly coding. I plan on getting my head into a bit more AS3 so maybe I’ll revisit these and rework them a bit.

Maybe…

Advertisements
This entry was posted in Advanced Software unit, code, College and tagged , . Bookmark the permalink.

One Response to Three Flash Pieces

  1. Bob Kaze says:

    Job well done!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s