Flash Lite: Graphics for Mobile Devices
by Hartti Suomela

Listing One

for (i=1; i<10; i++) {
    playerName = eval("name" add i);
    trace(playerName);
}

Listing Two

<?php
// create the SQL query based on query type and the year
// there is a hardcoded 5 row limit (returning only top 5)
switch ($_GET["query"])
{
    case "homeruns":
        $sqlquery = "SELECT nameFirst, nameLast, HR AS value FROM master, batting WHERE master.playerID=batting.playerID AND batting.yearID='" . $_GET["year"] . "' ORDER BY HR DESC LIMIT 0,5";
        break;
    case "salaries":
        $sqlquery = "SELECT nameFirst, nameLast, ROUND(salary) AS value FROM master, salaries WHERE master.playerID=salaries.playerID AND salaries.yearID='" . $_GET["year"] . "' ORDER BY salary DESC LIMIT 0,5";
        break;
    default:
        die("Incorrect query requested");
}
// make the SQL connection ready
mysql_connect("localhost", "root", "") or 
    die("Could not connect to database");
mysql_select_db("baseball") or
    die("Could not select database");
// make the SQL query
$result = mysql_query($sqlquery) or
    die("Could not complete query\n&noData=true&\n&loaded=true&");
// print out the resulting rows as name-value pairs, limited with &-characters
$i = 1;
while ($row = mysql_fetch_array($result))
{
    echo "&name$i=" , $row["nameFirst"] , " " ,  $row["nameLast"] , "&\n";
    echo "&value$i=" , $row["value"] , "&\n";
    $i++;    
}
// turn on the noData flag if result set was empty
if ($i == 1) 
    echo "&noData=true&\n";
// turn on the flag indicating that all data has been loaded
echo "&loaded=true&";
?>


Listing Three

(a)
// this ActionScript sets your content to be full screen
fscommand2("FullScreen", true);
statYear = 2006;
stop();

(b)
on (release) {
    target = "homeruns";
    gotoAndPlay("frLoad");
}

(c)
on (release) {
    target = "salaries";
    gotoAndPlay("frLoad");
}


(d)
on (release) {
    fscommand2("Quit");
}

Listing Four

(a)
// initialize and clear the variables
loaded="false";
noData="false";
for (i=1;i<5;i++)
{
    eval("name" add i) = "";
    eval("value" add i) = "";
}
url = "http://www.hartti.com/bb_hr.txt?query=" add target add "&year=" add statYear;
LoadVariables(url, _root);

(b)
if (loaded eq "true") 
{
    if (noData eq "true")
        gotoAndPlay(1);
    else
       gotoAndStop(target);
}

(c)
gotoAndPlay("wait1");

(d)
fscommand2("SetSoftKeys", "Options", "Back");

(e)
on(keyPress "<PageDown>")
{
    gotoAndPlay(1);
}



2


