Archive for February, 2009

Event Broadcast Model Saved My Marriage

Saturday, February 28th, 2009

Not really, but I’ve been reading up on how it’s used in NeatTools, both from EJ’s Thesis, and from an analysis done by Rob Salgado.  I’ve tried to replicate it to the best of my abilities within my code, and while it’s still a work in progress, it’s already done two things for my program.  First I’ve lost a bunch of code (in a good way).  I don’t have custom methods for every module.  Everyone contains three in common which power their interaction. engine(), broadcast(), and access() which makes for more universal communication.  Second, it’s fixed the functionality of a couple of modules, LED and Integer.  By forcing me to restructure how data is flowing and doing it more closely to how NeatTools does it, the behaviors have become more accurate.  I’ve also fixed the Integer box text formatting problem.  The strange number problem was to do with using integers larger than 32 bits.  Anyway, here it is, essentially the same but much work done under the hood.

This movie requires Flash Player 9

The Wires are the Thing

Thursday, February 26th, 2009

After dealing with two new module types and incorporating them into the mix, I’m starting to think I need to rethink my module interaction model.  Right now modules communicate directly with those modules they have connections with.  To make the Integer module talk to the Add module, because they each handle data differently, I had to had separate code for each possibility.  This will quickly get huge, and slow and unwieldy. So, I either need to normalize the data being sent somehow, making for a more universal data transfer, or, make the wires the keepers of the kingdom. Right now they’re just pretty lines.  They don’t do anything besides exist.  When they are constructed, they are used to populate a list of ‘moms’ and ‘kids’ for the modules being connected, but other than that, nothing.  I could make them the converters/translators/gate keepers and handle all the unpleasantness.  Something to think about.

Adding with Iman

Thursday, February 26th, 2009

Sounds like a children’s tv show.  The Add module was the next requested NeatTools feature, and here it is, more or less.  I still need to pretty it up.  For instance, if you type too much in a box it extends beyond the boundaries of the box.  Also Flash’s text boxes take strings, not numbers, so in my code, number are being turned back and forth from strings, something I think that’s causing the strange behavior if your number get’s too big.  But that aside, it’s working.  The two integer modules on the left feed into the add module and the output is displayed in the third integer module.  The output is dynamically updated when the numbers in the first two boxes change.

This update also marks my first use of actual NeatTools source code.  The formula used to draw the plus sign on the add module was taken directly from JAddObj.cpp.

This movie requires Flash Player 9

Note: I’ve just disovered a small bug. If you click before the number and hit delete, it will erase the text style, and revert to black, so you won’t see it on a black background.  Instead, click after the number and use backspace to change it.

Small Moves

Sunday, February 22nd, 2009

I’m trying to knock out all the small things, before I have to start dismantling my code to make the bigger improvements. Hence, the most recent update.  When hovering over a module, the wires will glow green. Yay.

The gray box on the side of the modules is the start of drawing my own connections. Those will eventually be the hit area which will trigger the drawing of the wire. For now, they don’t do anything.

This movie requires Flash Player 9

NeatTools AS3 SVN

Sunday, February 22nd, 2009

The file Main.as under examples is needed to start off the application.

http://svn.sambaker.net/neattools/

Open Source Flash

Sunday, February 22nd, 2009

Last year Adobe released a free and open source Flex 3 SDK.  Flex is essentially, flash without the Flash Application.  Using Flex alone, you can build fully functional Flash AS3 or AIR applications.  Instead of using Adobe Flash (the application) to build my NeatTools application which kinda sucks for writing code (not to mention the expense), I’m using the Flex 3 compiler that is part of the SDK.

I was using SEPY for my actionscript editing and it was pretty good, but I moved to FlashDevelop which I love.  It has great integration with both the Flash IDE and the Flex SDK, so workflow is very smooth.  It handles all the compilers settings, so there is no need to use the command line compiler.  Release 3 just got out of beta in late December, so it’s actively developed unlike SEPY which hasn’t put out a RC since 2005.

These two tools are all you need to start building your very own applications.

Flex 3 SDK

http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK;jsessionid=32A0FB1C1BD2999C0FD1A980348AC435

FlashDevelop

http://www.flashdevelop.org/community/

And for help, I found a video detailing the steps neaded to get it all working.

http://www.as3apex.com/videos/flashdevelop_demo.html

Switches are Go

Friday, February 20th, 2009

That took much less time that I thought. Switches are working, at least basically. The modules on the right are LEDs. The top left module is a button. The bottom left module is a switch.

This movie requires Flash Player 9

Victory is Mine. Sort of.

Friday, February 20th, 2009

The reason I had to disable the dragging in the last one, was to get the children of a module (the ones it’s plugged into), I put a function call in the drawConnection function that collects the modules you’re passing it to connect.  So, for instance, when you create a connection between box1 and box2, this function says ok box1 has the child box2.  If you connect box1 and box3, it say ok box 3 is also a child of box1.  The function is a method of the Module class. The function looks like this:

public function addKid(m:Module):void
{
	var max:int = kid.length;
	kid[max] = m;
}

The problem with putting it in the draw connection method is that that method is called every frame to redraw the connection, so every frame, it re-adds the same children to the parent module, making the array.length much much longer than it should be and consequently producing some unpredictable behavior. My solution was to create two methods one that draws the connection initially and one that redraws it. They are identical save the one line that calls the function above. This is obviously not ideal, but it works. Switches next…

This movie requires Flash Player 9

LED and Button

Friday, February 20th, 2009

I’ve begun diversifying the Module class with two subclasses, LED and Button.  LED will light up and button will cause its connected classes to toggle when pressed.  The green module is the button and the top red one is the LED. Press the button to light the LED.  The bottom two modules are just vanilla modules and don’t do anything for now.

Note: I’ve had to temporarily disable the redrawing of connections.

This movie requires Flash Player 9

Very close to NeatTools and a new class

Friday, February 20th, 2009

This seems to me to be very close to the way NeatTools handles the drawing of wires. The behavior may not be ideal, but, first step is to duplicate the existing interface.
Also, I’ve started creating subclasses of the Module class. The LED class is the first example of this, and for the moment the only differentiating feature of the LED subclass is when you click on it, it changes color. (This isn’t how the NeatTools LED object functions, I’m merely testing out the method of changing the color of the Module.

This movie requires Flash Player 9