Flash Cafe

Pictures as Music

February 22nd, 2010 nebutch

http://music.almerblank.com

R Blank has just revealed Synthia, a real-time image to music creator created in Flash. You can upload an image, then listen to it!

http://music.almerblank.com/

Hype/Papervision3D Demo

November 5th, 2009 nebutch

So after getting my hands on the new Hype framework, I wanted to put together a simple demo together that utilizes a combination of the SoundAnalyzer class and some 3D eye candy (via Papervision3D).

First off, I can say that I really like being able to play around with the sound spectrum using only a couple lines of code. I also used the Rythm class to run an enter frame method, which is very convenient in that I didn’t need to manually set up an event and listener.

Lastly, I wanted to also utilize a tweening engine to smooth out the particle movement, but doing so cut the framerate by about 80% (a little better with TweenMax/TweenLite, but still not good enough). I also briefly played around with the Flint particle emitter, but I’m not familiar enough with Papervision/Flint to get it working how I wanted.

UPDATE – I decided to give a tween engine one more shot, and was able to use TweenMax while keeping the framerate at an acceptable level.

UPDATE 11/06/2009 – Updated code sample to reflect demo swf.

Read the rest of this entry »

Hyped about Hype

October 30th, 2009 nebutch

I just came across one of the coolest AS3 toolkits I’ve seen in a long time – Hype. Basically, the point of Hype is to make UI design as easy and fast as possible. It includes commonly used algorithms used in visual and audio design such as grids, shapes, random placement, chaos patterns, and audio spectrum calculations. It’s also capable of calculations such as custom timing (run a callback every 2nd frame, etc) with minimal coding requirements, and a callback system that is much more efficient than AS3’s native Event system.

Another great feature is the use of Object pooling and unordered lists. The concept of this is to minimize Object creation (thereby keeping memory requirements as small as possible) by recycling Objects rather than recreating them on the fly. This is obviously a standard best practice when designing code projects, but Hype will do the dirty work for you and let you focus on the fun stuff.

From the looks of the intro video, the toolkit looks to be well-written using a combination of a core framework and an extension package (which is highly flexible and easily built upon). It looks like a minimal set is included for now, but I’m sure additional extension kits will be added along the way (plus allow developers to add/share there own).

The framework is slated for release on Saturday, October 31st.

Check out the video HERE, and the examples HERE.

Happy coding ;)

Snow Leopard doesn’t like Flex Builder…

October 13th, 2009 nebutch

..or vice-versa.

After starting my new gig with Almer/Blank today, I changed my workflow a bit to incorporate my Macbook along with an external 21″ display. The primary development environment in our projects is Flex Builder.

nom nom nom

Well, the first thing I noticed when going in to edit a file was that the line numbers weren’t tracking correctly with the page scrolling. I figured that this was a fluke, so I tried restarting Flex Builder. Nothing. Tried again. No go. With some tight deadlines, I kind of put that aside and pushed through without using line numbers (which really sucks, if you get used to relying on them like me). After things slowed down a little, I came across this bug ticket: Read the rest of this entry »

Are you a dick?

April 10th, 2009 nebutch

I came across the following image on Fark.com, and something about it tickled my geek bone.

PI

From FlashDevelop to xCode : Duplicate Line

April 6th, 2009 nebutch

So over the past month or so, I’ve decided to delve into the wonderful world of Objective-C and Cocoa. I’ve been using xCode as my primary IDE, and so far I love it. However, one nagging issue about xCode is that there is no “Duplicate Line” or “Delete Line” hotkey as there is in FlashDevelop, which I’ve been using for years for most of my AS development. While I *could* try to get used to the old “Option” + drag method or copy/paste, I found myself spoiled by the quick hotkey action that FD offers (which by default is Ctrl+D for duplicating and Ctrl+Shift+D for deleting. There’s also a handy “transpose” hotkey, which I won’t go into).

So doing some research, I came across a couple of options. One option requires that you create a User Script in xCode and assign whatever hotkey to that. You can find more information HERE. I decided not to use that solution because there was no “Delete line” code source, and I frankly wasn’t in the mood to learn Ruby in order to customize my own script (yet).

