Jan 24 2008

We need a package manager like RubyGems for distributing Flex components – Revisited

Tag: AS3, ActionScript, Flex, Ruby, maven, package manager, sproutsDerek Wischusen @ 6:31 am

About a year ago I wrote a post about how the Flex/As3 community needs a package manager like RubyGems for managing libraries and components.

Well, I have some good news. Recently I’ve learned about two potential solutions to this problem.

The first I learned about from a comment on the original post by Luke Bayes. Here is an excerpt:

I’ve been working on ’sprouts’ for the past year and finally landed on an architecture that actually sits on top of Rubygems for package management. Even though we have a functional pre-alpha in the wild right now, we expect to release a production-ready build before the end of January 2008 that will really support versioning via Rubygems the repository.

Check it out: http://www.projectsprouts.org

The second potential solution is a Flex plugin for Maven. It appears that it is still under development, but it looks promising. You can check it out here.


Nov 23 2007

ActionScript 3 Inflector class for pluralizing and singularizing words

Tag: AS3, ActionScript, RailsDerek Wischusen @ 9:08 pm

The as3 Inflector class can be used to pluralize or singularize most words.  It is essentially a direct port of the Rails inflector class.

Here is a little demo Flex app that I put together to demo the classes functionality.

Inflector Demo

You can right click on the app to view the source and grab the class, or you can just click here.


Nov 23 2007

as3Stomp – Project site and source code

Tag: AS3, ActionScript, ActiveMQ, ActiveMessaging, STOMP, Server PushDerek Wischusen @ 7:48 pm

A little while ago I posted about my ActionScript 3 implementation of the STOMP protocol.  Well, I am just now getting around to posting that I created a google project site and released the source.   This version is slightly updated from the one that was included in my example code in the previous post.

 If you have any questions about this project, or if you would like to contribute, please let me know.  Please post any bugs to this issue list.


Nov 23 2007

as3yaml – A YAML 1.1 parser and emitter for ActionScript 3

Tag: AS3, ActionScript, as3yaml, yamlDerek Wischusen @ 7:13 pm

I am pleased to announce the first release of as3yaml, an ActionScript 3 library for parsing and emitting YAML. It is a direct port of Ola Bini’s jvyaml, which was itself a port of Kirill Simonov’s PyYAML.

For those of you who are unfamiliar with YAML, here is a concise description from the yaml.org welcome page:

YAML(tm) (rhymes with “camel”) is a straightforward machine parsable data serialization format designed for human readability and interaction with scripting languages such as Perl and Python. YAML is optimized for data serialization, configuration settings, log files, Internet messaging and filtering. YAML(tm) is a balance of the following design goals:

  • YAML documents are very readable by humans.
  • YAML interacts well with scripting languages.
  • YAML uses host languages’ native data structures.
  • YAML has a consistent information model.
  • YAML enables stream-based processing.
  • YAML is expressive and extensible.
  • YAML is easy to implement.

Here are some example of YAML taken from the current version of the YAML spec:

american:
  - Boston Red Sox
  - Detroit Tigers
  - New York Yankees     

national:
  - New York Mets
  - Chicago Cubs
  - Atlanta Braves     

-
  name: Mark McGwire
  hr:   65
  avg:  0.278     

-
  name: Sammy Sosa
  hr:   63
  avg:  0.288

Here is an example of decoding a YAML string and converting it to ActionScript objects:

With the following YAML stored in a file called myYaml.yaml

  ---
  Date: 2001-11-23 15:03:17 -5
  User: ed
  Fatal:
    Unknown variable "bar"
  Stack:
    - file: TopClass.py
      line: 23
      code: |
        x = MoreObject("345\n")
    - file: MoreClass.py
      line: 58
      code: |-
        foo = bar

You can load then load the YAML and decode it as follows.

   public function loadYaml() : void 
   { 
       var loader : URLLoader =  new URLLoader(); 
       loader.load(new URLRequest('myYaml.yaml')); 
       loader.addEventListener(Event.COMPLETE, onYamlLoad); 
   } 
  public function onYamlLoad(event : Event) : void 
  { 
       var yamlMap : HashMap = YAML.decode(event.target.data) as HashMap; // returns a HashMap 
       trace(yamlMap.get("Date"));  // returns a Date object and prints: Fri Nov 23 15:03:17 GMT-0500 2001 
       trace(yamlMap.get("User"));  // returns a String and prints: ed 
       trace(yamlMap.get("Fatal")); // returns a String and prints: Unknown variable "bar" 
       trace(yamlMap.get("Stack")); // returns an Array and prints: [object HashMap],[object HashMap] 
       trace(yamlMap.get("Stack")[0].get("line"));  // returns an Int and prints: 23 
       trace(yamlMap.get("Stack")[0].get("code"));  // returns a String and prints: x = MoreObject("345\n")     
 
  }

There are some more examples available in the as3yaml docs.

