Tag: Flash
Flash Stuff Here. Move Along…
In the middle of a cool project which is right on the cusp of being designered into oblivion, I discovered a nifty way to make things “snap to” a grid. Copy-and-paste into Flash MX/MX2004.
var gridSize = 20; // size of grid var nodeSize = 20; // size of individual nodes var nodes = 50; // number of nodes var radius = Stage.height/3; // radius of drawn circle var centerX = Stage.width/2; // center horizontally var centerY = Stage.height/2; // center vertically var steps = (Math.PI*2) / nodes; // math stuff var i=0; this.onEnterFrame = function() { if(i < nodes) { var m = _root.createEmptyMovieClip("node"+i,i); m.lineStyle(0,0x000000,100); m.beginFill(0x000000,10); m.moveTo(0,0); m.lineTo(nodeSize,0); m.lineTo(nodeSize,nodeSize); m.lineTo(0,nodeSize); m.lineTo(0,0); m.endFill(); var mx = centerX + radius*Math.cos(steps*i); // horizontal snap if(mx%gridSize != 0) mx += (Math.floor(gridSize/2) - (mx%gridSize)); var my = centerY + radius*Math.sin(steps*i); // vetical snap if(my%gridSize != 0) my += (Math.floor(gridSize/2) - (my%gridSize)); m._x = mx; m._y = my; i++; radius += .1; } else { this.onEnterFrame = null; } }
It’s the modulus (mx % gridSize) which makes it cool. The Math.floor() which follows could also easily be Math.round() or Math.ceil(), depending on the constraints of the project.
Math is Easy
Gone Fishin’
Side Tracks
Where have I been? Working on a Flash game . At least, the beginning of one. Miles to go before I sleep, and all that.
Pictures
I have finally, and only a month and a half after the event, posted pictures of the martial arts demo at Festival. Flash 6 plug-in required.
ZOOOOOMMM!!!
Scott is on vacation this week, so I am handling all of the development work at the studio . Rick and Behnje are on their honeymoon so I am teaching all of his tai chi classes, in addition to being the only full-time instructor (other than Master Lee) in Master Lee’s class .
In other words, I am freakin’ busy this week.
And of course this happens just when I spin off a subdomain for the flash adventure game. I can spend hours figuring out data models, noting and then discarding objects and sprites and tile engines and pathfinding algorithms, and never have time to write out a single line of code. It has been like this for a couple of weeks. At this rate I will have completed the game in my head, played it until it bored me, and given it up for something new – all before compiling a single Flash file.
I need a vacation.
Games and Nostalgia
This post will mostly only be interesting for Flash coders and game developers
I have spent the past several days working out various functional specifications and data models for the Flash Adventure Game. So far, I have rudimentary versions of the following:
-XML heirarchies
-Tile placement engine
-dynamic bitmap object masking
I am particularly proud of the object masking idea.
My ultimate goal to create a game (engine) which can be modified without the requiring that the user in question have access to Flash. All that should be needed is a graphics program which can pump out .jpg files, a text editor with which to produce XML, and (maybe) an FTP program to place files on a website.
The dynamic masking is the key. It compensates for Flash being unable to dynamically load .gif or .png files; these formats support alpha transparency. .jpgs, which can be dynamically loaded, do not support transparency. But they can (using the Flash Drawing API) be masked. All I need to do is feed in the appropriate coordinates (in XML; not unlike creating an image map), and skaboom, I have one highly detailed, appropriately transparent sprite!
A lot of this reminds me of the hundreds of hours I spent back in the 80s writing games on the Commodore 64. Back then, there were no graphics applications so we had to program our images in hexadecimal. And the images, egregious hacks aside, were all 24×24, and one color. Or 12×24 and three colors, but all of the colored images had to share one of the colors.
In other words, this is a real walk down memory lane.
As I have useful information I will post it in an open directory. I will post some code after it is debugged. As always, suggestions are welcome .
Kung Fu Fighting
The tournament on Saturday was a lot of fun. Six people competed and we brought home nine medals. Photos are here , and a writeup will be following shortly.
Yes, that is the Flash photo application I created a couple of weeks ago. It still has some rough spots but it works. You will need the latest version of the Flash 6 player to use it.
Sifu Chung, the event host and organizer, told us a few weeks ago that there would be a Praying Mantis sifu at the tournament who had studied with Master Lee ‘s instructor Chiu Chuk Kai (hereafter referred to as Sigong). This instructor, Sifu Tony Chuy, studied with Sigong in Hong Kong after Master Lee came to America. All the time he was a student he had heard stories about Master Lee but had never met him.
Before the tournament started we noticed someone we didn’t recognize but who was wearing the crest of our style of Kung Fu. He was obviously looking for someone, so when he got close, Rick said “Are you from New York?”
“Yes.”
“This is Sifu Lee.”
Sifu Chuy said “Okay”, then he flinched and and his jaw hit the floor when he realized that the person he had been waiting for 25 years to meet was right in front of him.
As fun as the rest of the day was, that was the best moment.
We don’t have a lot of contact with other schools, so it is easy to forget how big the world of martial arts really is. For instance, on Saturday I watched people performing Tai Chi Praying Mantis kung fu, Seven Star Praying Mantis kung fu, Wing Chun, Jow Gar, Pak Mei and Kempo. I saw Jeung, Wu, Yang and Chen style Tai Chi,and I participated in an Iron Shirt Chi Kung demonstration. All of this at a small (though highly respected) martial arts tournament in Midland.
It is good to be reminded that we are part of such an extraordinary world.
Photos Part II
Added some serious functionality to the Flash photo album application. It is far from perfect, but still, I think, something of which to be proud.
Let me know if you come across any serious bugs, or have suggestions for improvement.
By the by, I discovered that an image which is dynamically loaded into a Flash movie is cached exactly as if it had been loaded into an HTML page. I love Flash.