Converting Hexadecimal to base 10

Hexadecimal is base 16. Represented by 0 – 9 – A – F

I am running into many walls here. I needed to create random values of the color RED.

Color is usually expressed in hexadecimal form. 0xFFFFFF is 255R 255G 255B

it works like so: (F*16^3)+(F*16^2)+(F*16^1)+(F*16^0)

The problem is that color is expressed as this single value for all three (or four) channels. Red, Green, Blue, and sometimes Alpha.

This just means you can’t multiply “the red color” by a random 0-1 value to get another shade of red. You will get all possible colors by multiplying 0xFFFFFF by 0-1, or 16776960 in decimal.

To get all shades of red, you have to do: (random 0-1)*255 << 16 to get your hex equivalent because the Red Channel is stored in the XX0000 value. 255 = FF in hex. FF0000 is 16711680. so thats full red.

0xF = 15

0xF0 = 240

240 + 15 = 255. there it is.

R << 16 | G << 8 | B = separate RGB 0-255 converted to Hex.

Full Red Channel : 255 << 16 | 0 | 0 = 16711680 aka 0xFF0000

Full Green Channel : 255 << 8 = 65280 aka 0x00FF00

Full Red + Green = 255 << 16 | 255 << 8 = 16776960 aka 0xFFFF00

Assigning dynamic/unique variable names in a for loop in AS3

Assigning dynamic variable names to objects created in a for loop in AS3.

You have to get very creative to search these questions on google because words like “for” and “loop” are so utterly common.

If you have a loop in AS3 creating multiple variables but need them to have unique names (for later modification) you need to create something like an array to store the references to the variables.

For example, anything you create in a for loop is a temporary reference. It disappears after the loop is complete, and whatever objects were created stick around in the displayObject.

In my situation I had a loop creating my navigation elements, but needed to position each X value separately.

Here is the method I used to keep the references to these variables:

private var mcArray:Array = new Array();  // array that holds references
private function myfunction():void{
	for (var i:int=0; i&lt;2; i++) { 
		var movieClip:MovieClip = new MovieClip(); // the temporary variable
		addChild(movieClip);
		mcArray[i] = movieClip; // store reference to temporary variable in array
	}
}

Now, to use those references:

mcArray[0].method_here;
// or
// --
for (var i:int=0; i&lt;2; i++) {
	mcArray[i].foo = bar;
}

To be absolutely clear, the above example creates two MovieClips according to the loop (while i < 2), and places each MovieClip in the mcArray array at index i (which we have defined as the integer counting the loop).

Now if I wanted to access those individual MovieClips I could use the mcArray to do so.

mcArray[0].graphics.beginFill(0x555555,1);
mcArray[0].graphics.drawRect(0,0,900,300);
mcArray[0].graphics.endFill();</code>

I could also loop through the array to apply an animation to each item. The possibilities are endless when you use this basic concept!

Generate 1000 triangles. Animate each one to a random color and rotation.

I wish I could move entirely to Linux.

My laptop is a dual boot machine with Vista / Ubuntu Gutsy. My Desktop has Kubuntu Gutsy after a little accident killed windows on it (the wind knocked over one of my drives that was in a RAID).

Doing anything on the computer is more efficient and faster on Linux. I always say that a strong motivation for buying overpowered computers is it saves you a lot of frustration from hanging windows. You clicked close 30 seconds ago.. its still “thinking”. You opened a folder.. its taking ages.

Only my desktop with an overclocked E6600 Core 2 Duo + 4GB ram doesn’t reliably hiccup on Windows. Windows reliably hiccups in 99% of environments. You don’t even realize how bad it is until you try Linux.

Everything is snappy. Stuff opens the instant you click on something. It stays this way for as long as your computer is on. Imagine that? It is very difficult to quantify this snappiness. And you don’t even need a great computer. I get a huge productivity gain just by not being frustrated.

So, on that note, the second greatest thing about Linux is the productivity. I am extremely productive on this machine. Everything is a shortcut away. All of the open source programs are literally one command away from installing on any machine. I note below that text-based computing has easily documented productivity gains across the board. It’s easy to see why.

Alt+F2, Konsole, Enter
sudo apt-get install Skype

For development, my workflow is so much faster on Linux. For developing Django I am probably around 300% faster on Linux.

It helps that the same architecture is used for production servers. Linux revolves around terminals, and coding does too. Alt+F2, Konsole, Enter. Navigate to my Django directory. Type Screen. Ctrl A + C to make a new sub screen, start editing settings.py, Ctrl A +n to go to next screen, edit urls.py

Need to test the dev server? Alt+F2, Konsole, Enter, tab complete my way to my project folder, python manage.py runserver. Perhaps Super+N to turn the window negative so that the dev server stands out.
Ctrl+alt+shift+right to move the window to the right workspace, ctrl+alt+left to move back. Alt+F2, firefox, Enter. Check my dev server.

Ctrl+alt+ arrows let me switch between my 9 virtual screens. It works perfectly. I’ve tried a few windows versions and they are not worth the hassle. It doesn’t solve the problem of everything slowing down even on ONE screen, anyways.

It is entirely documented what kind of workflow gains you get from switching from GUI to Type based computing.

It also makes it infinitely more fun. Windows is a chore, Linux is something I could actually enjoy day to day. Ubuntu put fun back into computers.

There are tons of extremely useful programs only on Linux as well. Open source goes a long way into developing what people WANT/NEED/FIND USEABLE.

