Schematic LA on Adobe AIR and Iron Flexer

September 25th, 2007

Ben, Jeff and myself will be speaking about our experiences with Adobe AIR being run as a Windows service during the Iron Flexer competition.

Event info here: http://upcoming.yahoo.com/event/213333/

Basic AS 3 event system for AS 2

September 18th, 2007

Having to jump on some Actionscript 2 projects … put this together to help me feel more at home :-P

http://specialrelativity.org/blogAssets/AS2EventSystem.zip

Here is some code showing it being used …

Read the rest of this entry »

Schematic 3.0 Launched!

September 6th, 2007

I’m happy to finally announce that my most recent project (the website of the company I work for) has finally launced - see it below …

http://www.schematic.com

The Special Theory of Relativity

August 16th, 2007

This site is not a resource for information about the special theory of relativity. However, what better place to go for information then wikipedia?

The Special Theory of Relativity on Wikipedia

UML Class Diagramming

August 16th, 2007

A colleague posted this on our internal forums, found it to be a very good read. Worth sharing…

IBM UML Basics: The class diagram

as3-collections hosted on code.google.com

August 14th, 2007

Instead of posting a bunch of crap here about this project, I am just going to develop it, and then post when I feel it is important. The links relevant to the as3-collections project are the google code project home, the documentation, and the source code which you can browse:

Google Code and Repo Browser:
http://code.google.com/p/as3-collections/
http://as3-collections.googlecode.com/svn/trunk/src/com/as3collections/

Docs:
http://specialrelativity.org/projects/as3-collections/docs/

If you have an SVN client and would like to check out the code, you can do so with the following line:

svn checkout http://as3-collections.googlecode.com/svn/trunk/ as3-collections

Sorry for tearing down those other posts.

-M

Discussion: Collections in Actionscript 3?

August 12th, 2007

I’ve seen a few collection frameworks in Actionscript, but you never really here of any of them being used as a standard. That kind of acceptance is hard anyway, but I’m really surprised that it hasn’t happened in the community. I think for the longest time the argument was simply that having that kind of extra weight was unjustified, and was strengthened by the fact that Arrays quite simply are much faster. But those are forgotten times, aren’t they? I mean with everyone on the OOP kick. I don’t know, I wanted to put some stuff together just to see how useful a collection framework would be, and how much of a performance hit I would take by using one.

Rather then adopt one I decided to take a stab at implementing it (silly me), after all it’s just for experimenting right now. I’m opening this thread as a discussion about what I plan on doing, and what I am thinking. I will work on it gradually, each time I change a major component, or release a new component altogether it will be in its own post.

Now unfortunately, I’m just not that smart :-\, sorry. So I’ve spent some time looking into it, and picked up some books. I wanted to make a note of one of them though, because it has proven to be incredibly helpful. It’s “Data Structures and Algorithms with Object-Oriented Design Patterns in Java by Bruno R. Preiss”. Check it out. If you’ve read it you would notice that it is an obvious source of the inspiration for my code. The thing to remember is that Java and Actionscript, while similar in syntax, are two very different languages, so my code will differ where things can be done in a way that is more appropriate for Actionscript.

For simplicity and the sake of performance I am going to stick with using Array and Dictionary objects for the implementations of the different data structures.

My initial effort is to get the following done relatively soon.

  • Collection
  • AbstractCollection
  • Stack
  • Queue
  • Tree
  • BinaryTree

There is a lot more to be done then that, but I think its a fair list to commit to for now. Of course any of these could probably be put together quickly if need be, however I want to focus on making a useful framework of collections, something reliable.

I decided to set up a google code project for it, who knows, may just be wasting time.

project:
http://code.google.com/p/as3-collections/

svn:
http://as3-collections.googlecode.com/svn/trunk/

So, if you don’t here from me for a few days, you know why :) Although I’m going to try and get at least the basic containers out tonight, or tomorrow morning.

Easy Cursor Management

August 11th, 2007

This came up because we decided to refactor the cursor management in the project that I am on at work. It works, but the project has changed a lot since we first started writing it. We had to make changes to the way it worked, as well as accomodate for unexpected changes to the design. Like I said, it works, but it wasn’t as flexible as we would have liked. So I came up with this solution, and think it’s cool enough to share.

Lets take a look at the cursor manager stuff along with an example.

The example is going to be the most simple drawing app you have ever seen. It has two tools a rectangle drawing tool, a line drawing tool, and a canvas to draw onto. When you select a drawing tool and then mouse over the canvas you will see the mouse cursor change to a cross hair, indicating that you are in drawing mode.

Below is an example of the cursor demo in action.
[kml_flashembed movie=”http://specialrelativity.org/blogAssets/CursorDemo.swf” height=”306″ width=”426″ /]

The focus will only be on the code that is related to the cursor stuff we are talking about. We will be relying on event bubbling and a technique I talk about in this post.

Read the rest of this entry »

About

August 8th, 2007

“I’m Michael Avila, I’m currently employed at Schematic LA, where all the bitchiz and pimps are yo. Now youza gonna read my articliz fasho, oh-yo!”

Quoted from a hilarious friend… you know who you are.

I’m Michael Avila and I work as a software developer for Schematic which is located in Los Angeles, California.

Understanding Scrolling

August 6th, 2007

I have written a simple scrollbar to work with our examples. The only thing to note about the scrollbar is that it has a percent property which is a number from 0 - 1, and also that it broadcasts ScrollbarEvent.SCROLL events. You can see an example of it below, slide the marker back and forth and you’ll see the percentage displayed just above it.

[kml_flashembed movie=”http://specialrelativity.org/blogAssets/ScrollbarDemo.swf” height=”40″ width=”110″ /]

What we will spend most of our time talking about is how to find the position of the content you are scrolling with the scrollbar. We are going to use a very simple equation to solve this problem, and it looks like this:

content.position = content.iposition - ( scrolling.percent * content.scrollable )

Like I said a second ago this is really simple. We are going to briefly go over the different elements within it, and then take a look at some code.

  • content.position is the position of the content based on the scrolling, and is obviously what we are looking for.
  • content.iposition is the position the content would be at if no scrolling were applied to it.
  • scrolling.percent is the percentage of the content’s scrollable area which will be visible. This is usually provided by the scrollbar.

and finally

  • content.scrollable is how much of the content can be scrolled.

Now most of those are pretty simple, but I think the content.scrollable could use a little more definition. Scrollbars usually allow content that overflows some viewing area to be scrolled and seen. The area of the content that is actually viewable we’ll refer to as content.viewable. How much of the content can be scrolled can now be defined as:

content.scrollable = content.size - content.viewable

So that is enough of that, we want to see it in code. I’m going to build off of some of the more common techniques within flash. For our demo we will have content, which is 300×300 and contains 3 rectangular graphics stacked on top of one another. The viewable area of this content is going to be a 300×100 mask. The initial position of the content is going to be right at the top of the mask. And again we will be using the scrollbar I put together. You can see it at the top of this post. This will all exist in our ScrollbarContentDemo class.

There is a full listing of the class here: ScrollbarContentDemo.as. We are only going to go over the important part right now.

So essentially we create three different elements. The scrollbar, the content, and the content mask. Then we wait and listen for the user to scroll the scrollbar. When the scrollbar is scrolled is where we implement our equation from earlier. I’ll list these two lines.

var scrollable:Number = content.height - content_mask.height;
content.y = content_mask.y - ( scrollbar.percent * scrollable );

These lines should be familiar since we just talked about them a second ago. First we find how much of the content is scrollable, and then we apply the equation to the content. Here is the swf file so you can see the output.

[kml_flashembed movie=”http://specialrelativity.org/blogAssets/ScrollbarContentDemo.swf” height=”100″ width=”310″ /]

Here is the source code for both demos, the scrollbar itself will be listed first since it is used in both.

ScrollBar.as
ScrollbarEvent.as

ScrollbarDemo.as

ScrollbarContentDemo.as