Mar 26 2008

RubyIZUMI – Open Source RTMP Server(MP4/H.264) for streaming Flash video/audio

Tag: RTMP, RubyDerek Wischusen @ 3:04 am

Here is yet another exciting Flash-related Ruby project. Takuma Mori at Vixy.tv recently released RubyIZUMI, an open source streaming Flash server that can stream H.264 encoded videos over RTMP that is written in pure Ruby.

You can check out a demo of the server in action here.


Mar 24 2008

HotRuby – Ruby for Flash and JavaScript

Tag: Flex, Ruby, hotruby, iron monkeyDerek Wischusen @ 2:19 am

It looks like there is another project, in addition to IronMonkey (which I wrote about in a previous post), that is looking to bring Ruby support to Flash/Flex (and JavaScript).

HotRuby is a Ruby VM, which is written in JavaScript, that runs opcode that is compiled by YARV (the VM that is used in Ruby 1.9). 

Using HotRuby it is possible to use straight Ruby to build a Flash app.  Here are a couple Flash examples from the HotRuby website:

You can grab the source files for HotRuby from the Google Project site.


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.


Sep 19 2007

FunFX – A Ruby based automated testing framework for Flex

Tag: Flex, Ruby, TDD, TestingDerek Wischusen @ 4:31 pm

During the development of a large-scale (or even a medium-scale) Flex application it is very likely that you will quickly reach a point where manually testing your interface becomes impractical. This is where Flex’s automation framework comes into play. It makes it possible to simulate user level interactions in your Flex interfaces. So, you can write a script that performs a series of interactions (e.g., click this button, fill out this form, click here, click there, and so on) and then automatically run that script, and any others, with the rest of your tests. Pretty nice, right? Well, there is one potential problem; until recently there was only one existing solution that worked with Flex’s automation framework, and it is pretty expensive. Fortunately, there is now another option.

FunFX is a free, open source framework, developed by Peter Motzfeldt, that makes it possible to take advantage of Flex’s automation framework using test scripts written in Ruby. It is still relatively early in its development, but as you can see in this tutorial video, it already has some pretty impressive functionality. FunFX is packaged as a Ruby gem. I was unable to install it via the normal gem install route, so for now it looks like you’ll have to download it from here and do a local install.

CREDITS:

I came across this gem via Aslak Hellesoy’s blog (who, incidentally, just gave a well received tutorial on using Flex and Rails at RailsConf Europe).


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 13 2007

Ruby-like Mixins in ActionScript 3

Tag: AS3, RubyDerek Wischusen @ 2:26 am

That title may be a bit of a stretch, AS3 does not support mixins in the same way as Ruby, but it is possible to define a set of methods and/or attributes in a single file and then mix those methods and attributes into your AS3 classes. Here’s how:

First create a new ActionScript file (a file, not a class) then add the methods and/or attributes that you want to mix in to your classes.

For example, I created a file called classmixin.as that looks like this:

// ActionScript file 
 
	import flash.utils.*; 
 
        // returns the name of the class 
	public function whoAmI () : String 
	{ 
		return getQualifiedClassName(this); 
	} 
 
        // returns the class object 
	public function myClass () : Class 
	{ 
		return getDefinitionByName(whoAmI()) as Class; 
	} 
 
        // returns the prototype object 
	public function proto () : Object 
	{ 
		return myClass().prototype; 
	}

Now, let’s say that you want to add these methods directly to two classes, one is controller called ContactsController and one is a model called Contact. To do this you need to use the include statement along with the relative path to file that defines the methods. For example:

package com.rxr.mixinexample.control 
{ 
	public class ContactsController 
	{ 
		include "/../classmixin/classmixin.as" 
	} 
}
package com.rxr.mixinexample.model 
{ 
	public class Contact 
	{ 
		include "/../classmixin/classmixin.as" 
	} 
}

That’s it. Now both of these classes have all of the methods defined in classmixin.as, so if you were to run the following code:

package { 
	import flash.display.Sprite; 
	import com.rxr.mixinexample.control.ContactsController; 
	import com.rxr.mixinexample.model.Contact; 
 
	public class MixinExample extends Sprite 
	{ 
		public function MixinExample() 
		{ 
			var a : ContactsController = new ContactsController(); 
			var b : Contact = new Contact(); 
 
			trace(a.whoAmI()); 
			trace(b.whoAmI()); 
 
		} 
	} 
}

you would see these trace statements in the console:

com.rxr.mixinexample.control::ContactsController
com.rxr.mixinexample.model::Contact