Every program seems to fit in the operating system.


So why can’t I completely switch to Linux?

My main reason is Adobe products. Adobe hasn’t ported their products to Linux. WHY!?
I need Photoshop and to a lesser extent Illustrator. I also use FlashDevelop which is an open source windows only Flash development tool. It felt so nicely done and felt so “Linuxy” that I assumed I could get it for linux. Nope!

Learning the Linux alternatives will take time. I’ve used GIMP and it certainly is all I need for web graphics but there is just a lot to learn.

One of the main reasons I want a mac is to have more Linux like functionality while still being able to use Adobe products.

I am a total convert to text based computing. I now realize how stupid it is to click through folders to find something. Click through folders to open an image, modify it in photoshop, click through folders to save it, etc. It’s an utter waste of time and doesn’t help by being annoying. To spend a few seconds moving your eyes across the screen looking for a particular folder is really, really, dumb. You just don’t get it untill you try something else that works infinitely better.

Linux is only getting better, and I hope Adobe starts selling Linux ports of their products. Thats the only thing I need. Otherwise I lose quite a bit from the fact that I have to shut down windows and log into Ubuntu just to use it. Therefore, if I’m designing something, and I want to use my email, I stick to windows and put up with the slowness. It wouldn’t make sense to log out every time I use something non adobe.

There is a fair learning curve, but if you don’t think of your computer as magic, you can learn it, and you will thank me.

If you do think your computer is magic, you won’t be able to understand it. The most recent releases are about as user friendly as it gets though. It most likely won’t have a problem detecting and installing the right basic sound drivers/video drivers and you can be on your way.

SVN Tweener breaks previous versions. Revision 389

Did updating to SVN Tweener break everything?

I had downloaded Tweener from http://code.google.com/p/tweener/ a few months ago but needed to use it on a few GlowFilters. After doing some research I find out that the SVN trunk has support for GlowFilter and various other special properties.

After updating Tweener the rest of my Tweens broke. I started getting these errors:

## [Tweener] Error: The property ‘_blur_blurX’ doesn’t seem to be a normal object property of [object MovieClip] or a registered special property.

I looked into caurina.transitions.properties.FilterShortcuts and saw that they were labeled _Blur_blurX (capitalized letter) but that didn’t solve the problem.

I finally stumbled upon a forum post saying you must manually initialize the shortcuts so they are registered as specialproperties.

Basically, import whatever properties branch you need, like

import caurina.transitions.properties.FilterShortcuts

Then, before you use Tweener:

FilterShortcuts.init();

Done. It all works as it used to.

Tweener.addTween( mc, {delay:1, time:2, _blur_blurX:3 } );

Embedding Fonts in AS3 Only.

This post details how to embed fonts with only AS3.

Took a good 2 hours to come across the right information. Hopefully somebody else can benefit from this as well.

It looks like if you ever need to change the alpha on a TextField you need to embed the font. Here are the basics.

/// EMBED FONT ///
[Embed(source = "path_to_font", fontName= "myFont")]
public static var myFont:Class;
Font.registerFont(path_to_font_class);
/// CREATE TFORMAT ///
var format:TextFormat = new TextFormat();
format.font="myFont"
/// CREATE TFIELD ///
var tf:TextField = new TextField();
tf.embedFonts = true;
tf.defaultTextFormat = format;

Now you are finally good to go. tf.alpha=0, and sure enough, it works.

All energy flows according to the whims of the Great Magnet. What a fool I was to defy him.

I just watched Fear and Loathing in Las Vegas. What a great movie. It might be my favorite movie ever, actually.

The scene during this quote is amazingly powerful. The right words with the right pictures is worth a million words. Maybe something words can’t even express.

And that, I think, was the handle – -that sense of inevitable victory over the forces of Old and Evil. Not in any mean or military sense; we didn’t need that. Our energy would simply prevail. We had all the momentum; we were riding the crest of a high and beautiful wave. So now, less than five years later, you can go up on a steep hill in Las Vegas and look West, and with the right kind of eyes you can almost see the high-water mark – that place where the wave finally broke and rolled back.

What a wonderful time. I wish I could witness that generation.

Buenos Aires is covered in smoke.

I am inside my apartment on the 11th floor in Buenos Aires, windows closed. I am breathing in smoke. Why?

Because somebody decided to do an agricultural burn expecting the wind to blow in the opposite direction. It blew towards BA and now you literally can’t escape the smoke.

It’s very strange not even having the /choice/ to leave. This has to be bad for you.

It’s real bad as you get closer north. You can’t see more than a foot in front of you. At least in mist you can breathe. I’d take a picture but I would need to open a window.

I think it’s getting worse. It looks hazy INSIDE. This is very bad for you.

I took a picture outside and I felt like a hurricane photographer or something. Being somewhere you are not supposed to be. At least a hurricane is “you live or you die” –this just eats away at you.

I felt like a hurricane photographer.

One particular direction.

Here is one direction we can head in for Anuva’s new look. Its sleek and sexy. I do wonder if it will appeal to everybody, though. The interesting thing about the wine industry is that its demographic has a rift in it between the past generation who has its own views on the internet, and a new generation who is closely linked to the internet.

I only know how internet design appeals to the latter group. Perhaps this type of design, and new generation features such as flash are only appealing to that group. Perhaps a blank white page looks better and more ‘refined’ to the past generation.

Time will tell. I plan to have many different versions to show everybody I know.

Hip and Modern.

Beautiful Flower