Posts Tagged ‘AS3’

Flash 3D Coming Soon

Wednesday, November 10th, 2010

At MAX 2010, Adobe announced new APIs for Flash player. Code named ‘Molehill’, they give developers low level access to 3D hardware acceleration through the GPU.

The current version of Flash provides us with 2.5D content; not quite 3D. But with frameworks and libraries like Away3D, we could stuff a 3D engine into Flash. Now the engine will be built-in with GPU support, allowing content with faster frame rates, more triangles, and better lighting and shaders. But because the APIs are low-level, developers will need to use frameworks to simplify development. Check out these videos for all the details:

3D APIs for Adobe Flash Player and Adobe AIR

Flash Player 3D Future


Options for Online 3D Content

Thursday, September 2nd, 2010

The Flash plugin is required to view this object.

3D movies, 3D TVs, 3D cameras and camcorders, 3D cell phone displays… The 3D craze is well underway. So here’s a list of my favorite 3D development apps.

3D in Flash – Since Flash CS4, Movie Clips could have 3D transformations (position and rotation, but not scale). It’s a primitive 3D engine. In fact, Adobe calls it 2.5D. It’s more than 2D, but not quite 3D.

There are also 3D libraries such as Papervision3D and Away3D that can be imported into your Flash project that will give you a real 3D engine. These are great if you need to use Flash for your project, but you’re still limited to bending a primarily 2D program into 3D. Also, Flash comes with a lot of overhead and it is not the most efficient or fast solution for 3D content.

Virtools – Virtools offers a unique coding experience in which the programmer adds functionality by linking together behavior blocks in a schematic drawing, similar to a flow chart. It’s a very fast way to get basic functionality on your game assets. For example, to make a box rotate, just drop the box model in the 3D view to add it to the scene, then drop the Rotate behavior on it. In the schematic view, draw a link from the output of the Rotate behavior back to its input and you’re done. There’s not a single character of code to write, and it only takes about 5 clicks of the mouse. Of course, this is a pretty simple example, but most of it really is that easy. If you want more control, you can click a few more times to specify how fast it rotates and in which axis. You can also create your own behavior blocks if the hundreds that come with Virtools doesn’t have what you need. The downside to Virtools is that it is ridiculously expensive. Seriously, Virtools, offer a free version and lower the price to build your install base. You’d make up for it in volume.

Unity3D – Like Virtools, Unity is an integrated development environment (IDE) for building 3D games and simulations. I just started playing with it, but so far I like it a lot! Programming in it is not nearly as easy as in Virtools, but it is about the same as coding with Actionscript. It beats Flash with Papervision or Away3D when it comes to everything else. It’s a pain in the neck to get 3D models into Flash. In Unity, just save your assets in the Assets folder. They’ll now show up in your assets list in Unity. Also, because Unity is a real 3D engine, Flash can’t compare in visual quality to what you can do with Unity. Unity comes in a free version and a pro version, plus add-ons for developing for iOS or Android. And Unity 3.0 is coming out soon!

So there you have it; 4½ 3D development solutions (Flash by itself only counts for ½).


How to Read a Binary Watch

Wednesday, August 11th, 2010

The Flash plugin is required to view this object.

A while ago, I received a Binary watch as an anniversary gift. Since then, I frequently get asked how I read it. So let me break it down for you.

First, note the Flash app to the left. I built this for my Chumby, but the inspiration came from my watch. The main differences are that I put in a line of bits to show seconds, and I gave it the ability to show the date. Tap the watch face to view the date for five seconds. If you’re reading this, 01 The One, take some notes.
(more…)


Duplicate MC in AS3

Thursday, July 15th, 2010

The Flash plugin is required to view this object.

So, the other day I was looking for a way to duplicate a movie clip that the user clicks on. In my case, I had lots of buttons made of the MCs that I wanted to copy. I could have made a big switch statement like this:


(more…)


Database access with a Chumby

Thursday, May 6th, 2010

Chumby, Database AccessIn my earlier posts, I’ve writen about writing a Chumby widget, writing a configuration widget, and accessing the accelerometer. Now we’ll look at accessing a database from a Chumby widget.

First, you’ll need to set up a database. I’ll assume you have access to a web server and know how to create a database, tables, and code to access it. I use MySQL and PHP.

You’ll also need a Chumby widget.

And to connect the two, you’ll need a crossdomain.xml file.
(more…)


Accessing the Chumby Accelerometer

Friday, March 26th, 2010

Chumby Accelerometer
Let’s take a look at the Chumby accelerometer. It’s the thing inside Chumby that tells it if it’s looking up or down, sideways, or up-side-down. It also detects sudden changes in acceleration. It’s basically an electronic inner ear. So if you shake Chumby, knock him on the side of the head, or drop him on the floor, the accelerometer will detect this and report how hard and in what direction the jolt happened. Disclaimer: I do not recommend or endorse violent behavior to Chumby, including hitting, shaking, throwing, or dropping.

