Well, here is the first public release of Alph:
Alph is a Ruby/Java/Flash (I know...I am insane) that bridges the Ruby and Flash runtimes (and Java too...but that is to solve the cross-platform projector problem that Macromedia will not solve.) With Alph and Ruby (>= 1.8.1) you can create Flash user interfaces (forms, etc) that are fully coded in, and controlled by Ruby. No Actionscript required, no Flash IDE required, just Ruby (and those dependent runtimes). Here is a simple ruby script:
This example demonstrates the List Box family of components (ComboBox, ListBox, Grid). See: http://www.ultrashock.com/tutorials/flashmx2004/ui-components06.php
$:.unshift '../lib' require 'alph' app = Alph::Application.new frame = app.new_frame frame.control.setBounds(100, 100, 640, 480)
flash = frame.flash myComboBox = flash.new_component("mx.controls.ComboBox", :editable=>false, :rowCount=>5, :_x=> 14, :_y=>26, :_width=>291, :_height=>22) myComboBox.labels = ['Organic Snacks', 'Recycled Office Paper', 'Wind Energy', 'Solar Power'] myComboBox.change do |event| # The myComboBox.selectedItem method returns # the label (not an object) because the data is not set. puts "You selected #{myComboBox.selectedItem}." end myList = flash.new_component("mx.controls.List", :_x=> 14, :_y=>66, :_width=>291, :_height=>120) # Data provider is an array of anonymous objects (label/data) myList.dataProvider = [ {:label=> "Organic cotton underwear", :data=> 7.25}, {:label=> "Organic T-Shirt", :data=> 15}, {:label=> "Recycled Office Paper", :data=> 6.99}, {:label=> "Organic Cola", :data=> 1.25} ] myList.change do |event| # The myList.selectedItem method returns an object with # a label and data property because the data _is_ set. item = myList.selectedItem puts "#{item.label} costs $#{item.data}" end myDataGrid = flash.new_component("mx.controls.DataGrid", :_x=> 14, :_y=>200, :_width=>291, :_height=>120) # Column names align with column ids myDataGrid.setColumnNames( ["Product", "Price", "Quantity"] ) # Data provider is an array of anonymous objects (keys = column ids) myDataGrid.dataProvider = [ {:Product=> "Underwear", :Price=> 7.25, :Quantity=> 3}, {:Product=> "T-Shirt", :Price=> 15, :Quantity=> 1}, {:Product=> "Paper", :Price=> 6.99, :Quantity=> 7}, {:Product=> "Cola", :Price=> 1.25, :Quantity=> 24} ] myDataGrid.change do |event| # The myDataGrid.selectedItem method returns the anonymous object item = myDataGrid.selectedItem puts "#{item.Product} costs $#{item.Price} (#{item.Quantity} left in stock)" end # You can rename column names by index myDataGrid.getColumnAt(0).headerText = "Product Name"; myDataGrid.getColumnAt(1).headerText = "Price"; myDataGrid.getColumnAt(2).headerText = "Quantity Left"; flash.new_component("mx.controls.Button", :label=>" Close", :_x=>380, :_y=>89, :_width=>120, :_height=>35, :icon=>"icon_16x16_warning") do |closeButton| closeButton.click do frame.control.close exit end end
frame.control.show app.wait_until_done
Pretty sweet eh?
Go download it, and let me know what you think.