I have been working on this for a little while now, and running it through various tests, so I think it is at a point where it is ready to be released into the wild. Please submit any bugs that you find to the issues list on the google project site. If you have any interest in contributing to the project, please let me know.

 THANKS:

  • Of course, special thanks to Ola Bini and Kirill Simonov for their excellent work on jvyaml and PyYaml, respectively.
  • I would also like to thank the as3commons project.  This library made the port from Java quite a bit easier than it might have been. 

Aug 07 2007

method_missing in ActionScript 3/Flex

Tag: AS3, ActionScript, Flex, RubyDerek Wischusen @ 2:05 am

method_missing is one of the small bits of Ruby magic that can be used to some really amazing things when used properly, and some really dangerous things when used improperly. Rails dynamic finders are good example of the amazing things that you can do. Here are some others.

It is possible to implement something like method_missing in AS3 using the Proxy class. Here is a relatively simplistic example:

import flash.utils.Proxy;
import flash.utils.flash_proxy;
 
dynamic public class BaseProxy extends Proxy
{     
	flash_proxy override function callProperty(method: *, ...args): * {
	   try { 		 
	   var clazz : Class = getDefinitionByName(getQualifiedClassName(this)) as Class;
	    return clazz.prototype[method].apply(method, args);
	   }
	   catch (e : Error) {
		return methodMissing (method, args);
	   }
 
	}
 
	protected function methodMissing(method : *, args : Array) : Object{
		throw( new Error("Method Missing"));
	}
}

The callProperty method is called whenever an undefined method is called on an instance of this class, or any instance of class that extends this class. In the try block we check if the method was defined on the prototype. If it is not found there, we call methodMissing.

So, now if we create another class that extends this one like so

public dynamic class Model extends BaseProxy
{
	public function myMethod (arg1 : String, arg2 : Boolean) : String {
		return arg1 + " " + arg2;
	}
}

and then run the following trace statements

import flash.display.Sprite;
 
public class MethodMissingExample extends Sprite
{
	public function MethodMissingExample()
	{
		var m : Model =  new Model();
 
		Model.prototype.runtimeMethod = function (date : Date) : String {
			return "I was defined at runtime at " + date.toLocaleTimeString();
		};
 
		trace(m.myMethod("I exist", true));
                trace(m.runtimeMethod(new Date()));
		trace(m.someMethod(0, false, "x"));
	}
}

You will see the following in the console:

I exist true
I was defined at runtime at 09:58:00 PM
Error: Method Missing

The first call succeeds because myMethod is defined. someMethod is not defined, so a Method Missing error gets thrown.

Now, if we override the missingMethod in the Model class like so,

public dynamic class Model extends BaseProxy
{
	public function myMethod (arg1 : String, arg2 : Boolean) : String {
		return arg1 + " " + arg2;
	}
 
	override protected function methodMissing(method : *, args : Array) : Object {
		return "You called " + method + " with " + args.toString();
	}
}

and run the same trace statements you will see the following in the console:

I exist true
I was defined at runtime at 09:58:00 PM
You called someMethod with 0,false,x

Jun 15 2007

Static initializations in ActionScript, Take 2

Tag: ActionScriptDerek Wischusen @ 12:05 am

In a previous post I discussed how you can use the [Mixin] metadata tag to create a static initialization in Flex. Here is another way to do pretty much the same thing:

public dynamic class Model 
{ 
 
    trace('I get called first'); 
 
    public function Model() 
    { 
 
    } 
 
}

The trace statement and any other code that is directly inside the class body will be invoked when the class is loaded. You can read more about this here.


Phentermine online uk
Viagra ordering
Free cialis online
Tramadol for sale
Levitra 20mg
Buy phentermine no script
Brand viagra cheap
Cialis 20mg side effects
Xanax bars effects
Get viagra prescription
Cheapest cialis professional
Cheap cialis soft tabs
Buy viagra online in australia
Valium online overnight
Buy levitra online canada
Best way to buy viagra online
Propecia information
Cialis purchase online
Tramadol dosage
Cialis 20mg
Valium pill 10mg
Cialis price
Buy tramadol overnight
Buy viagra in england
Best price on phentermine
Purchase phentermine online
Get tramadol prescription
Generic viagra for sale
Xanax online cheap
Cialis online canadian pharmacy
Buy valium europe
Fedex tramadol
Prescriptions for phentermine
Generic viagra sales
Valium 10 mg
Best price tramadol
Tramadol online no prescription overnight
Generic xanax no prescription
Xanax bars dosage
Order cheap viagra online
Purchase viagra online without prescription
Authentic phentermine 37.5
Propecia online uk
Viagra online uk
How to buy valium without a prescription
Prednisone tablets 10 mg
Cheap cialis india
Generic propecia
Viagra express delivery
Where can i buy viagra without a prescription
Australia viagra prescription
Buy generic cialis
Buy viagra online in ireland
Cheapest online cialis
Buying viagra online
Overnight tramadol no prescription
Buy phentermine online no prescription
Valium without prescription uk
Cialis side effects
Viagra online without prescription reviews
Prescription phentermine online
Cheap tramadol overnight delivery
Cialis dosage 20mg
Propecia price australia
Viagra generic
Xanax no prescription overnight
Cialis samples canada
Buying viagra in london
Phentermine 37.5 pills
Where to buy viagra in england
Tramadol without prescription
Tramadol no prescription overnight delivery
Levitra price
Drug phentermine
Buy valium cheap online
Buy valium without prescription uk
Best price cialis
Valium online uk