If you’re familiar with Actionscript, you know that it’s pretty easy to find the position of the mouse cursor on the stage. Well, it’s also easy to get data from the accelerometer. The trick, however, is making use of it. Let’s take a look.
(more…)


More Fun With Flash

Monday, March 22nd, 2010

The Flash plugin is required to view this object.

Here’s a little thing that I wrote a while ago while learning the Flash particle system.  It just makes little light blurbs generate from your mouse pointer.  It’s pretty neat, and if you don’t know how to generate particle effects in Action Script 3, the code might help you out.  Check it out if you want to.

If you find it helpful or fun, let me know in the comments.  Thanks for reading!  Code when you click through…



(more…)


Creating a Chumby Configuration Widget

Friday, February 26th, 2010

In my last post, we quickly went over Writing your first Chumby widget. This time, we’ll expand on that by adding a configuration widget.

A configuration widget is another Flash file that sets up parameters for your Chumby widget, so those settings are available when the widget loads into your Chumby. For example, perhapse you have an analog clock widget. You could create a configuration widget that allows someone to choose a color for the face of the clock, or whether or not to display the second hand. The user could choose a color and save their preferences in the Chumby database. Then, when their Chumby loads your clock widget, it would look for and download any settings for that widget.

Here’s what we’ll need:

(more…)


Writing your first Chumby widget

Monday, February 1st, 2010

tic-toc-goes-the-clockSo, you got your first Chumby and have browsed through the 1500 open source widgets, and now you’re ready to contribute to the open source community by writing your own widget. There’s lots of resources out there, so we’ll just cover the basics here.

Here’s what you need:

  • A Chumby
  • Adobe Flash or other developing environment for creating SWF files
  • An account at Chumby.com

Open up Flash. Set your size to 320 x 240 and frame rate to 12 frames per second. In Publish Settings, set the Player to Flash Player 8 and the Script to ActionScript 2.0. Chumby allows widget up to 100kb in size, which is plenty of room for code, but can get tight when working with audio and video.

For this tutorial, we’ll make an analog clock. But there are hundreds of clocks already! Yes there are, but I like to have every other widget be a clock, and I’ve only found about a dozen clocks that I really like. That is one of its primary functions, after all.

First of all, set up your assets. You’ll need three clock hands, positioned in the center of the stage, with the registration point properly set. Name them hourHand_mc, minuteHand_mc, and secondhand_mc.

OK, now the code:

onEnterFrame = function() {
	dt = new Date();
	//set hour hand
	hrs = dt.getHours()+dt.getMinutes()/60+dt.getSeconds()/3600;
	angle = hrs*30;
	if (angle!=hourHand_mc._rotation) {
		hourHand _mc._rotation = angle;
	}
	//set minute hand
	mns = dt.getMinutes()+dt.getSeconds()/60;
	angle = mns*6;
	if (angle!=minuteHand_mc._rotation) {
		minuteHand _mc._rotation = angle;
	}
	//set second hand
	scs = dt.getSeconds();
	angle = scs*6;
	if (angle!=secondHand_mc._rotation) {
		secondHand _mc._rotation = angle;
	}
}

Let’s break it down. On each frame we create a new date object. Then we get the hours of the date object. We also add in the minutes and seconds because we want the hour hand to move a tiny bit every second, not just once an hour. Next we convert the hours into degrees by multiplying by 30. (360 degrees per 12 hours makes 30 degrees per hour). Next we check if the hour hand needs to be changed. It should only be changed once every 12 frames, not every frame. Using this if statement prevents unnecessary redrawing of the screen, which can save processing time and make a widget run more smoothly. Though, you’ll probably not notice any difference in this simple example.

The minute hand and second hand go through the same process.

OK, save it, publish it, and upload it to Chumby.com, but don’t make it public yet. Add it to a channel on your chumby and try it out. You’ll undoubtedly find lots of things to tweak with your clock. Did you even give your clock a face? Maybe it needs a tick sound, or a gong on every hour. Maybe you don’t want a typical analog clock. Changing the code for a digital clock should be pretty easy.

This is a simple example, but it should get you on your way. In my next post, I’ll write about creating a configuration file, and playing with the accelerometer. (unless I forget or change my mind). Until then, make a cool clock.


The Problem with Probability

Friday, January 22nd, 2010

If you were to flip a coin 10 times, and it comes up heads each time, you might think, “On the next flip, it’s SURE to come up tails – it’s due.” If you flip the coin 10 more times and again it comes up heads each time, you might think, “The next flip will surely be HEADS. Just look at the statistics.” Of course, we know that any flip has just as much chance as being heads as it does tails (assuming the coin is evenly weighted and symmetrical). So how many flips does it take to change our feeling about the next flip? Somewhere between 10 and 20 flips? (more…)