Wednesday, July 18, 2012

JSFL Rocks

I've always loved being able to automate repetitive tasks. Whether using AppleScript with Quark or Lingo with Director in the 1990s, to shell scripting Solaris and OSX, Illustrator with JavaScript, or Python with Blender.

For some reason, I've neglected JSFL with Flash (JavaScript automation for Flash Professional). It's been in the software since 2004. Recently I started looking into it, given the amount of documentation on the subject I think I know why I waited, but now I wish I didn't. The thrill of being able to type a few lines of code to save you time and drudgery is addictive when it hits.

I just had a small but practical real world use of my newfound JSFL skills on a FLA I am building. I'd created 9 symbols and set there base class to flash.display.Sprite as I made each one. After the fact, I decided that the 9 symbols that I'd made sprites should really be flash.display.MovieClip. In less time than it'd take to open up each one's property dialog and reassign its base class, I was able to type run the following in my script:


function changeBase(){
for each( var i in fl.getDocumentDOM().library.items){
i.linkageBaseClass = "flash.display.MovieClip";
}
}
changeBase();

If you've never tried JSFL before, here are some simple steps to get started.
  1. Create a text document with the JSFL extension.
  2. Add your code.
  3. From Flash, select Commands -> Run Command...
  4. Find your JSFL file (from step 1)
Start simple with a file like this, hello.jsfl:
alert("Hello, world!");

Then wrap it in a function:
function hello(){
alert("Hello, world!");
}
hello();

The code outside the function is what actually executes. This makes it easy to add additional functions and test. Eventually, you can create a gui for your code in Flash and create your own tools that appear under Window -> Other Panels, but that's a post for another day. In the meantime, here is some more info from Adobe's site as well as a PDF reference.

Thursday, April 26, 2012

iPad Art

I finally have my own iPad and I broke it in with a first for me, a sketch entirely created on an iPad. The sketch features the star of four of my Blender training courses.

I did the initial line work in Adobe Ideas, then brought it into ArtRage for some painting, finally I imported that into Photoshop Express to do some adjustments. Drawing and painting with your finger takes some getting used to, but it can be fun.

Saturday, April 14, 2012

Astra Itinera on Facebook

I have a Facebook page for my game Astra Itinera. Check it out for the latest news and tips. Note: You do not have to be a member of Facebook to browse the page.

Saturday, March 31, 2012

Astra Itinera

My first iPad game, Astra Itinera, is now available on iTunes! Astra Itinera is a turn-based strategy game. Check out the Facebook page.

Astra Itinera grew out of my AS3 Strategy Games tutorial series. If you'd like to learn how to create random terrains, use connected component labeling, A* (a-star) pathfinding, state machines and more, check out the tutorial

Recommended by MacMost.com: "The interface is simple, but the game play is deep."

Mentioned in the CartoonSmart.com blog.

Tuesday, February 14, 2012

MovieClip Buttons in AS3

Note to self: When using Flash's ability to make a MovieClip a button by adding frame labels _up, _down, and _over remember to set both buttonMode=true and mouseChildren=false. Somehow I always forget the latter! Throw in the useCursorHand=true for good measure.

Tuesday, December 06, 2011

Playing with Processing

I've been fascinated with Processing lately. So I decided to port a small part of my terrain generation code from my Strategy Games in AS3 series. I was surprised at how easy it was to port and how fast it runs. An unexpected benefit, I found that rethinking a problem by writing it in a different language gave me better insight into the problem I was originally solving.

Tuesday, November 22, 2011

State Machines


The third course--State Machines-- in my Strategy Games in ActionScript 3 series is now available from CartoonSmart.com.
  • 5 hours
  • Learn to master state machines in part 3 of the Strategy Games in AS3 series. Attach A* to sprites to move them across terrains, bringing together the two previous parts of this series.
  • Create a shaded terrain.
  • Dynamically adjust contrast with the ColorMatixFilter class.
  • Create multiple states for an object.
  • Progress from a simple switch statement to object-oritented states.
  • Create multiple players.
  • Learn to create a turn-based environment for units and players, for both human and computer input.
  • Create computer opponents.
  • Create multiple unit types: land, air, computer and human.
  • Use the bitmap class to create a “fog of war” that reveals the map as units move.
  • Differentiate between turn-based and non-turn-based states (and support both).
  • Add combat between units.
  • Refactor to use a singleton design pattern.


You can also get a bundle of all three courses, 10 hours of training:
  • Terrains
  • A* Pathfinding
  • State Machines