# Pull in the project-local config file # if it exists... if(File.exists?('script/asclass_config.rb')) # require 'script/asclass_config' # include Config end module AsProject class FlashPlayerError < StandardError; end class FlashPlayer < RemoteFileTask attr_accessor :version, :name, :swf def initialize(name=:flash_player) @name = name @version = 9 super(name) end def remote_task_name return "flash_player-#{version}" end #TODO: Add urls and locations for versions and osx def define_user_task if(version == 7) @win_url = nil @win_extracted_file = nil @osx_url = nil @osx_extracted_file = nil @unix_url = nil @unix_extracted_file = nil elsif(version == 8) @win_url = "http://download.macromedia.com/pub/flashplayer/updaters/8/flash_player_update3_flash8_win.zip" @win_extracted_file = "/Players/Debug/SAFlashPlayer.exe" @osx_url = nil @osx_extracted_file = nil @unix_url = nil @unix_extracted_file = nil elsif(version == 9) @win_url = nil @win_extracted_file = nil @osx_url = nil @osx_extracted_file = nil @unix_url = nil @unix_extracted_file = nil else raise FlashPlayerError.new("It seems you are trying to use a Flash Player version (#{version}) that is not yet supported...") end super end def define super desc "Run #{@swf} file using Flash Player #{version}" task @name => [@swf] task @name do log_file = FlashLog.new.get_file index = 0 File.open(log_file, 'w') do |f| f.write('') end player_thread = Thread.new { execute("./#{@swf}") } if(!File.exists?(log_file)) raise UsageError.new('Unable to find the trace output log file in the expected location: ' + log_file) end while(player_thread.alive?) sleep(0.2) incr = 0 File.open(log_file, "r").readlines.each do |line| incr = incr + 1 if(incr > index) puts "[trace] #{line}" index = index + 1 end end end end end end end