This mixin capability in AS3 works a bit differently than mixins in Ruby. In Ruby when you mixin a module you are really creating a reference to that module and when you call a method that was mixed in it is actually being delegated to the module. Also, in Ruby when you mixin in a module only the member methods get mixed in, though there is way to mixin statics as well, but you have to add some extra code to make this happen. This is because the module is an object itself and the static methods belong to the module, so if you want to add them to your class you need to extend the module.

In AS3 when you include a .as file, it is though you are appending that file directly to the class definition. So you are not creating a reference to a module, you are just adding the contents of the file to your class, so if you define static attributes or methods they will be added to your class along with the member attributes and methods.

Please let me know if you have any questions, or if any of this is unclear.

You can grab the source files for this example here.


Apr 29 2007

Extending Apollo with Ruby using RubyAMF

Tag: Apollo, Flex, Ruby, RubyAMFDerek Wischusen @ 3:08 am

At the end of my last post about RubyAMF I mentioned that I was particularly interested in how it could be used to extend Apollo applications using Ruby in the same way that Artemis makes it possible to extend Apollo with Java.

Here’s why:

  • It enables AMF3 communication between Flex and Ruby.
  • It comes with its own webrick servlet, so deploying RubyAMF is dead simple (if you have Ruby installed).
  • It’s small: less than 300k. So it’s a quick download.

Here’s an example:

I put together a very simple demo app that uses RubyAMF to extend Apollo. I am calling the app Clairify (because everything needs a name). Clairify allows you to take a screenshot of whatever is underneath it, mark it up with some simple drawing tools and text boxes, and then save it to disk. The concept behind Clairify is that you could use it to quickly provide feedback on an application’s UI.

It would take several steps and downloads for many people to run the app, so I’ve put together a short video.

Here is a quick overview of what is going on in the video:

  1. I launch Clairify.
  2. When Clairify launches all you see are the controls. The rest of the app is transparent.
  3. I then bring up the interface that I want to capture (the login screen of my simple issue tracker).
  4. I click the capture button. This calls code in Ruby (see below) that captures the screen and saves the image to a PNG that Apollo loads.
  5. I add some comments to screen.
  6. I click save, which uses Apollo’s File API to save the marked up image to my desktop as PNG.
  7. I open up the PNG in Fireworks.

Click here to view the video.

If you want to take a look at the Apollo source code, click here. (If you really want to know how to run this on your own machine let me know and I will put together some instructions).

And, here is the Ruby code:

require 'win32screenshot'
require 'RMagick'
include Magick

class CaptureService
  def screenCapture
    width, height, bitmap = Win32::Screenshot.desktop
    img_lst = ImageList.new
    img_lst.from_blob(bitmap)
    img_lst.write('public/screen.png')
    true
  end
end

Credits:
Clairify is based on the ScreenPlay app that is avalable on Adobe Labs.


