October 16, 2009

Binary Clock

Filed under: ActionScript, Personal, experiments — Anthony @ 11:56 pm

I have been looking into bits, bytes and bit shifting a lot recently so I thought I would quickly make a small binary clock to help burn it into my mind. In addition it also gave me the chance to experiment with the spark skinning. Below is the result. Not pretty I know but thats what the skinning is for.

Get Adobe Flash player

Full source

September 28, 2009

Forcing the Browser to crash using ActionScript

Filed under: ActionScript, Flex — Anthony @ 11:59 pm

I just discovered this little trick, I'm not sure how useful it is but it works.

Simply create a class that throws an error in the constructor. This will cause the browser to crash and close.

 
 
package
{
   public class BrowserCrasher
   {
      public function BrowserCrasher( )
      {
         throw new Error( 'goodbye browser' );
      }
   }
}
 

Enums and static initializers in AS3

Filed under: ActionScript, OOP — Anthony @ 10:24 pm

I just came across the idea of static initializers in Java and was wondering if they are available in ActionScript as well.

I found a couple posts on the subject.

post 1

post 2

July 16, 2009

Layout Organizers

Filed under: 3D, ActionScript, Uncategorized — Anthony @ 4:12 pm

I recently stumbled across this awesome project by somerandomdude and just wanted to give it some exposure as it is open source and even in 3D

July 8, 2009

Mixin’s in ActionScript 3

Filed under: ActionScript, Flex — Anthony @ 11:48 pm

I was strolling through the UIComponent source code earlier today when i cam across this line of code.

 
 //--------------------------------------------------------------------------
    //
    //  Class mixins
    //
    //--------------------------------------------------------------------------
 
    /**
     *  @private
     *  Placeholder for mixin by UIComponentAccImpl.
     */
mx_internal static var createAccessibilityImplementation:Function;
 

I wasn't entirely sure what a mixin was but after reading up on wikipedia I realized they are exactly what they sound like basically just a mix of code bases. There is a really good post over on the yahoo flash blog about accessibility and the way in which Flex uses the

 
[AccessibilityClass(implementation="mx.accessibility.UIComponentAccImpl")]
 

meta data to mixin the Accessibility code into the UIComponent implementation.

March 18, 2009

Unable to Catch IOErrorEvent’s when Loading a ByteArray into an Image

Filed under: ActionScript, Bug Fixes, Flex — Anthony @ 1:07 pm

I was trying to load a byteArray into an image control today and would randomly get an Unhandled IOErrorEvent message. Now this shouldn't really happen as the image control uses a default broken image icon to display when there are any loading problems. Well after trying to catch the error unsuccessfully I wanted to know what was going on.
So i went digging and i found in the base class of image, SWFLoader line 1497 the following (more...)

March 12, 2009

Flex Cookbook Recipe 5.8 Allow Certain items in a list to be selectable, Doesn’t quite work correctly

Filed under: ActionScript, Bug Fixes, Flex — Anthony @ 11:38 am

Ok I needed to disable Heading elements inside a List Component in Flex, and i was being too lazy to work it out for myself so i picked up the Flex cookbook Adobe had been kind enough to send me and yes... It was there. Now the Mouse removal was straight forward and worked like a charm. But the keyboard events were a different story. The code didn't work for several reasons.
1. Key directions were not being assigned.
2. When a disabled item was at either the top or the bottom of the list it would stop you being able to continue down / up the list.
To fix this i added the following code. (more...)

March 9, 2009

Augmented Reality

Filed under: ActionScript, Flex — Anthony @ 10:40 am

I saw this post over on Ryan Stewarts Blog today and thought that i would mention in addition to the FLARToolkit download you can also download the source flex project from Saqoosha's demo at Max Japan here.

March 5, 2009

Salesforce ActionScript Fun

Filed under: ActionScript, Bug Fixes, Flex — Anthony @ 4:41 pm

Ok I have been working with the salesforce API for a couple of days now and I have found it very interesting. However I have found a few things that don't seem to be very clear when trying to simply login to your account from an application that is running outside of the salesforce Sandbox.
So as i have seen a lot of posts about this i have decided to explain how i go about logging in here.

1. To login you need 3 things
1. Username in the form user@user.com
2. Password.
3. Security Token
To get the security token for a user go to setup>Reset your security token. This will then be emailed to you.

Logging into an Administrators account seems to be different than logging into a normal users account.
For Administrators you have to set the protocol to 'http' for normal users set it to 'https' in addition we have to add the token to the password as follows.

 
private var _conn : Connection = new Connection( );
 
private function login( username : String, password : String,
           token : String, isAdmin : Boolean = false ) : void
{
    _connection.protocol = isAdmin ? 'http' : 'https';
    var login : LoginRequest = new LoginRequest( );
	  login.username = value..username;
	  login.password = value..password.toString( )
                                    + value..token.toString( );
	  login.callback = new Responder( loginResult, loginFault );
	 _connection.login( login );
}
 
January 27, 2009

Number Romanizer

Filed under: ActionScript, Flex — Anthony @ 2:58 am

I was messing around on a personal project today and had to build a simple converter to change numbers into Roman Numerals. Below is the result. Had a few issues trying to use a simple object to hold the numerals as ActionScript was sorting the object Alphabetically which meant I was getting false results especially with 4's which would return four 'I''s instead of the correct 'IV'.

 
/**
* Function that turns any number into it's roman numeral
* equivelant.
* We have to use an array to hold the values as if we use
* a Dictionary / Object actionScript sorts it alphabetically.
* and we don't get the correct results.
*
* @param value : Number 0 - 9999;
*/
public static function romanize( value : Number ) : String
{
var numerals : Array = [
{ label : 'M', value : 1000 },
{ label : 'CM', value : 900 },
{ label : 'D', value : 500 },
{ label : 'CD', value : 400 },
{ label : 'C', value : 100 },
{ label : 'XC', value : 90 },
{ label : 'L', value : 50 },
{ label : 'XL', value : 40 },
{ label : 'X', value : 10 },
{ label : 'IX', value : 9 },
{ label : 'V', value : 5 },
{ label : 'IV', value : 4 },
{ label : 'I', value : 1 }
]
 
var roman : String = '';
 
for( var i : String in numerals )
{
while( value >= numerals[ i ].value )
{
roman += numerals[ i ].label;
value -= numerals[ i ].value;
}
}
 
return roman;
}