« October 2004 | Main | December 2004 »

November 29, 2004

Experienced Flash ActionScript Developer for Hire

I am now officially looking for full-time or contract Flash applications or games development work. While I will still be working at Blitz as a contractor (until I can find a more permanent position) they just didn’t have enough work coming in to keep me on full time.

I have worked on a number of large scale enterprise wide applications, web sites, rich internet applications (RIAs) and games for fortune 500 companies in the entertainment, telecommunications and healthcare industries.

If you or anyone you know is looking for an experienced Flash developer feel free to shoot me an email: erik@erikbianchi.com

Resume, work experience, references and code samples available upon request.

-erik

Posted by erikbianchi at 06:08 AM | Comments (629)

November 18, 2004

Library / Prototype Extension Organization

When Flash MX first debuted a couple years back I started working on an enterprise wide Flash based application that utilized a Java / Oracle backend. All of our code was external because it had to be versioned and backed-up regularly. To better organize my external ActionScript files I started utilizing a package structure. Then in the fla itself I found it more intuitive to copy the external package structure in the library using folders even if it didn’t mean anything (classes and packages where not supported until Flash MX 2004 Pro)

A few months back Grant Skinner and his team posted about a similar method they where using to organize their libraries. So to add to his post and as a follow up to my Prototype Extensions article I’d like to share a technique that I’ve been using that you might find useful.

For core Flash classes (MovieClip, Array, Object, etc) or components I like to place my prototype extensions into an Extensions folder in the main library:

Library>Extensions

Then for each class that I am extending I create a folder for it:

Library>Extensions>MovieClip

I then create a MovieClip symbol for the method or methods that I am adding:

Library>Extensions>MovieClip>method(s)

The actual code would go into that method MovieClip symbol. If I’m adding a group of methods that go together I’d name the symbol something more general.

So say for example I want to create a setColor method for all MovieClips. My library might look something like this:

Library>Extensions>MovieClip>setColor

Inside the setColor MovieClip would be my extension’s ActionScript:

#initclip

// color example: 0xff0000
MovieClip.prototype.setColor = function (color){
var c = new Color(this);
c.setRGB(color);
}

#endinitclip

For the setColor’s MovieClip Linkage properties I would check “Export for ActionScript” then set its’ linkage Identifier to “Extensions.MovieClip.setColor” and then check “Export in first frame”. This allows me to see exactly what extensions I have in any given fla and allows me to enable / disable them by checking or un-checking “Export for ActionScript”. When working in a team environment or going back into older code setting this standard helps avoid having to look for magic code / hacks.

For Grant’s original post check out:

http://www.gskinner.com/blog/archives/000107.html


-erik

Posted by erikbianchi at 11:07 AM | Comments (603)

[Flash Quirks] Prototype Extensions: Decorator

Often times in Flash you may find it easier to just overwrite Flash’s core classes / components / methods to add functionality, fix an issue or to hack into a component. Because all objects in Flash are referenced (including classes and functions) you can overwrite existing methods by hacking into the class’s / component’s prototype property (what I like to refer to as extending the prototype or as a prototype extension) rather then using inheritance.

A recent (and useful) example of this can be seen here: http://www.darronschall.com/weblog/archives/000135.cfm

Because prototypes are not protected you can overwrite the prototype of just about any object dynamically at any time and have the change take effect immediately to all instances of that class.

In the following example I’m using what could be considered an implenmentation of the decorator to add trace statements to the v2 Button component:

import mx.controls.Button;

// references original method
Button.prototype.$oldPress = Button.prototype.onPress;
Button.prototype.$oldRelease = Button.prototype.onRelease;

// overwrites original reference
Button.prototype.onPress = function(){
trace("onPress");
this.$oldPress();
}


// overwrites original reference
Button.prototype.onRelease = function(){
trace("onRelease");
this.$oldRelease();
}

