FlashFile Launcher

Flash MX Standalone Player requires CarbonLib 1.5 or later to run on Mac OS 9.x (the CarbonLib functionality is built into OS X so nothing additional is required for that OS).
The following script will check the installed version of CarbonLib of your system. If you don’t meet the requirements you might want to install a CarbonLib 1.6 from this CD-ROM.

Modify to match your needs…

OS version: Any

-- This is the name of the FlashFile to be lauchend after test has succeeded
property docName : "yourFlashStandalonePlayer"

tell application "Finder"
	try
		-- Check the version of the OS
		copy my gestaltVersion_info("sysv", 4) to {system_version, system_string}
		-- You can skip all further tests, because system is up to date
		if the system_version is greater than "0922" then
			-- display dialog "Congratulations, you already have Mac OS " & system_string & return & return & ¬
			--	"Enjoy the namics labor!" & return buttons {"Thank you."} default button 1
			
			-- Now the script will try to open the FlashFile with given name docName 
			-- it has to be in the same directory as this script
			try
				open application file docName of container of (the path to me)
			on error
				display dialog "///////////// Error /////////////" & return & return & ¬
					"Can’t find and open the application \"" & docName & "\"" & return & return & ¬
					"Please open from namics labor CD." buttons {"OK"} with icon 2
				return
			end try
		else if the system_version is less than "0900" then
			-- If the system version is too old you can’t update CarbonLib and Flash MX player will not run
			display dialog "The namics labor requires Mac OS 9.x or higher." & ¬
				return & return & "The currently installed version is: " & ¬
				system_string buttons {"Cancel"} default button 1
			return
		end if
		
		-- Check the version of CarbonLib: it has to be 1.5 or higher
		copy my gestaltVersion_info("cbon", 4) to {CL_version, CL_string}
		if the CL_version is less than "0150" then
			display dialog "The namics labor requires" & return & "CarbonLib 1.5 or higher." & return & ¬
				return & "The currently installed version is: " & CL_string & return & return & ¬
				"Do you want to install the current version now?" with icon 1
			
			(* You can include a CarbonLib installer on a CD-ROM, the script will try to open the folder  which containsthe installer
			This will give the user a language selection choice and control about the installation
			Because Apple provides the installer as a SMI disk image, some user may need more advice about the installation...
			As an alternative, you might try to open the "software update" control panel.
			*)
			try
				open folder "Install CarbonLib" of container of (the path to me)
			on error
				display dialog "There is something wrong with the script, anyway..." & return & return & ¬
					"Please locate the \"Install CarbonLib\" folder on the CD-ROM manually." & return buttons {"OK."} default button 1 with icon 2
				return
			end try
			activate
		end if
		--display dialog "Congratulations, you already have" & return & "Mac OS " & system_string & "and CarbonLib " & CL_string & return & return & ¬
		--	"Enjoy the namics labor!" & return buttons {"Thank you."} default button 1
		
		-- Now the script will try to open the FlashFile with given name docName 
		-- it has to be in the same directory as this script
		try
			open application file docName of container of (the path to me)
		on error
			display dialog "///////////// Error /////////////" & return & return & ¬
				"Can’t find and open the application \"" & docName & "\"" & return & return & ¬
				"Please open from namics labor CD." buttons {"OK"} with icon 2
			return
		end try
	on error
		display dialog "///////////// Error /////////////" & return & return & ¬
			"Can’t find and open the application \"" & docName & "\"" & return & return & ¬
			"Please open from namics labor CD." buttons {"OK"} with icon 2
	end try
end tell

-- sub routine to read the system information
on gestaltVersion_info(gestalt_code, string_length)
	try
		tell application "Finder" to ¬
			copy my NumToHex((system attribute gestalt_code), ¬
				string_length) to {a, b, c, d}
		set the numeric_version to {a, b, c, d} as string
		if a is "0" then set a to ""
		set the version_string to (a & b & "." & c & "." & d) as string
		return {numeric_version, version_string}
	on error
		return {"", "unknown"}
	end try
end gestaltVersion_info

on NumToHex(hexData, stringLength)
	set hexString to {}
	repeat with i from stringLength to 1 by -1
		set hexString to ((hexData mod 16) as string) & hexString
		set hexData to hexData div 16
	end repeat
	return (hexString as string)
end NumToHex