Saturday, April 30, 2011

Let their be pausebutton!

So... What is the next step here? I am thinking I really need to finish
my collideable and constrainable line class. My linked-line class was nice
visually, but the class was not structured with standards in place that
would make it work well with a dependency graph.

Senocular Tint Snippet
05-11-2007, 11:25 AM
here is an example using the Tween class with a tint. Assumes a movie clip with the instance name "clip"
import fl.transitions.*;
import fl.transitions.easing.*;

// function to transition from one colorTransform to another
function interpolateColor(start:ColorTransform, end:ColorTransform, t:Number):ColorTransform {
var result:ColorTransform = new ColorTransform();
result.redMultiplier = start.redMultiplier + (end.redMultiplier - start.redMultiplier)*t;
result.greenMultiplier = start.greenMultiplier + (end.greenMultiplier - start.greenMultiplier)*t;
result.blueMultiplier = start.blueMultiplier + (end.blueMultiplier - start.blueMultiplier)*t;
result.alphaMultiplier = start.alphaMultiplier + (end.alphaMultiplier - start.alphaMultiplier)*t;
result.redOffset = start.redOffset + (end.redOffset - start.redOffset)*t;
result.greenOffset = start.greenOffset + (end.greenOffset - start.greenOffset)*t;
result.blueOffset = start.blueOffset + (end.blueOffset - start.blueOffset)*t;
result.alphaOffset = start.alphaOffset + (end.alphaOffset - start.alphaOffset)*t;
return result;

// start and end colors for tween
var startColor:ColorTransform = new ColorTransform(); // default color, no tint
var endColor:ColorTransform = new ColorTransform();
endColor.color = 0xFF0000; // end color of red

// create tween; use "" for property since no
// property is being tweened; just using the
// Tween class here to handle the animation
// using the values 0 and 1 (0% to 100%)
// over a time period of 50 frames
var tween:Tween = new Tween(clip, "", Strong.easeOut, 0, 1, 50);
// listen for the TweenEvent.MOTION_CHANGE event to
// perform the custom color tween
tween.addEventListener(TweenEvent.MOTION_CHANGE, tweenTransform);

// TweenEvent.MOTION_CHANGE handler using interpolateColor
// to set the colorTransform of clip (tween.obj) based on
// the startColor and endColor properties defined earlier
function tweenTransform(event:TweenEvent):void {
// use tween position for interpolation of
// start and end colors (value 0 - 1)
clip.transform.colorTransform = interpolateColor(startColor, endColor, tween.position);

Note To Self: Don't forget drop shadows sometime.

Using Tween Class for pre-packaged interactivity

Next step: Procedurally generate drop shadows that are linked to movieclips.
These drop shadows will NOT be bound to the raster surface and thus will
not contribute to drawing on the surface. Only contribute to visibility to
help user understand object is interactive.

MouseOver vs Rollover

Friday, April 29, 2011

Save Image and download from server?

Char to KeyCode As3

Char to keycode looks pretty impossible... But I think I found a script that does it...

Why Char to keycode?

Well, for readability.

Example: keyBoardListener.BindKeyToFunction("K",true,theFunction);
K = the K key.
true = case sensitive. AKA, bind to capital K, not the k key.
theFunction = the function that will execute when you press the k key.

This Andy guy looks to have done a badass job at what I need:

Test of new raster function and constrainable class

PREVIEW IMAGE: (Interactive App Further Down!)

INTERACTIVE APP. Click, Drag And Throw!

Thursday, April 28, 2011

Click and and throw balls

The text will go away if you click it. Bad design on my part...
By the way, you can totally click and throw the balls! Do it!

Sunday, April 24, 2011

Bouncing Ball with capsule collision with mouse

Download Source: ****HERE****

Capsule collision with mouse made so that it is easier to grab balls moving at
high speed. Also, if you hold down the mouse, it will grab a ball when the mouse
is over something. No need to time the clicking.

This feature will probably be able to be toggled on and off depending on
what the class is being used for.

The arrows are from a simple "VectorDisplay" class I wrote to debug
the user friendlyness of the ball throwing. It shows you the velocity vector
upon throwing the ball.

Saturday, April 23, 2011

MoveAble Line Research

Looks like, once you draw a line in flash, you cannot access the vertices
of that line and move them. Even though the line itself may still be a vector.
You have to store the line data somewhere else, and clear the screen
and redraw everything if you want to move the line.

Resource that has what I need:

Friday, April 22, 2011

Bouncing Ball with more user friendly throwing. BETA01

Download Source: ****HERE****

I implemented a queque that averages the velocity of the ball while you are
holding onto it to make the throwing more user friendly. I think
I may have forgotten to clear the que after you let go... Because
sometimes it has erratic behavior.

May want to weight the velocities. If you go back 5 frames slowly, and then go forward VERY FAST, you should go forward.

Throwable Click Draggable Class

Download Source: ****HERE****
So, it is a bit glitchy with the throwing, because you only have a sample of
1 frame to determine the new velocity. Next step is to get an average of say... the previous 5 frames to create a new velocity.

Thursday, April 21, 2011

Reflection Vector Research

Reflection Vector Research:

Vect1 is the direction of the ball before hitting the wall
Vect2 is after the wall
WallN is the normal of the wall
DOT is the dot product
Vect2 = Vect1 - 2 * WallN * (WallN DOT Vect1)
note that this will work for 3D vectors too

v' = 2 * (v . n) * n - v;
Where '*' is the scalar multiplication operator, '.' is the dot product of two vectors, and '-' is the subtraction operator for two vectors. v is reflected off of the surface, and gives a reflection vector v' which is used as the new velocity of the object.

Dot Product By Hand:

Basically: [1]Multiply the X components together.
[2]Multiply the Y components together.
[3]Add the X and Y of the new point2 value
together to get a single scalar float value.

F02: Click Draggable Class That Moves

Download Source: ****HERE****
This is the same click draggable class as before. But now it moves when you are
Not clicking on it. The next version after this will be one you can grab and toss.

F01:ClickDraggable Class Demo

Download Source: ****HERE****
My current maxscript project is taking a while to develop.
And I want to have something tangible to show for my efforts every day.
Thus, here is a clickDraggable class I made in flash today: