Thursday, July 15, 2010

Add Code Snippets with Github's Gist

I’ve been looking for a simple way to add formatted code snippets to my blog. I know that Wordpress has a few neat plugins that do the job, but because this is a Blogspot-based blog, I had to find an outside solution (or maybe there’s a way to it here, but I just don’t have the time and efforts to delve into that right now)

Well, I should say I found it. Plus, it’s not a miserable, banner-full service, but good old Github. Interestingly enought, the guys offer a nice way to make, share, fork, and embed code snippets in proper format, at the expense of adding a reference to a small js wherever the code should appear …. like that
<script src="”https://gist.github.com/765326.js?file=Test.cs”">
I think that the end result is good enough for sharing code snippets around.



Monday, May 17, 2010

There are a number of people, myself included, who have been observing for a while now that the current web stack feels like Flash did in 1996. Look at the canvas demos, for example. The canvas demos we’re seeing now are totally reminiscent of the Flash demos we used to see in the ‘96 era, where it was like: “Hey, look! I have three circles and you can grab one with a mouse and flick it. And then it bounces around the box and there’s physics and collision and animation and they’re blobby and woo hoo.
Eric Meyer

Sunday, May 16, 2010

I did it

I did it. I graduated. Probably the best years of my life so far, are going to an end. I will never forget any single moment of those four years; the friends, the parties, the lessons learned ... wherever I go, I will always remember my Bachelor days.

Congratulations to the Class of 2010 !!!



Friday, February 12, 2010

Newbie tip: Declaring and Managing Linked MovieClip Instances in Parent Classes

Suppose that we have two MovieClip-based classes called MegaNode and SimpleNode. We have created both of them by drawing two vector shapes on the scene and converting them to those Movieclip-based classes. For some reason, we want to call the instance of the shape that's inside - mainShape, therefore we convert it to a MovieClip, and call the instance mainShape.

Now, since on many occasions the MovieClip class is too general for our purposes, we define a SuperNode class, which extends MC, and servers as the parent for both M
egaNode and SimpleNode. We need to be able to manipulate the mainShape instance, so we instantiate it in the SuperNode class:

public var mainShape:MovieClip;

if we simply do that, the compiler will throw the following error: "1152: A conflict exists with inherited definition SuperNode.mainShape in namespace public."
The reason for that is that by default, all instances of linked MovieClips, such as mainShape, are automatically declared by default at runtime. In order to make sure that we don't get into that error again, we need to go to the ActionScript s
ettings, and uncheck the "Automatically declare stage instances" checkbox. With that done, the above mentioned code will work, and we'll be able to manipulate the mainShape instance from the SuperNode class

NOTE: Make sure that instances like mainShape are always declared as public


Wednesday, February 10, 2010

stage.width, stage.stageWidth, and loaderInfo.width

For any new Flasher comes the time of dealing with the stage and its properties. It is probably confusing for newcomers to distinguish between stage.width and stage.stageWidth, therefore this post. (the same logic follows for stage.height and stage.stageHeight)

stage.width is defined by the distance between the smallest and the largest x coordinate that its children reach at any certain point in time. If we imagine the stage as a balloon, the further we inflate it, the bigger the distance between its walls gets. Therefore, if you have tried to determine the width/height of the stage using the stage.width/stage.height properties, before anything has been put on the stage, the output must have always been 0.

stage.stageWidth, on the other hand, defines the width of the entire Flash window.

NOTE: Normally, one would assume that if the stage's scale mode is set to StageScaleMode.NO_SCALE, the stage.stageWidth will remain constant, no matter how much we resize the Flash window. Well, no .... stage.stageWidth changes all the time, regardless of what the documentation says.

If you want to get the value of the stage width, as defined in the project settings, or the SWF metadata, you should use loaderInfo.width