function click(){
trace(“click event");
}

var MyButton_btn:mx.controls.Button;
MyButton_btn.addEventListener("click",this);

This technique could be useful for debugging existing classes or creating a log file of all user events for tracking.

For organizing prototype extensions check out my follow up post: Library / Extension organization

-erik

Posted by erikbianchi at 10:32 AM | Comments (415)

November 15, 2004

[Flash Quirks] Saving Custom Classes to SharedObjects

According to Macromedia’s documentation on SharedObjects (paraphrasing): “SharedObjects can only save basic ActionScript or JavaScript types (Array, Number, Boolean, String, etc)” However, there is in fact a way to store user defined classes to a SharedObject and have access to almost all its variables and methods.

I didn’t actually know you could do this up until a couple months ago when someone on one of the list mentioned it (sorry don’t remember who). So in case anyone else missed it, here's some sample code goodness (note: parameters passed to the constructor are not saved):

/**

Example of saving classes to shared objects

*/


// Person Class / Prototype Object
function Person(p_sex){

// not saved to SharedObject
this.m_sex = p_sex;

}


Person.prototype.setName = function(p_name){
this.m_name = p_name;
}


Person.prototype.setAge = function(p_age){
this.m_age = p_age;
}


Person.prototype.getName = function(){
trace("Name: "+this.m_name);
}


Person.prototype.getAge = function(){
trace("Age: "+this.m_age);
}


Person.prototype.getSex = function(){
trace("Sex: "+this.m_sex);
}


// Deserilizes custom class in ShareObject
Object.registerClass("Person",Person);


// Initializes SharedObject
var SavedData_so = SharedObject.getLocal("PersonData");


// Creates and saves SharedObject if it doesn't already exist
if(SavedData_so.data.Person == null){

trace("SharedObject Created");

// Parameters in constructor are NOT saved
SavedData_so.data.Person = new Person("male");
SavedData_so.data.Person.setName("Erik");
SavedData_so.data.Person.setAge(25);
SavedData_so.flush();

}else{

trace("SharedObject Retrieved");

}


// Call SharedObjects custom class methods
SavedData_so.data.Person.getName();
SavedData_so.data.Person.getAge();
SavedData_so.data.Person.getSex();

// Output

// First Run: Creates / Saves
SharedObject Created
Name: Erik
Age: 25
Sex: male

// Second Run Retrieves SharedObject
// as you can see, parameters specified in the constructor are not saved correctly.
SharedObject Retrieved
Name: Erik
Age: 25
Sex: undefined // Insert joke here

-erik

Posted by erikbianchi at 12:24 PM | Comments (411)

November 12, 2004

[Flash Quirks] Strict Typing Gotcha + Unit Testing

Exporting to FlashPlayer 6 AS1 and mistakenly using strict data typing causes the variable you’re declaring to return undefined and does not report any errors!!!

// Export to Flash Player 6

// undefined param
function setVar(value:String){
trace(value)
}
setVar("Hello World!");

// undefined var
var a:String = "Hello World!";
trace(a);

// Output
undefined
undefined

When you’re jumping between multiple AS1 and AS2 projects it’s easy to miss and without Flash throwing an error you’re practically blind. Fortunately I was running Unit Test on this particular project which helped point me in the right direction of the problem.

For those who haven’t used them, Unit Test basically ensure your classes and methods are all responding as expected. They help reduce the chance of bugs and speed up the debug process.

So if you unexpectantly come across an undefined variable and you're using AS1 check to see if you’re trying to use strict data typing.

For more information on Unit Testing in Flash checkout:

AS1 Unit Test Framework
http://www.debreuil.com/FrameworkDocs/UnitTestingOverview.htm

AS2 Unit Test Framework
http://www.as2unit.org/


-erik

Posted by erikbianchi at 10:55 AM | Comments (357)

November 11, 2004

Server Meltdown

Well, I'm recovering from a total server meltdown that corrupted my database and most of my files. I'll be working on the site the next couple days to get it back to 100%. I’m also in the process of migrating from MovableType 2.6 to 3.1.

If you come across any broken links or general weirdness, let me know and I'll fix her right up! =)

-erik

Posted by erikbianchi at 12:16 PM | Comments (546)