16 Aug

Towers of Hanoi Solved.

I got an iPhone recently, cool little device but thats not what this post is about. On the iPhone you can download applications direct to your phone, one of these applications I downloaded was the towers of hanoi. If your not familiar with this game then you might want to look it up. Now as any good programmer would do, after 30 seconds of playing the game you think “I wonder how I’d get a computer to solve this game…” So thats what I set out to do.

Continue Reading »

09 Jul

A* Shiny-ness

So today was an unusually rainy day in Manchester, so I was pretty much grounded to the house for the afternoon. So since I was bored I decided to play around with doing a proper A* implementation (none of that hacky Dijkstra crap this time) for another project of mine.

While I was testing it I got it to draw on to a bitmap the Open List and Closed List (for all of you are thinking “the what what a what what?” have a look here) so I could better see how it was working and if I could optimize it a little better. After playing around with it for a couple of hours I got it to a point I was fairly happy. However I also noticed that there was a clever little side effect of what I did. The drawing of the Open and Closed lists seem to grow and follow along the main path, it seemed to resemble a bush or a tree or a lightening spike or frost covering a window; All very organic shapes which are quite hard to replicate in their static state let alone animated.

So I changed the map I was working with to be just random noise of 50% probability of wall or not, randomly placed start and end points and let it run. It was pretty cool! So I played with it a little more to add some colour variation and to fade out as it went on and here is the final output

07 Jul

Who and what am I, and what called me? … and a bit about metadata

(Links in this post will open in a new window/tab. I’m also aiming at being overly explicit :) )

Problem and solution

This post will discuss a method I use to figure out which method called the method Im currently executing code within and also what the name of the currently executing method is. To start with, take a peek at the first pastebin snippet.

Simple enough, we execute the following function from an applicationclass called InspectionTest:

private function doImportantStuff():void {
  var c:InterestingClass = new InterestingClass();
  trace(c.method2("Foo"));
}

And this then traces out “You told me: Foo”, simple enough.

Now, I’ll apply some changes (pastebin snippet) to InterestingClass in order to allow it to be self inspected. Executing doImportantStuff() would after the changes yield:


I am in method2 of InterestingClass and was called from doImportantStuff of InspectionTest
You told me: Foo

Again, to be clear, InspectionTest is the application class that has the method doImportantStuff(). Lets try inheritance in AnotherInterestingClass! (pastebin snippet)

private function doImportantStuff():void {
  var c:AnotherInterestingClass = new AnotherInterestingClass();
  trace(c.method2("Foo"));
}

Executing doImportantStuff() again yields:

I am in method2 of InterestingClass and was called from doImportantStuff of InspectionTest
You told me: Foo

Which is perfectly alright! AnotherInterestingClass isn’t overriding method2().. what happens if we do that? (pastebin snippet)

doImportantStuff() now yields:

I am in method2 of AnotherInterestingClass and was called from doImportantStuff of InspectionTest
You told me: Foo

As the result shows, by overriding method2() in AnotherInterestingClass and making a call to processStacktrace() we get a result back which we can use to figure out which method was called and from what method it was called… and as you probably can see we also get which class name the originating method is from.

Discussion

Knowing which method has been called and what method called it can be important to know when doing stuff using the reflection API. AS3 supports metadata tag (docs entry on metadata tags) notation on methods and properties (perhaps also class declarations?) and we can see these tags by calling describeType (docs entry on describeType) with a class or instance of a class as the parameter. With the data given from describeType() and knowing which method is executing we can then see what kind of metadata is attached to that method… neat eh? :)

It should be noted that these tags can not be used via Adobe Flash CS3 IDE compilation (as far as I know, atleast), only the commandline compiler that comes with the Adobe Flex SDK. Further, if you declare a custom tag you must explicitly tell the compiler to include these by adding “-keep-as3-metadata+=[Tag name]”. For example, if I have a metatag called MyTag, I add “-keep-as3-metadata+=MyTag” to the compiler parameters and it will then visible when calling describeType().

Upcoming

In a future post to this blog, I will describe how I created a role/permission-based policy framework to be used with Adobe Flex, using the techniques described in this post. It would be nice to have a discussion on improvements that can be made to the processStacktrace() method or completly different approaches to the problem.

Nasties

It should be noted that the regular expression used in processStacktrace() currently ignore getter/setter functions. There might also be other issues when doing deep inheritance or composition.. . if you spot any bugs, please report them here :)

05 Apr

Audio Creation in Flash… The How To!

I like the idea of experimenting. I always have. Nowerdays I particularly like experimenting with Flash, and enjoy hearing about people experimenting and pushing the boundaries of Flash. Dynamic Audio Creation in Flash is pretty much THE cutting edge in flash at the moment. You dont get much better than that. This was first touched on by Andre Michelle to outstanding effect at Flash Forward and Flash on the Beach, where he showed off a TB-303 created in Flash. This is a fairly impressive in any language let alone Flash. So after a little bit of searching I found that there is a How To on this exact topic. Its not too bad either, worth giving a try. Check it out here: http://www.flashcodersbrighton.org/wordpress/?p=9

05 Apr

Away 3d alternative to Papervision?

With all the Hype around Papervision these days you tend to forget that there are other engines out there such as Sandy or in this case Away3d. And if I’m being honest Away3d’s demo is fairly impressive, even more so than any of the papervision demo’s I’ve seen. Check it out for yourself at:

http://www.closier.nl/playground/temple.html

01 Apr

Quake 2 done in Flash!

This is fairly impressive, I’ve found a multiplyer Quake 2 done in flash! It looks like its using SWFZ, Pretty damn Awesome!

Quake in Flash

14 Mar

Komodo Candidate Project

As a few of you may or may not know I was applying for a job at KomodoMedia.co.uk. Unfortunatly I didnt get the job due to lack of experience in an Agency environment. But as part of the interviewing process I was asked to create a small project along the lines of a portfolio for their internal sales team. So I took the project as a chance to learn Papervision. Unfortunatly half way through learning it I found out the version I was learning was pretty much totally depreciated. But never mind, here is my stab at coverflow in papervision:  http://www.slashflash.net/komodo/

07 Mar

Audio Creation in Flash.

I was reading up on some of my blogs this evening to find that Joa Ebert has been working on a Flash based Audio Creation tool for Hobnox.com. I had to look twice and was thinking that it isnt possible… Well technically it isnt, its Flash and Java based but its still by far the greatest creation I have seen come out of Flash to date! You get a full beat box (TS-808, TS-909 and the TS-303 for you sound geeks out there) an equalizer and 2 whole arrays of effects. And you can link them all together how you like. I strongly recommend you check it out for yourself at http://www.hobnox.com/audiotool-startpage.1046.html

04 Mar

/Flash - Rewards System

I was thinking today how could I get people to post more items on /Flash. The problem is that although people like the idea of /Flash, they arent particularly inclined to contribute. So I figured a Rewards system would be a good idea. The more (good) articles you post the higher rank you get, which unlocks rewards such as free email accounts, FTP access (with increasing Quota) and subdomain hosting. If people think this is a good idea, then tell me! Tell me what would make you post articles ;)

29 Feb

Fractaly landscape generating class.. thing

Alright, I got linked to this sweet little thing by another member of the channel (can’t remember your nick, sorry!). The attached archive is an implementation of the linked-to algorithm for “midpoint displacement in one dimension”.

For more information on topics surrounding this algorithm, look up (all on wikipedia):

LandscapeDemo.zip (includes source, ofcourse :))