Happy Birthday, me

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

Add comment June 20th, 2008

Flash Player 10 API online no zip file

Thanks to Alex Bustin. He decided to take the bandwidth hit and upload the Flash Player 10 API to his site.

No you don’t have to download it. Also, Matt Chotin said that some new properties do not code complete currently, so don’t think you did something wrong. It’s Adobe not you.

Add comment May 22nd, 2008

Using Flash Player 10 to produce Dynamic Musical Notes

image of swf flash player 10 guitar tunerSo after 13 year of off and on drumming I have learned a thing or two about music. Not much about tuning a guitar. Thanks to a class that I got a D in, Musical Acoustics, I know every note produces a frequency and a wavelength. With that you can now you Flash to produce a frequency and that is what I did, the six notes from left to right are the notes of a regularly tuned guitar.

Since I lost my Musical Acoustics book from UNT I had to look it up to find the Frequency of All Notes

and that pick the ones I wanted starting w/ E4.

So if you don’t have a guitar tuner…here you go.

View Code:

(more…)

1 comment May 20th, 2008

Flash Player 10 Dynamic Sound Generation

I miss writing classes w/ 50 or so lines of code and here is one. This is a take off of Lee Brimelow’s Example of Dynamic Sound Generation. I’m using the BitmapData to create a tone.

[as]

package
{
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.net.URLRequest;
import flash.system.Capabilities;
import flash.text.TextField;

public class DynamicSound extends Sprite
{
private var sound:Sound;
private var noise:Number = 0;
private var _loader:Loader;
private var _bm:Bitmap;
private var _verText:TextField;
public function DynamicSound():void
{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
_verText = new TextField();
_verText.text = Capabilities.playerType + ” (” + Capabilities.version + “)”;
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
_loader.load(new URLRequest(”http://www.scarlet.nl/~ivo/photo_ASTRO3.JPEG”));

}

private function onComplete(evt:Event):void
{
_bm = Bitmap(_loader.content);
addChild(_bm);
addChild(_verText);
sound = new Sound();
sound.addEventListener(Event.SAMPLES_CALLBACK, onCallback);
sound.play();
}
private function onCallback(e:SamplesCallbackEvent):void
{
for(var i:uint=0; i<512; i++)
{
noise += _bm.bitmapData.getPixel(mouseX, mouseY)/ 44100;
var sample:Number = noise * Math.PI * 2;
sound.samplesCallbackData.writeFloat(Math.sin(sample));

sound.samplesCallbackData.writeFloat(Math.sin(sample));
}
}
}
}

[/as]

Quick and Dirty!

1 comment May 20th, 2008

How to load Pixel Bender in Flash Player 10

Hey so I spent most of the weekend trying to get Senocular’s tutorial on loading .pbj into flash player 10.

For some reason it wasn’t working for me so I decided to download Pixel Bender Preview Release and copy the file’s source code and export it (File > Export Pixel Bender…for Flash) and it worked so I wanted to post it. Just in case some one had the same problem.

AS FILE:

[as]package {
import flash.display.*;
import flash.events.*;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.utils.ByteArray;
import flash.utils.getTimer;

public class astro2 extends Sprite
{

// image for shader fill
private var _bitmap:Bitmap;

// shader fill shader; it will use
// the image as an input
private var _shader:Shader;

// loader to load pixel bender bytecode
// for shader instance
private var _shaderLoader:URLLoader

private var _loader:Loader

public function astro2()
{
//load image
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImgLoad, false, 0, true);
_loader.load(new URLRequest(”http://bp2.blogger.com/_Y8m29ZLX5ag/RarR3rcAVwI/AAAAAAAAAL4/dtA7xOMrI4g/s400/ASTRO_jpg.jpg”));

}

//once loaded load Pixel Bender File
private function onImgLoad(evt:Event):void
{
_bitmap = Bitmap(_loader.content);

_shader = new Shader();
_shaderLoader = new URLLoader();

_shaderLoader.dataFormat = URLLoaderDataFormat.BINARY;
_shaderLoader.addEventListener(Event.COMPLETE, shaderLoaded);
_shaderLoader.load(new URLRequest(”test.pbj”));
}

// shaderLoader complete handler
private function shaderLoaded(event:Event):void {

// set up shader

_shader.byteCode = _shaderLoader.data as ByteArray; // error if invalid
_shader.data.src.input = _bitmap.bitmapData; // image input
_shader.data.size.value = [100]; // constant size
_shader.data.fade.value = [.5]; // constant fade value

// draw the shader every frame
addEventListener(Event.ENTER_FRAME, drawKaleidoscope);

}

// enterframe handler
private function drawKaleidoscope(event:Event):void {
// base position on mouse location
_shader.data.position.value = [mouseX, mouseY];
// rotate constantly over time
_shader.data.angle.value = [getTimer()/500];

// draw a rectangle with the shader fill
graphics.clear();
graphics.beginShaderFill(_shader);
graphics.drawRect(0,0,300,250);
}
}
}[/as]

and the Pixel Bender code:

kernel Kaleidoscope
< namespace : “Petri Leskinen”;
version : 1;
vendor : “”;
description : “kaleidoscope -effect, rectangular”;
>
{
parameter float4 fadeColor
<
minValue: float4(0,0,0,0);
maxValue: float4(1,1,1,1);
defaultValue: float4(0,0,0,1);
description: “Fade color”;
>;
parameter float2 position
<
minValue: float2(0,0);
maxValue: float2(2880,2880);
defaultValue: float2(250,280);
description: “Center point”;
>;

parameter float size
<
minValue: float(1);
maxValue: float(500);
defaultValue: float(75);
description: “Size”;
>;

parameter float fade
<
minValue: float(0.5);
maxValue: float(1.0);
defaultValue: float(1.0);
description: “Fade”;
>;

parameter float angle
<
minValue: float(-3.14159);
maxValue: float(3.14159);
defaultValue: float(0.5);
description: “Rotation angle”;
>;

input image4 src;
output pixel4 dst;

void evaluatePixel()
{
float sina = sin(angle);
float cosa = cos(angle);

float2 newC = position – size/2.0* float2(cosa+sina, cosa-sina);

// mx matrix for rotation and scaling
// mxR reverse transformation
float2×2 mx = float2×2( cosa,sina,-sina,cosa) /size;
float2×2 mxR = float2×2( cosa,-sina,sina,cosa) *size;

// coordinate p1 on the new coordinate system,
// on the center area 0.0 < p1.x < 1.0 , 0.0 < p1.y < 1.0
float2 p1 = mx * (outCoord() -newC);

// p2 integer part, p1 only decimal part,
// which maps every pixel to the center area
float2 p2 = floor(p1);
p1 = fract(p1); // p1 -= p2;

// p3 dislocation for mirroring,
// mirrored if integer part odd
float2 p3 = 1.0-2.0*p1;
p1.x += mod (p2.x,2.0) > 0.0 ? p3.x : 0.0 ;
p1.y += mod (p2.y,2.0) > 0.0 ? p3.y : 0.0 ;

// reverting to the main coordinate system, sampling and mixing the pixel
p1 = newC + mxR*p1;
dst = mix( fadeColor, sampleLinear(src,p1) ,
pow ( fade,abs(p2.x)+abs(p2.y)) );

}
}

Add comment May 19th, 2008

How to compile and examples for Flash Player 10 or ASTRO BETA

As many of you know ASTRO is in Public beta.

Download browser plugin

Here are some links on how to compile:

Text instruction – by Mike Chanmbers

Video Instruction – by Lee Brimelow

Flash Magizine Article

A promising sound example:

flash produced sound example – by Keith Peters

Here is my “3D” example, quick and dirty:

[as]

package {
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Vector3D;
import flash.net.URLRequest;

public class ASTRO extends Sprite
{

private var _loader:Loader;
private var mc:MovieClip;
public function ASTRO()
{

stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.EXACT_FIT;
_loader = new Loader()
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete, false, 0, true);
_loader.load(new URLRequest(”record.gif”));

}

private function loadComplete(evt:Event):void
{

mc = new MovieClip();
mc.rotationY = 0;
mc.rotationZ = 0;

stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove, false, 0, true);
mc.opaqueBackground = true;
_loader.x = – (_loader.width * 0.5);
_loader.y = – (_loader.height * 0.5);
mc.addChild(_loader);
mc.x = (_loader.width * 0.5);
mc.y = (_loader.height * 0.5);
addChild(mc);

}

private function onMove(evt:MouseEvent):void
{
mc.rotationZ = stage.mouseY;
mc.rotationX = stage.mouseX

}
}
}
[/as]

Also here are some classes that I saw through code completion. I don’t really know what to do with them yet. Maybe someone else will and will let me know (I have too much work and GTAing to do :) ).

  • flash.text.engine Package (over a dozen classes)
  • __AS3__.vec.Vector (that is wierd)
  • flash.display.GraphicsBitmapFill
  • flash.display.GraphicsPathCommand
  • flash.display.TriangleCulling (that sounds interesting)
  • flash.geom.Vector3D
  • flash.filters.ShaderFilter

