Posts Tagged ‘BitmapData’

A symphony of light without sound.

Wednesday, April 15th, 2009

Heres my second submission to the AR contest. i call it.
“A symphony of light without sound.”

enjoy

 

I’m really not sure how to deal with the copyright’s situation. so i just leave it where i put the corrosponding code most of the time, hehe.

I try my best to give credit above and beyond where applicable.

And really i have such a terrible method of coding  i dont know what i should leave from fork to fork and what i dont need as you can see in what i call my “vestigial import evolution” system.

Since my grasp of AS3 goes about as far as questionable grammar and syntax, and try as i may i am just unable to wrap my mind around the class system as of yet (just know this all of you Flex programmers… you are the enemy). Sooo to get a little understanding of what youre seeing here i’ll explain my Nintendo Gauntlet style HACK and SLASH  method of coding.

I take whole classes, remove all the public, private, class, static etc. statements, paste everything in the main time line in flash, call the main function from the root in flash and work out errors from there :-) my theory is, if I did it, theres probably a better way.

I know i totally break everyones very well organized and pretty code structure and proceduralize it to my understanding. Just giving you a referance as to what youre looking at.

Something in the source is killing my whole post.
Heres a link to the code in a .txt file
http://www.splengy.com/FireWorksMidiAS3.txt
Flint, papervision, FlarManager.

the magic here is a midi Java applett written by a programmer named “abudaan”. as it turns out the week i decided to throw my self into Flash and AS3 this brilliant gentleman decided it was time to take alot of the complexity out of AS3 and midi communication. He wrote a beautifully simple set of java applets that connect to your systems midi devices and give you variables in flash.

to be honest thats the end of my understanding about it. the beauty is thats all ive needed to know up till now.

theres a java applet and swf that has to be running in a browser to connect to the midi hardware and translate midi to flash. it only runs on a single domain. so you cant connect to it from a differant domain. for instance your swf and the midi java applet have to be on Splengy.com, or 127.0.0.1,

then theres a block of code i copy and paste from file to file that gives me access to allmost anything i could need out of in bound midi communications.

http://code.google.com/p/miditoflash/

I’m going to do my best to get an online version running for any of you that have midi hardware plugged in. If not i’ll post a few more videos of velocity response and such.

ONLINE DEMO INFO!!

If for some reason youve allready clicked the links and are wondering why it doesnt work let me first ask you, do you have any midi hardware? You’ll NEED midi hardware (a keyboard, drum pad, retro midi wind controller, free energy device…) to make this work.

First click this link. it brings up the java midi bridge.(update java and flash player if you think you maybe should please) it should bring up a list of midi devices connected to your machine. if it doesnt, refresh the screen once or twice, it should work. then when you see a list of available midi devices click the one you want to use to input data, and click OK.

http://www.splengy.com/MIDI/src/bridge.html

Once all that is done and you have a connection to the applet click the link below.

http://www.splengy.com/MIDI/src/ARfireworksMidi2.swf

it will bring up the SWF in a differant window.

I USED MIDI NOTES  69, 70, 71, and 72 FOR THIS DEMO AND IT SHOULD REACT TO THOSE NOTES REGARDLESS OF THE CHANNEL#, GLOBAL RESPONSE TO THOSE NOTES.

if for some reason those notes do not get a response like the one in the video, do the refresh dance, refresh one then the other, and keep trying. it may or may not work for you, i have gotten it to work here pretty successfully.

You may need these. same markers for both examples.
patt012patt004patt010pmarker

submissionexamples.zip Both submissions one zip. virus scanned right before upload.

If you take a look at my past posts you’ll see that this is really a compilation of most of my work with AS3 up till this point used in 2 files. though my acomplishments may not be great in the scale of things, it doesnt detract from the works taken to get there. enjoy them.

A very happy birthday FLART!

Tuesday, March 24th, 2009

FIRST print this

then plug in your web cam. if you get a security window when you click the example thats to be expected, it wants your permission to use your webcam, please say yes.

this is easily some of the coolest stuff ive seen on the internet.

FLART is an acronym for FlashAugmentedRealityToolkit. fyi!

if nothing comes up please right click anywhere in the window, select settings, click allow and remember. this just gives the examples on my site access to your camers so we dont have to do this again. also check to see that the camera youre using is selected in the camera tab of the flash player security window. that concludes our breif tutorial on the flash players security settings, tune in next week when we learn to make a time machine out of things you may have lying around the house. and now the example.

just point your webcam at the paper you printed. 

Example below:

Enjoy

Birthday FLART

Birthday FLART

WebCam FUN now with Ripples!!