Where can i buy cialis without a prescription
Levitra samples
Viagra online uk
Canada pharmacy valium
Buy cialis in the uk
Discount viagra pills
Viagra discount coupons
Low cost cialis
Buy viagra from canada
Purchase phentermine without prescription
Ordering cialis online
Low price viagra
Buy levitra
Cheap 100mg viagra
Cheap xanax bars
Australia viagra online
Viagra canada mastercard
Get viagra prescription
Propecia uk pharmacy
Valium 10 mg
Blood pressure and prednisone
40 mg prednisone side effects
Buy phentermine 37.5mg pills
Cheapest cialis professional
Levitra online cheap
Levitra canada
Buy valium no rx
Discount viagra online
Cialis prices uk
Purchase phentermine online
Levitra price
Where to buy phentermine cheap
Viagra prescription
Viagra 50 mg online without prescription
Viagra cheapest
Propecia cost
Phentermine online uk
Propecia generic online
Prednisone dosages
Cialis dosage 20mg
Authentic phentermine 37.5
Low price cialis
Tramadol cheapest
Discount viagra usa
Buy cialis viagra
Pharmacy tramadol
Cheap generic valium
Cialis uk sales
Buy viagra online in australia
Order tramadol online overnight
Xanax price per pill
Tramadol india
Viagra pharmacy prices
Buy propecia
Cheap cialis pills
Viagra dosage information
Free cialis online
Phentermine buy australia
Where can i buy viagra without a prescription
Buy propecia cheap
Order prednisone no prescription
Tramadol dosage
Purchase levitra online
Viagra shop online
Order tramadol cod
Phentermine 37.5 wholesale
Generic viagra super active
Viagra without prescription uk
Buy viagra uk online
Phentermine 37.5 pills
Buy viagra australia
Prednisone 40 mg
Cheap xanax for sale
Best way to take tramadol
Propecia information
Cheap generic viagra
Valium pill 10mg
Best viagra alternative
Side effects of viagra
Order cheap viagra online
Prednisone tablets
Prescription viagra canada
Best prices for cialis
Buy propecia online without a prescription
Generic xanax xr
Propecia usa
Ordering propecia from canada
Xanax online cheap
Buy viagra 100mg
Valium drug side effects
Where to buy cialis safely
Dose of xanax
How to buy valium without a prescription
Cheap valium online
Viagra online cheap
Mail order phentermine
Viagra generic
Cialis medication
Propecia cheap
Buying cialis
Buy brand name viagra
Buy valium cheap online
No prescription cialis online
Viagra online purchase in india
Buy levitra online canada
Best price cialis
Free cialis samples
Buying viagra in new zealand
100mg tramadol effects
Phentermine buy uk
Levitra us
Buy viagra online uk no prescription
Tramadol without prescription overnight delivery
Where to buy propecia in canada
Generic viagra sales
Buy xanax canada
Pfizer viagra price
Cheap tramadol overnight delivery
Dosage of xanax
Phentermine hcl no prescription
Phentermine canada no prescription
Generic viagra 100mg
Get viagra
Valium online uk
Cialis ordering
Where can i buy viagra without prescription
Cialis 20mg
Viagra for sale online
Xanax overnight cod
Order xanax cod
Valium online pharmacy
Generic cialis tadalafil
Buying tramadol in uk
Australia viagra prescription
Cialis canada no prescription
Buy generic valium
Cheapest place to buy viagra online
Buy viagra online in ireland
Valium generic
Xanax bars side effects
Where to buy viagra in england
Phentermine 37.5 buy online
Propecia ireland
Order cheap phentermine
Tramadol no prescription overnight delivery
Buy generic valium online
Cheap tramadol cod
Viagra 50mg side effects
Generic viagra for sale
No prescription valium
Phentermine 37.5mg
Best price on phentermine
Buy valium europe
Buy viagra online cheap
Viagra professional online
Buy cialis online from canada
Viagra buy online no prescription
Cheapest levitra
Cialis 10mg side effects
Cheap cialis viagra
Purchase tramadol without prescription
Valium online overnight
Buy valium without prescription uk
Purchase viagra online without prescription
Levitra online buy
Viagra purchase uk
Viagra canadian online pharmacy
Buying viagra online
Buy pfizer viagra without prescription
Xanax buy uk
Cialis for sale
Brand viagra cheap
Buy cialis brand
Cialis order canada
Buy cheap viagra online uk
Buying xanax online without prescription
Buying levitra without prescription
Cialis online canadian pharmacy
Xanax for sale without prescription
Buy generic phentermine online
Buy generic cialis online
Viagra in usa
Buy xanax online without prescription
Free samples of cialis
Cialis purchase online
Valium cheapest
Best levitra prices
Viagra express delivery
Generic cialis uk
Real phentermine without prescription
Buy xanax 2mg no prescription
Viagra price canada
Tramadol free shipping
Cheap propecia without prescription
Buying cialis online without a prescription
Generic propecia
Purchase tramadol online
Cost of viagra 50mg
Viagra in the philippines
Cheap cialis soft tabs
Cheap cialis
Online prescription tramadol
Discount viagra india
Viagra prescription cost
Valium online fast delivery
Viagra online without prescription reviews
Tramadol prescription online
Viagra cheap no prescription
Order xanax online
Propecia best prices
Prednisone online
Buy tramadol overnight
Canada viagra
Levitra 20mg
Valium from india
Buy phentermine hcl 37.5 no prescription
2mg xanax no prescription
Buy phentermine no script
Canada viagra no prescription
Generic levitra uk
Viagra india price
Generic xanax
Buying prednisone online
Tramadol without prescription
Prescription viagra uk
Phentermine online free shipping
Order tramadol online cod
Buy generic cialis
Buy tramadol cod
Xanax no rx
Fedex tramadol
Buy generic propecia uk
Phentermine 37.5mg side effects
Phentermine 37.5 mg
Prescription free viagra
Xanax bars effects
How to buy phentermine online
Tramadol online no prescription overnight
Drug phentermine
Generic viagra online without prescription
Viagra generic cheap
Viagra tablets for sale
Generic cialis overnight
Purchase cialis without a prescription
Viagra no prescription online
Levitra on sale
Generic tramadol
Buy generic xanax no prescription
Cheap cialis india
Prescription valium