The second option is to create a Dictionary file and customize your script very easily using the Mac OSX Key Binding documentation as a reference. Here’s what you do:

- Create a new .dict file in the following directory : home/Library/KeyBindings/PBKeyBinding.dict
Note : If the KeyBindings directory does not exist, you’ll need to create it.

- Add the following code:

{
"^$K" = (
"selectLine:",
"cut:"
);
 
"^$D" = (
"selectLine:",
"copy:",
"moveToEndOfLine:",
"insertNewline:",
"paste:",
"deleteBackward:"
);
}

- Save the file, restart xCode if it was already open.

So with the above code, placing the cursor within any line then hitting the key combo ‘Control + Shift + K’ will delete that entire line, and hitting ‘Control + Shift + D’ will duplicate it.

Thanks to TypeOneError for posting the initial info on this. One thing that I did change from the original code is that I added a “deleteBackward” command at the end of the Duplicate Line section. This will place the cursor back at the end of the line just created, rather than at the beginning of a new line (which is more like what FD’s behavior is). The obvious beauty of this is that you can recursively hit the hotkey combo and duplicate lines without having to place your cursor back up into the previous one. You can further customize or add other bindings by referencing the Mac OSX Key Bindings documentation.

I may delve into this a bit more and see about a ‘Transpose’ hotkey, which switches placement of the last two selected lines of code, but I’m in no hurry.

Merry Christmas!

December 24th, 2008 nebutch

To celebrate both the holiday and my new gig with Animax Entertainment, here’s a little Christmas diddy. Canadian style, eh. :)


Mr. President

November 5th, 2008 nebutch

Congratulations, Barack Obama!

small_obama_image.jpg

I’m definitely proud as an American that we as a Nation came together and voted for change. Now that we chose, let’s all make sure that we stand behind our new President and do our parts to steer the USA into better waters – Democrats and Republicans alike.

Flash CS4: Using FileReference.load() for bitmaps

November 2nd, 2008 nebutch

Lee Brimelow did a nice tutorial a while back showing us how to load text into a browser based .swf using Flash’s new FileReference.load() method. Here’s how to take it a step further and load in a local bitmap, cast it as a Bitmap object, and resize it proportionally. I don’t include any code on actually uploading the file to a server, as that is another topic altogether, but if I get some demand for it, I’ll try to put together an example of doing that with PHP…

Here’s the code:

package
{
	import fl.controls.Button;
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.display.MovieClip;
	import flash.net.FileFilter;
	import flash.net.FileReference;
	import flash.text.TextField;
	import flash.text.TextFieldType;
 
	import flash.events.MouseEvent;
	import flash.events.Event;
 
	public class  BitmapLoader extends MovieClip
	{
		private static const _MAX_WIDTH		: Number = 790;
		private static const _MAX_HEIGHT	: Number = 560;
 
		private var _fileRef			: FileReference;
		private var _fileFilter			: FileFilter;
		private var _loader			: Loader;
		private var _bitmap			: Bitmap;
		private var _browseBtn			: Button;
		private var _staticTxt			: TextField;
		private var _browseTxt			: TextField;
 
		public function BitmapLoader ( )
		{
			_init ( ) ;
		}
 
		private function _init ( ) : void
		{
			_staticTxt = new TextField ( ) ;
			_staticTxt.type = TextFieldType.DYNAMIC;
			_staticTxt.x = 10;
			_staticTxt.y = 10;
			_staticTxt.height = 21;
			_staticTxt.text = "Select an image:";
			addChild ( _staticTxt ) ;
 
			_browseTxt = new TextField ( ) ;
			_browseTxt.type = TextFieldType.INPUT;
			_browseTxt.x = _staticTxt.x + _staticTxt.width + 4;
			_browseTxt.y = 10;
			_browseTxt.height = 21;
			_browseTxt.width = 200;
			_browseTxt.border = true;
			_browseTxt.background = true;
			addChild ( _browseTxt ) ;
 
			_browseBtn = new Button ( ) ;
			_browseBtn.label = "Browse";
			_browseBtn.name = "browse";
			_browseBtn.x = _browseTxt.x + _browseTxt.width + 4;
			_browseBtn.y = 10;
			_browseBtn.useHandCursor = true;
			_browseBtn.addEventListener ( MouseEvent.CLICK, _handleMouseEvent ) ;
			addChild ( _browseBtn ) ;
 
			_fileFilter = new FileFilter ( "Image", "*.jpg;*.gif;*.png;" ) ;		
 
		}
 
		private function _handleMouseEvent ( evt : MouseEvent ) : void
		{
			switch ( String ( evt.target.name ))
			{
				case "browse" :
					_fileRef = new FileReference ( ) ;
					_fileRef.browse ( [_fileFilter] ) ;
					_fileRef.addEventListener ( Event.SELECT, _onImageSelect ) ;
					trace ( "Browse" ) ;
				break;
			}
		}
 
		private function _onImageSelect ( evt : Event ) : void
		{
			_fileRef.load ( ) ;
			_fileRef.addEventListener ( Event.COMPLETE, _onDataLoaded ) ;
			_browseTxt.text = String ( evt.target.name ) ;
		}
 
		private function _onDataLoaded ( evt : Event ) : void
		{
			var tempFileRef : FileReference = FileReference ( evt.target ) ;
			_loader = new Loader ( ) ;
			_loader.contentLoaderInfo.addEventListener ( Event.COMPLETE, _onImageLoaded ) ;
			_loader.loadBytes ( tempFileRef.data ) ;
		}
 
		private function _onImageLoaded ( evt : Event ) : void
		{
			_bitmap = Bitmap ( evt.target.content ) ;
			_bitmap.smoothing = true;
			_bitmap.x = 5;
			_bitmap.y = _browseTxt.y + _browseTxt.height + 5;
			addChild ( _bitmap ) ;
 
			//Resize the image if needed
			if ( _bitmap.width > _MAX_WIDTH || _bitmap.height > _MAX_HEIGHT ) {
				_resizeBitmap ( _bitmap ) ;
			}
 
		}
 
		private function _resizeBitmap( target : Bitmap ) : void
		{
			if ( target.height > target.width ) {
				target.width = _MAX_WIDTH;
				target.scaleY = target.scaleX;
			} else if ( target.width >= target.height ) {
				target.height = _MAX_HEIGHT;
				target.scaleX = target.scaleY;
			}
 
		}
 
	}
 
}

And here’s a .zip including the FLA (must have CS4), SWF, AS, and JPG.

Enjoy ;)

Leave Sarah Palin ALONE!!!!

September 24th, 2008 nebutch

I normally don’t like to bring my political views outside the realm of friends and family, but the latest statement from Laura Bush has me in stitches. Here’s a quote from a recent press conference:

Mrs. Bush also said that she thinks Palin is being treated unfairly because she is a woman. That, the first lady says, is to be expected.

I have two issues with that statement…

First, we all know why Gov. Palin was picked for the #2 spot – get the Hillary voters. Fact is, she’s a woman. That’s a major factor in the GOP’s choice. It wasn’t ability to lead the nation, experience, foreign affairs, financial wizardry, or anything else that should be relevant to running the nation. Oh wait! She’s a hockey mom! That’s one thing at least… So to say that she’s getting any kind of treatment “because she’s a woman” is blatantly hypocritical.

Second,  it’s to be expected that she gets put through the ringer because 95% of our nation did not know who the hell this woman was before the veep announcement. I’m sure it’s safe to say that it would be expected for any candidate who the voters need more knowledge about so that we can make an informed decision at the polls. The fact that Sarah Palin happens to be a woman just puts ammo in the GOP’s shotguns, and gives them an easy way out.

So to prevent any further hurt feelings and possibilities of being sexist, I say to the media and common voter alike:

leavepalinalone.jpg

One more thing  – No matter who you think is the best candidate, get out and VOTE!! If you aren’t registered, go do it now…

  • Meta