Tag Archives: ActionScript

The slides from my presentation at FlashMidlands.

My FlashMidlands presentation has now taken place, and here’s my slides, to share with the world:

Introducing: The Flash Facebook Cookbook

I’ve been significantly less active on this blog recently, which is primarily down to the fact that, for most of the past year, in my evenings and weekends, I’ve been writing a Developers’ Cookbook for Packt Publishing – The Flash Facebook Cookbook which has just been unveiled for sale on the Packt Publishing website.

New! The Flash Facebook Cookbook

Pop on over to the Packt Publishing website to read all about it and, of course, place your order!

Simple Box2D – Custom Polygon creation.

I’ve been working on some classes to simplify Box2D for Actionscript developers (See previous post for a quick intro).  The latest update to these classes introduces couple of minor ideas, and one gosh-darned awesome idea, if I do say so myself.  Let’s start with the awesome things, and move on from there…

Awesome thing: Creating Custom Polygons

Or rather the methods for creating them.  Shapes in Box2D come in three basic flavours – circle, rectangle and custom polygon.  Moreover, everything must be convex (no inny bits), have no more than 8 sides, and can’t have holes.  On the plus side you can still make larger, more complex objects out of smaller ones – but it all involves a lot of thinking.

So, here’s the solution – or rather, the options.

Polygon creation option #1 – Creating a polygon from an array of points.

Using some clever triangulation code from Splashdust.net, there’s a simple method for creating any custom shape from an array of Point objects.  With this method you can create a shape with any number of sides, and not worry about whether the shape is concave or convex.  It’ll still break if the edges of your shape interest each other, and doesn’t support holes in the objects you’re creating, but it’s a start.

var array:Array = [ new Point( 0, 0 ), new Point( 10, 0 ), new Point( 10, 10 ), new Point( 20, 10 ), new Point( 20, 0 ), new Point( 30, 0 ), new Point( 30, 30 ), new Point( 0, 30 ) ];

world.createComplexPolygon( 50, 50, array );

Polygon creation option #2 – Creating a polygon from a shape in a library.

This is where things get cool.  Creating a shape from a series of points is all well and good, but it’s a laborious process to set up and modify.  You can create a shape in the Flash IDE, add your symbol to your library and import it to Box2D.  Currently this method only supports single shapes on a single layer, and only straight edges – but multiple shapes, layers and curved edges are definitely on the list for the future.

world.createPolyFromLibraryShape( 300, 100, "sampleShape", "vectorassets.swf" );

Read More…

Link: Using Deferred instantiation in Flex

Here’s a useful example – showing how you can implement deferred instantiation in Flex, but with Actionscript instead of mxml.

http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=2&postId=15826

ActionSnippet

ActionSnippet

This site has loads of little ActionScript snippets. There’s some cool stuff in there – click on ‘All Posts’ and you’ll see a list of them.
It’s got things like dragging and snapping to a grid, random sort, variable swap, etc etc.

http://actionsnippet.com/