Something Wrong with the System

A Flash/Actionscript blog

Zoom In/Out Image viewer (.swf & source)

First of all, I made it to ten posts! W00, I really wasn’t sure if I’d make it this far.

Recently at work, I had to write an AS3 image viewer with zoom and pan capabilities. It was a lot harder than I had anticipated. I decided to write another (much better) version for the blog. I’m hoping that by releasing this code I’m saving a couple people a lot of grief.

You can zoom in/out with the buttons in the bottom right corner, or by using your mouse wheel (Mouse wheel might not work on a Mac! Let me know if it’s an issue or if you have a solution).

After the break you can see the application in action.

I’ll also try to explain some of the ActionScript parts I found interesting.

Read the rest of this entry »

May 18th, 2008 by Peter Organa

Colour Seperator (.swf and source)

Update May 27, 2008: Hey guys I just found a much better way of doing colour separation. The code below takes a very brute force approach. It seems the Flash engineers were one step ahead of me though. There’s a method called copyChannel() which essentially takes a selected colour channel from one bitmap and moves it into another. The below code is still a decent introduction to parsing through bitmaps and bitwise operators. It’s just not the efficient way to do this task.

After the Red tick failure this morning, I wanted to get right back into it and do something quick.

In this project I:

A) Load in an external image

B) Read in all of the image’s pixel values and split the data in to red, green, blue.

C) Feed the colour data into seperate layers

D) Animate ’em!

I’ll go into the code after the break.

But first:

I stumbled upon this link while looking into bitwise operators:

Bitwise gems

It’s a great resource and I’d strongly suggest looking into it, especially if you’re not familiar with getting colour data out of hex numbers.

Read the rest of this entry »

May 12th, 2008 by Peter Organa
Posted in AS3, Programming, Source Code | Comments Off on Colour Seperator (.swf and source)

Angry red tick (.swf)

Angry Red TickSo first of all I’m not dead! I haven’t given up on blogging, experimentation or coding.

But I did run in a completely wrong direction with my latest experiment. This is actually a bit of an epic failure. It’s SUPER slow, doesn’t look great… meh.

But I did some cool stuff with colour transitions and the tentacles are kind of cool.

So check out the full post to see the working swf, my apologies if it’s really slow on your computer 😀

No source this time guys, it’s just too much of a mess.

Read the rest of this entry »

May 12th, 2008 by Peter Organa

The Forever Tree (.swf) update: (& source)

Ok, this was a totally accidental project. I was planning on doing a GSkinner style branching tree, and ended up with something kind of cooler.

Here’s an image from the app:

foreverTree image
Click to see it in action

I’m especially happy with the seeded random code, it’s based off of the perlin noise function.

I’ll probably post the source code early next week. But right now it’s time for Team Fortress 2!

UPDATE:
Just finished playing, so I can go ahead and post the source. This one is more messy than usual.
Click to Download Source

May 4th, 2008 by Peter Organa

pixelizer [cooler version] (.swf and source)

Ok, I came up with a slightly cooler version of the pixelizer that I posted posted a couple days ago.

This code is a little harder to follow. But on the bright side, I’ve added 3d Effects and BLUR! WOO!

Read the rest of this entry »

May 3rd, 2008 by Peter Organa

Pixelizer (.swf and source)

Ok, new project!
This took a few hours to get going, largely because I did the ball spin animation and scrollbar from scratch. Hopefully I’ll reuse them!

You can pretty much ignore every class in this project except: pixelEngine
That’s where the magic happens!

public function setBitmapSize(newScale:Number) {
var newBitmapWidth:Number = maxBitmapWidth / newScale;
var newBitmapHeight:Number = maxBitmapHeight / newScale;
//
myBitmapData = new BitmapData(newBitmapWidth, newBitmapHeight, false, 0x000000);
//
var bitmapScale:Number = 1 / newScale;
myMatrix = new Matrix();
myMatrix.scale(bitmapScale, bitmapScale);
//
myBitmapData.draw(mySource, myMatrix);
myBitmap = new Bitmap(myBitmapData);
myBitmap.width = maxBitmapWidth;
myBitmap.height = maxBitmapHeight;
...
}

Here are the fundamentals:

  1. Figure out the size of your new bitmapData by dividing the maximum size by your reduction value. So if you’re doing a 4x reduction and your fullsize image is 200 pixels: 200 / 4 = 50 pixels.
  2. Create a matrix and change it’s scale. This will squeeze the captured image into the reduced space of the new bitmapData
  3. Draw the source data into your bitmapData, make sure to include the Matrix.
  4. Stretch your new small bitmap to fill the screen

That’s it! The rest of the code is there as support structure.

Click to see the finished project and download the source.

Read the rest of this entry »

April 29th, 2008 by Peter Organa

pixelStorm ver.2 (.swf with Source)

Ok, my first AS3 post.

This week I went to FITC. I had a really good time, I went to a bunch of really interesting sessions, got drunk at the open bar and hung out with Grant Skinner for a while. Good times.

The important thing I learned from FITC is that: A) I should do more experimental work B) I have to start a blog so I can share my work with others.

So, here it is. My first post-FITC AS3 code post! I call it pixelStorm (sounds like a straight to VHS movie circa Lawn Mower Man)

I got the idea from GMUNK’s session: He mentioned a rejected project where words would appear on screen one pixel at a time.

Click to see the swf and download the source.

Read the rest of this entry »

April 27th, 2008 by admin