Skip to Content
Many of you know that I own Flex Builder 2 thanks to Thomas Jung (https://www.sdn.sap.com/irj/sdn/wiki?path=/display/profile/thomas%2bjung). So my next natural step was to upgrade to Flex Builder 3 (http://www.adobe.com/products/flex/)…However…Adobe doesn’t have an oficce or a shop in Peru, which means that I can’t buy it -:( Gladly, Adobe provides a free Flex 3 SDK (http://labs.adobe.com/technologies/flex/sdk/flex3sdk.html) which means that we can still develop AIR applications using the command line tools. Use the command line tools it’s kind of boring and time consuming, each time you want to compile an App, you must enter the Command Line tool and type all the details, that’s why I developed using {code:html}Ruby{code} and WxRuby (http://wxruby.rubyforge.org/) a small compiler which helps us to automate the process. Just pass the folder that contains your .mxml files, press a couple of button and you’re done -;) Let’s see the source code first… require ‘rubygems’ require ‘wx’ Btn_ChooseFolder = 1000 Btn_CompileSWF = 1001 Btn_TestAIR = 1002 Btn_CompileAIR = 1003 $config_file = File.dirname(__FILE__) << ” Flex_Dir.txt” $config = IO.readlines($config_file) SWF = $config[0] + “amxmlc.bat” AIRTest = $config[0] + “adl.exe” AIR = $config[0] + “adt.bat” $Files = Array.new $Flex_Files = Array.new $App_Files = Array.new $XML_File = Array.new $exits_xml = false class Blag_Flex < Wx::Frame def initialize(title) super(nil, :title => title, :size => ( 400, 300 )) panel = Wx::Panel.new(self) m_Folder = Wx::StaticText.new(panel, -1, “Project Folder”,Wx::Point.new(10, 12),Wx::Size.new(80, 20)) @mFolder = Wx::TextCtrl.new(panel, -1, “”,Wx::Point.new(100, 10),Wx::Size.new(170, 20)) #—- —————————————————————————————————– m_Id = Wx::StaticText.new(panel, -1, “Id”,Wx::Point.new(20, 32),Wx::Size.new(80, 20)) @mId = Wx::TextCtrl.new(panel, -1, “”,Wx::Point.new(100, 30),Wx::Size.new(170, 20)) m_Version = Wx::StaticText.new(panel, -1, “Version”,Wx::Point.new(20, 52),Wx::Size.new(80, 20)) @mVersion = Wx::TextCtrl.new(panel, -1, “”,Wx::Point.new(100, 50),Wx::Size.new(170, 20)) m_Filename = Wx::StaticText.new(panel, -1, “FileName”,Wx::Point.new(20, 72),Wx::Size.new(80, 20)) @mFilename = Wx::TextCtrl.new(panel, -1, “”,Wx::Point.new(100, 70),Wx::Size.new(170, 20)) m_Content = Wx::StaticText.new(panel, -1, “Content”,Wx::Point.new(20, 92),Wx::Size.new(80, 20)) @mContent = Wx::TextCtrl.new(panel, -1, “”,Wx::Point.new(100, 90),Wx::Size.new(170, 20)) m_Visible = Wx::StaticText.new(panel, -1, “Visible”,Wx::Point.new(20, 112),Wx::Size.new(80, 20)) @mVisible = Wx::TextCtrl.new(panel, -1, “true”,Wx::Point.new(100, 110),Wx::Size.new(170, 20)) m_SystemChrome = Wx::StaticText.new(panel, -1, “SystemChrome”,Wx::Point.new(20, 132),Wx::Size.new(80, 20)) @mSystemChrome = Wx::TextCtrl.new(panel, -1, “none”,Wx::Point.new(100, 130),Wx::Size.new(170, 20)) m_Transparent = Wx::StaticText.new(panel, -1, “Transparent”,Wx::Point.new(20, 152),Wx::Size.new(80, 20)) @mTransparent = Wx::TextCtrl.new(panel, -1, “true”,Wx::Point.new(100, 150),Wx::Size.new(170, 20)) m_Width = Wx::StaticText.new(panel, -1, “Width”,Wx::Point.new(20, 172),Wx::Size.new(80, 20)) @mWidth = Wx::TextCtrl.new(panel, -1, “”,Wx::Point.new(100, 170),Wx::Size.new(170, 20)) m_Height = Wx::StaticText.new(panel, -1, “height”,Wx::Point.new(20, 192),Wx::Size.new(80, 20)) @mHeight = Wx::TextCtrl.new(panel, -1, “”,Wx::Point.new(100, 190),Wx::Size.new(170, 20)) #—- —————————————————————————————————– btnChooseFolder = Wx::Button.new(panel, Btn_ChooseFolder, “Choose”, Wx::Point.new(280, 10),Wx::Size.new(80, 20)) btnCompileSWF = Wx::Button.new(panel, Btn_CompileSWF, “Compile SWF”, Wx::Point.new(10, 220),Wx::Size.new(80, 20)) btnTestAIR = Wx::Button.new(panel, Btn_TestAIR, “Test AIR”, Wx::Point.new(100, 220),Wx::Size.new(80, 20)) btnCompileAIR = Wx::Button.new(panel, Btn_CompileAIR, “Compile AIR”, Wx::Point.new(190, 220),Wx::Size.new(80, 20)) evt_button(Btn_ChooseFolder) {|event| onChooseFolder(event,panel) } evt_button(Btn_CompileSWF) {|event| onCompileSWF(event) } evt_button(Btn_TestAIR) {|event| onTestAIR(event) } evt_button(Btn_CompileAIR) {|event| onCompileAIR(event) } end end def GenerateXML() $XML_File.push(“”) $Dir_Text = @mFolder.get_value $Dir_Text = $Dir_Text << ” ” << @mFilename.get_value << “-app.xml” $output = File.new($Dir_Text,”w”) $XML_File.each {|line| $output.write(“#{line}
“)} $output.close end def onChooseFolder(event,panel) dir_home = Wx::get_home_dir() dialog = Wx::DirDialog.new(panel, “Choose a folder”, dir_home) if dialog.show_modal() == Wx::ID_OK @mFolder.set_value(dialog.get_path()) end end def onCompileSWF(event) $Dir_Text = @mFolder.get_value Dir.foreach($Dir_Text) {|x| $Files.push(x)} for $file in $Files $long = $file.length – 4 $long_xml = $file.length – 8 if($file[$long,4] == ‘mxml’) $file = $Dir_Text << ” ” << $file $Dir_Text = @mFolder.get_value $Flex_Files.push($file) end if($file[$long_xml,8] == ‘-app.xml’) $Dir_Text = @mFolder.get_value $file = $Dir_Text << ” ” << $file $Dir_Text = @mFolder.get_value $App_Files.push($file) $exits_xml = true end end $Cert = @mFolder.get_value $Cert = $Cert << ” sampleCert.pfx” system(AIR,”-certificate”,”-cn”,”SelfSigned”,”1024-RSA”,$Cert,”samplePassword”) for $flex_file in $Flex_Files system(SWF,”-use-network=false”,$flex_file) end if($exits_xml == false) GenerateXML() end end def onTestAIR(event) if($App_Files.empty? != true) for $app_file in $App_Files system(AIRTest,$app_file) end else $Dir_Text = @mFolder.get_value Dir.foreach($Dir_Text) {|x| $Files.push(x)} for $file in $Files $long_xml = $file.length – 8 if($file[$long_xml,8] == ‘-app.xml’) $App_Name = $file[$long_xml,8] $Dir_Text = @mFolder.get_value $file = $Dir_Text << ” ” << $file $Dir_Text = @mFolder.get_value $App_Files.push($file) end end for $app_file in $App_Files system(AIRTest,$app_file) end end end def onCompileAIR(event) if(@mFilename.empty? == true) $Dir_Text = @mFolder.get_value Dir.foreach($Dir_Text) {|x| $Files.push(x)} for $file in $Files $long_xml = $file.length – 8 if($file[$long_xml,8] == ‘-app.xml’) $App_Name = $file[$long_xml,8] $Dir_Text = @mFolder.get_value $file = $Dir_Text << ” ” << $file $Dir_Text = @mFolder.get_value $App_Files.push($file) end end for $app_file in $App_Files $file = IO.readlines($app_file) $pos = $file[4].rindex(“<“) – 1 $str_file = $file[4] $str_file = $str_file[10..$pos] $FileName = $str_file $App_Name_AIR = $FileName + “.air” $Dir_Text = $FileName + “-app.xml” $App_Name_SWF = $FileName + “.swf” $Cert = @mFolder.get_value $Cert = $Cert << ” sampleCert.pfx” Dir.chdir(@mFolder.get_value) system(AIR,”-package”,”-storetype”,”pkcs12″,”-storepass”,”samplePassword”,”-keystore”,$Cert,$App_Name_AIR, $Dir_Text,$App_Name_SWF) end else $App_Name_AIR = @mFilename.get_value + “.air” $Dir_Text = @mFilename.get_value + “-app.xml” $App_Name_SWF = @mFilename.get_value + “.swf” $Cert = @mFolder.get_value $Cert = $Cert << ” sampleCert.pfx” Dir.chdir(@mFolder.get_value) system(AIR,”-package”,”-storetype”,”pkcs12″,”-storepass”,”samplePassword”,”-keystore”,$Cert,$App_Name_AIR, $Dir_Text,$App_Name_SWF) end end Wx::App.run do frame = Blag_Flex.new(“Blag’s Flex 3 Compiler”) frame.show end We also need a small file called Flex_Dir with the information about your Flex 3 SDK installation. C: Programacion flex_sdk_3 bin Now, we can take a look at some pictures -:D
image image image image image
To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply