Math Is My Friend
I am working on a website that uses a very large grid of pages that are shifted around to display content. I am building a map that lets you navigate to any rectangle on the board through a simple grid box.
The HTML is laid out in a simple list. The opening ul and then 44 li tags with nothing inside. This structure is styled with CSS and then each of the 44 rectangles sit nicely in a 4×11 grid.
With jQuery it is easy to get the index of a clicked element, what I really need is that element’s position in the grid. Specifically the row and column that it is in.
I spent some time thinking about the best possible solution and after trying to normalize the numbers, I remembered that I could use remainders!
Here is the code I used, it works like a charm. If you have a different size grid, replace the proper number and you are all set.
To MXML Or Not To MXML, That Is The Question.
Just this past week I began to delve into the wonder and beauty that is Flash Builder 4 beta. There seems to be some confusion around the Flex/Flash Builder family but to me it is very clear. Flash Builder is an IDE that features a flash compiler along with a MXML compiler, a design mode and code editor that enables quick and easy use of the flex (and other) components. Flash Builder understands the needs of an object oriented programmer and the program contains a project management component that I have only yet begun to tap. The MXML language is an interesting hybrid of XML and HTML. The best way I could describe MXML would be that it is web design for an object minded designer/programmer. The most attractive feature of the language is how easy it is to lay out an entire application in the visual builder but also how efficient it is to link the visual components to hand coded methods and properties.
Another interesting aspect of MXML is that it is forcing me to carefully consider my public methods when designing objects. All of the interactive controls exist on the application MXML file, the event handlers are responsible for calling methods that are buried deep inside the main program code. I need to spend some more time learning about the Model View Controller design pattern because it seems that MXML encourages this.
I am excited about using MXML as a front end for my generative art projects. It will save me tremendous amounts of time by reducing the need to design and code control components. I believe that it will also help me get my projects off the ground in less time, leaving more time free for new experiments! I have been reading debate about MXML and it’s usefulness and I agree with some of the dissenting opinion. MXML is great for rapid application development but in some situations, it does encourage sloppy coding. Someday in the near future, I plan to design and code my own set of components in favor of pure AS3 applications and programs.
AS3 Generative Art Framework
I find myself spending more and more time with ActionScript lately. My first introduction to the Flash platform was through the timeline and some basic AS2, in fact, AS2 was what sparked my interest in scripting. This interest in scripting soon snowballed into a programming interest. Over time, this programming interest exploded into a deep love and appreciation for code of all types.
For me, programming is about building tools to solve problems. I am beginning to understand why I like word problems so much in math class, it is the excitement of solving actual problems with understandable variables. I have never been one to learn from theory. It is too hard to wrap my head around something unless I can see it in action, or at least consider it in a real world situation. Programming is about solving real world problems it is a medium where theory gets twisted into action.
I had a problem. My problem was that I continue to use AS3 to create generative art experiments. This is an issue because of the amount of code needed to get a generative art project up and running. To solve this problem I have created the base for what will become a generative art framework.

The GenArt class should be used as a base for any new generative art project. By using GenArt, your project will have access to the GenArt API that will provide a drawing surface, methods to animate the drawing (or not!) and a method to save a file to the desktop.
To facilitate the saving of a completed image, the AS3 Core Library was used. You can find that library at http://code.google.com/p/as3corelib/.
Please note, this is an Adobe AIR project as it needs access to the file system to save the completed artwork. Artwork is saved to the desktop, it is named snapshot.png.
Form & Space Generative Art
Control Point Decline ↓

Sine Wave Ocean ↓

These two compositions are explorations of a single concept. For these pictures, I was exploring drawing multiple lines with a changing control point. The “Control Point Decline” project was the beginning of the line exploration. The concept was simple; what would a design look like if we drew many, many lines, beginning and ending in the same place but modifying the control point with each iteration. The first acceptable generation I achieved involved a very precise structure with little “personality”. The evolution of that piece generated some very interesting deconstructions of the dome structure. The final stage of the piece distorted the control point so greatly that the lines begin to define the frame of the canvas. Two iterations of the final stage are displayed side by side and much larger than the dome structures.
The “Sine Wave Ocean” project was a variation of the “Control Point Decline” project. With this variation, I select random points for the beginning and end of the lines but the control points are distributed based on simple algebra equations. The image shown here is a composition of multiple iterations of the “Sine Wave Ocean” code.
Recursive Triangle Construction ↓

The above piece, “Recursive Triangle Construction”, has generated some truly interesting visuals. The concept for this was simple. I wanted to see what a composition would look like if we created triangles stacked with each new shape smaller than it’s preceding shape. Each new shape would also be rotated slightly. In the larger image on the left, I added a random variable in the placement and achieved this interesting shape. The three small structures on the right explore the de-evolution of the structured shape.
These artworks are created in Adobe Flash using the ActionScript 3.0 language specification. I have included the code necessary to recreate the larger triangle image. To set up this project; create a new Flash As3 project and set the document class to RecursiveTriangleConstruction. Save that file somewhere and then create a new Actionscript file. Copy the sample code into the Actionscript file and then save it next to the project file, name it “RecursiveTriangleConstruction.as”.
Compile and enjoy! Click on the stage to generate a new iteration.