Sunday, February 28, 2010

Android Emulator with SD Card

I can't believe how lousy the Android documentation. To run an emulator with an SD Card, we have to do the following:

1. Create an ISO image of our SD card. Can be done with tools like "FREE ISO Creator".

2. After which, store the program somewhere in the drive and go to the SDK/Tools directory via command line. And then run this:
mksdcard 256M C:\Users\Aaron\workspace\tmp.iso

3. Go back to Eclipse, open "AVD manager" (the black phone icon). Then add a new AVD. Select the file option as "C:\Users\Aaron\workspace\tmp.iso

4. When we run the configuration file, remember to target the run AVD manager created in step 3.

Thursday, February 18, 2010

The Drs Show (Speech)

PMS: Please make it stop, Push me Stupid.

Monday, February 8, 2010

(Google Maps/MapQuest) Mapping in ActionScript 2.0

Writing a mapping function (to show direction/map) is really not a trivial matter in ActionScript 2.0. The main reason being ActionScript 2.0 does not support the various API/SDKs by GoogleMaps/MapQuest. Hence in other words, you have to rewrite your entire application (which is written in ActionScript 2.0). Not really a huge issue if the application was a switch from PHP 4 to PHP 5. ActionScript 2.0 and ActionScript 3.0 is a hell lot of difference.

One way to overcome this is to do a popup using the getURL command from within flash. Basically the idea is to write them as two separate application and compile them differently using AS 2.0 and AS 3.0 respectively.

Now this sounds simple enough. But for our case, since its a kiosk (which is calling a program), we cannot simply use getURL because it will call up IE/Mozilla by default. Which means we can't do it the normal getURL way. So that leaves us to create our own strip down browser and launch it with a batch file.

Step 1: Create a browser
Can be done with VB.NET with a simple webbrowser dialog. Name it SimpleBrowser.exe

Step 2: Create a batch file
With something like: fscommand("exec", "run.bat");
*now you have to create a folder call fscommand and place run.bat inside.

A batch file can be created with:
   >@echo off
   >start SimpleBrowser.exe %1

But there is a problem with the batch file as it shows the ugly black exe executing. One way around it is to use proxy.exe which was written by northcode. However, I ran into problems passing variables (we need to pass the map's URL) into the batch file. After much trying, I gave up and went the direction of writting the variables to a text file instead.

Step 3: Writing variables to a text file

In ActionScript 2.0 when you write to textfile using LoadVars, it will cause a popup/refresh. So you won't want to do it. Instead I went ahead with FFishScript again and used the following (within Flash):
_root.myURLString = vURLmap;
fscommand("ffish_run", "savetextfile");

Inside (FFscript), i created a script call savetextfile and put the following codes into it:
var myURLString = FlashPlayer.getVariable("myURLString");
var file = new FileStream("C:\\url.txt", "w");
file.writeLine(myURLString);
file.close();

Step 4: Linking Browser with the url output of a textfile
Again, I did it in FFIshScript, after the file.close() command.
Shell.run("C:\\SimpleBrowserC.exe", 1, 100,100);

In VB.NET i did the usual StreamReader and ReadLine and obtain the URL that we got from step 3.

Now everything should just work beautifully. :)

Aaron

Hacking the Print Function (Flash)

Printing in Flash without the dialog box is not a trivial issue. It can mainly be done in the following methods:

1. Having a wrapper around the SWF (by programs such as Zinc and SWFKit)
2. Hacking the Registry in the Operating System
3. Automatic clicking, such as auto-hot-key
4. Javascript clicking

I tried all four methods, and here are the results:

Method 1 works the best, the codes for using method #1 is really just:
FlashPlayer.showPrintDlg = false;
(this is in FFishScript which is SWFKit's language)

Method 2 does not work (at least for vista) which is what the Kiosk OS is on.

Method 3 does not work too. At least for me.

Method 4 works, but I don't actually launch my print function from within the SWF mode. I launch it in projector mode. The codes for Javascript method is:

<script language="JavaScript">
function printit() {
window.print();
}
</script>

Testing

<script language='VBScript'>
Sub Print()
OLECMDID_PRINT = 6
OLECMDEXECOPT_DONTPROMPTUSER = 2
OLECMDEXECOPT_PROMPTUSER = 1
call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,1)
End Sub
document.write "<object ID='WB' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>"
</script>

Friday, February 5, 2010

Replace newline in actionscript/flash

desc_txt.text = searchAndReplace(_global.WebHandler.mDesc, "\r\r", "\n");