Happy Coding!

1 comment May 16th, 2008

How to use Bitmap and BitmapData in ActionScript 3 – v3

example of BitmapTest 3 Alright, this example is very similar to the other examples I have done. But with this one I am scaling all pixels at the same rate. Just click on it the image in the example (more…)

Add comment April 29th, 2008

How to use Bitmap and BitmapData in ActionScript 3 – v2


Alright, in this example, I am cutting each pixel in an image and piecing it back together again. Only this time I animating the pixel to a new location, piecing back the image at 200%. I think this can open a lot doors in what you can do with a bitmap. (more…)

Add comment April 23rd, 2008

How to use Bitmap and BitmapData in ActionScript 3 – v1

snapshoot of bitmapData  test

So the last couple of weeks I have been jacking around w/ Bitmaps and BitmapData. I’ve always wanted to try it but never had the courage. Now that I have, I wish I’d have done it sooner.

In this first example I’m just copying each pixel throwing it to the wind and using Tweener to animate it to a spot. I don’t think Tweener is the best option course as you can see it runs slow. I’m also using Grant Skinner’s Memory Gauge to illustrate how slow it is. This is just a proof of concept anyway.

(more…)

Add comment April 21st, 2008

Adobe Evangelist Daniel Dura visits Travelocity

So today Daniel Dura, an Adobe Evangelist, came by Travelocity to talk about Flash, Flex and AIR. It was interesting to here him speak and his hair was redder then pictures led on. But I won’t hold that against him. (more…)

Add comment April 15th, 2008

Next Posts Previous Posts


About This Blogger

Josh Weatherspoon is a Flash Platform Developer and self-proclaimed millionaire who still has to work at Travelocity in Dallas(Southlake), TX

Feeds

Most Recent Posts

Categories

Links

29

Find a Ultrasound school near you