Best prices for cialis
Prednisone online
Cheapest generic viagra online
Buy xanax canada
Cheap cialis pills
Valium online fast delivery
Levitra online buy
Viagra 50 mg online without prescription
Levitra canada
Valium online pharmacy
Phentermine 37.5mg
Cheap levitra no prescription
Where to buy propecia in canada
Valium cheapest
Low cost cialis
Levitra online cheap
Free samples of cialis
Viagra without prescription uk
Viagra dosage information
Low price cialis
Buy cialis in the uk
Phentermine cheap online
Tramadol free shipping
Buy tramadol cod
Levitra on sale
Buy generic valium online
Tramadol cheapest
Buy viagra online uk no prescription
Xanax 0.5 mg
Viagra to buy
How to buy phentermine online
Levitra us
Buy tramadol hcl
Canada viagra
Phentermine with no prescription
Where to buy phentermine cheap
Buy viagra online cheap
Propecia ireland
Cialis soft tabs online
Cheap viagra online without prescription
Viagra canada online
10mg valium effects
Tramadol online overnight
Cheap xanax bars
Cialis prices uk
Where to buy cialis online
Cheap 37 5 phentermine
Pharmacy tramadol
Cialis for sale
Blood pressure and prednisone
Cheap propecia without prescription
Buy xanax 2mg no prescription
Buy female viagra without prescription
Xanax no prescription required
Tramadol india
Buy brand name viagra
Valium no rx
Low price viagra
Buy xanax online without prescription
Order xanax cod
Generic levitra uk
Tramadol pharmacy
Real phentermine without prescription
Viagra purchase uk
Generic xanax xr
Online prescription tramadol
Order tramadol online overnight
Order tramadol cod
Phentermine without a prescription
Buy cheap viagra online uk
Cialis order canada
Buying tramadol in uk
Cialis 10mg side effects
Cheap tramadol cod
Overnight delivery viagra
Order tramadol online cod
Viagra cheapest
No prescription valium
Propecia best prices
Cheap generic valium
Propecia usa
Online prescriptions xanax
Viagra online shop
Valium from india
Buy propecia
Viagra canadian online pharmacy
Buy phentermine 37.5mg online
Valium generic
Buying cialis online without a prescription
Discount viagra usa
Viagra cheap no prescription
Low cost levitra
Viagra canada mastercard
Viagra tablets for sale
Xanax generic dosage
Buy cialis viagra
Buy viagra in canada online
Phentermine 37.5mg side effects
Buy phentermine online without prescription
Propecia uk pharmacy
Purchase xanax
Phentermine buy uk
Discount viagra india
Propecia price
Propecia generic cost
Viagra canada prices
Viagra professional online
Viagra super active
Cialis canada no prescription
Buy cialis online from canada
Discount viagra online
Xanax 1mg
Phentermine 37.5 mg
Best viagra alternative
Cialis 20 mg dosage
Buy pfizer viagra without prescription
10mg prednisone
Phentermine diet pills without prescription
Side effects of viagra
Prednisone tablets
Cialis prescription cost
Where to buy levitra online
2mg xanax no prescription
Cheap levitra uk
Viagra india price
Get viagra
Viagra discount coupons
Australia viagra online
Viagra 50mg side effects
Cheap phentermine without prescription
Where can i buy viagra without prescription
Propecia uk prices
Buying levitra without prescription
Purchase phentermine without prescription
Propecia generic canada
Buy propecia online without a prescription
Propecia cost
Xanax buy uk
Buy cialis uk
Best way to take tramadol
Prednisone 20mg side effects
Brand name cialis
Cheapest cialis price
Xanax for sale without prescription
Ordering propecia from canada
Buy generic valium
Purchase levitra online
No prescription cialis online
2.5mg cialis
Buy cheap valium online
Cialis medication
Buying prednisone online
Buy generic phentermine online
Cheap valium online
Cheapest place to buy viagra online
Where to buy viagra online
Buy phentermine 37.5mg pills
Prescription viagra uk
Buy propecia cheap
Viagra discount prices
Buy xanax cheap online
Cheap xanax for sale
Generic viagra 100mg
Levitra samples
Tramadol prescription online
Order cheap phentermine
Free cialis samples
Xanax price per pill
Tramadol without prescription overnight delivery
Genuine viagra online
Overnight xanax delivery