Tuesday, March 10th, 2009
I just LOVE this effect and flash. its like salt and food, i put it on everything.
first make the file midi capable, then add stuff, then ripples :)
couldnt be easier to do, just feed it bitmapData.
WebCamRipples with flash
WebCamRipples with flash

 

 

the camera is set to 960 x 720 thats what looks best on my projector. and i have a nice webcam.

It should default to your cameras highest resolution. if anyone has problems leave a comment and i’ll put up a 640 x 480 version.

And the code.
the ripple class is posted earlier on the site.

	import flash.events.Event;
	import flash.system.Security;
	import flash.text.TextField;
	import flash.text.TextFormat;	

	import Rippler;

    import flash.display.Bitmap;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.MouseEvent;

stage.cacheAsBitmap;

var camW:int = 960;
var camH:int = 720;

// Create the camera
var cam:Camera = Camera.getCamera();
cam.setMode( camW, camH, stage.frameRate );
cam.addEventListener(Event.ACTIVATE, active);

// Create a video
var vid:Video = new Video( camW, camH );
vid.attachCamera( cam );
addChild(vid);

var mainBmd:BitmapData= new BitmapData(960, 720, false, 0);
var mainBm:Bitmap = new Bitmap;

function active(event:Event){
	addEventListener(Event.ENTER_FRAME, onEnterFrame );
} ;

function onEnterFrame(event:Event) : void
	{
		mainBmd.draw(vid);
		var mainBm:Bitmap = new Bitmap(mainBmd);
		//addChild(mainBm);	

	};			

        var _target : Bitmap = new Bitmap(mainBmd);
        var _rippler : Rippler;

        function Ripple()
        {
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;

            // create a Bitmap displayobject and add it to the stage
            _target = new Bitmap(mainBmd);
            addChild(_target);

            // create the Rippler instance to affect the Bitmap object
            _rippler = new Rippler(_target, 160, 16);

            // create the event listener for mouse movements
            stage.addEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove);
        }

        // creates a ripple at mouse coordinates on mouse movement
        function handleMouseMove(event : MouseEvent) : void
        {
            // the ripple point of impact is size 20 and has alpha 1
            _rippler.drawRipple(_target.mouseX, _target.mouseY, 50, .65);
        }

Ripple();

WebCam snippet

Tuesday, March 10th, 2009

I figured around the time of the cam ripples post id share my webcam snippet.

in changing over from AS2 to AS3 i had to search out the new code for camera interaction.

as with all things theres many ways to do it.

ive come up with a snippet i use all the time. it’s set to a camera resolution of 960 x 720.

i have a logitech 9000 pro.

it kicks arse

change the resolution if you want but i think flash defaults to the highest available resolution if your hardware doesnt support whats called for.

First we set our width and height,  grab the default camera ,create a video object to attach the camera to, create our “when camera becomes active” listener, and add the camera to the display list.

then theres a little bitmapData action happening in there,  followed by its partner in crime, the bitmap.

when the camera is active we add our holy enterframe listener and in the enterframe event we have that bitmapData draw() our video object giving us access to fresh bitmapdata from the camera when ever we need it.

the first line there, stagecacheAsBitmap; isnt necessary but i spent DAYS looking for those words in that order, i wanted to draw() the stage and couldnt for the life of me. So i’m leaving that line there hoping someone will stumble upon it and either end their search or be inspired by a new possability.

stage.cacheAsBitmap;

var camW:int = 960;
var camH:int = 720;

// Create the camera
var cam:Camera = Camera.getCamera();
cam.setMode( camW, camH, stage.frameRate );
cam.addEventListener(Event.ACTIVATE, active);

// Create a video
var vid:Video = new Video( camW, camH );
vid.attachCamera( cam );
addChild(vid);

var mainBmd:BitmapData= new BitmapData(960, 720, false, 0);
var mainBm:Bitmap = new Bitmap;

function active(event:Event){
addEventListener(Event.ENTER_FRAME, onEnterFrame );
} ;

function onEnterFrame(event:Event) : void
{
mainBmd.draw(vid);
var mainBm:Bitmap = new Bitmap(mainBmd);
//addChild(mainBm);

};

Ripple class

Sunday, March 8th, 2009

So heres a ripple effect i absolutely love. I like it so much i made it my banner. Really simple to use, runs pretty damn smooth if i do observe correctly. thats pretty good for all the bitmap data that used to and still can completely bog a system. 

You’ll see later it can be applied to a live webcam :)

 http://www.derschmale.com/2008/08/03/water-ripples-revisited-as3-only-version/

heres the tutorial i got it from i think.

enjoy :)