Accessibility

Table of Contents

Tips for Developing Flash Games for the iRiver U10

Tips for coders

Currently, there is no development-specific emulator for the U10, even though the U10 supports Flash Lite 1.1. To test its actual performance, you must transfer your completed content to the U10. Instead of publishing in Flash Lite 1.1, I recommend that you publish content in Flash 4 and then transfer the SWF file to the U10 to check its performance.

Introducing Flash 4 grammar

Below are some considerations to keep in mind when publishing content in Flash 4:

  • Flash Lite 1.1 borrows the slash (/) notation from Flash 4. Even though some developers use the dot notation introduced in Flash 5, you'll need to familiarize yourself with this slash notation because it is used in the overall structure of Flash Lite 1.1 content.
  • Slash notation identifies the appropriate instances (movie clips) that are under _root by a slash as follows: /instanceName/instanceName.
    To specify a variable and property in an instance, use a colon (:).
  • You can use ../ and ./ to specify a relative path such as this and _parent.
  • Table 1 shows some common syntax in Flash 8 and its equivalent in Flash 4.
Table 1. Syntax examples in Flash 8 and Flash 4
Flash 8 Flash 4
_root.instance._visible=false; /instance:_visible = false;
_parent.myName="MiniGate"; ../:myName = "MiniGate";
this.instance.dx = 3; instance:dx = 3;

Requirements for key mapping

Unlike desktop computers and phones that have keys you can press, you can use only navigation buttons with the iRiver U10 (up, down, left, and right) and volume buttons (+, –). These keys are mapped to Up, Down, Left, and Right for navigation, and PageUp and PageDown for volume.

You can use this like a generic button clip, as shown in the following example:

  // U10 Up button event
on (keyPress "<Up>") {
  // Handle Up button event
}
  // U10 volume + button event
on(keyPress "<PageUp>") {
  // Handle Volume Up button event
}

You can find the source file for this example (see Figure 1) in the sample files linked to at the beginning of this article.

Test key mapping example (sample1.swf)

Figure 1. Test key mapping example (sample1.swf)

onLoad and onEnterframe

Flash Lite 1.1 does not include onClipEvent. Therefore, to make the same effect as in Figure 1, you need to do so by moving frames.

In Frame 1 in the created movie clip, I input the content that will be in onLoad. In Frame 2, I input the content that will be in onEnterFrame. Finally, in Frame 3 (see Figure 2), I input gotoAndPlay(2);. When the movie clip appears, it runs Frame 1 (onLoad) first and then repeats playing the actions of Frame 2 (onEnterFrame).

ActionScript of Frame 1, 2, and 3

Figure 2. ActionScript of Frames 1, 2, and 3

Arrays

Because Flash Lite 1.1 does not support arrays, you must list the variables one by one. You can use eval() to simulate arrays, however, Retrieve the value of an object or variable expressed by a string that you entered as a parameter, such as in the following example:

eval("a") = 3;                //Save 3 in the variable of a.
eval("a" add 3) = 12;            // Save 12 in the variable of a3.
eval("/instance:myName") = "MiniGate";    //In the myName variable in the instance movie clip, 
                    save "MiniGate".

Here is an example you can use to simulate arrays:

//The values from 0 to 9 is saved in the variables from a0 to a9.
for(i=0; i<10; i++){
   eval("a" add i) = i;
}

Functions

Flash Lite 1.1 does not support functions. However, you can use call() instead of a function. The following examples show a function in Flash 8 and how you can simulate it in Flash 4 using call().

Flash 8:

function name () {};
// execute the name function.
   name();

Flash 4:

Insert a script in the frame labeled name
// Use call() to run a script in a corresponding frame.
   call("name");

Direct control of movie clips

Flash Lite 1.1 does not support direct control of movie clips. To control a movie clip, use tellTarget(). The following examples show how to directly control a movie clip in Flash 8 and how to simulate it with tellTarget() in Flash 4.

Flash 8:

chicken.wing.gotoAndPlay(1)

Flash 4:

tellTarget("chicken/wing") {
		gotoAndPlay(1)  
	}

Common problems

In Flash 4, you have to distinguish a string operation from a number. Use the add operator to combine strings, and use the eq and ne operators to compare one string with another. Be careful not to misuse the = or + operators in a string operation.

The following examples show operators in Flash 8 and their equivalents in Flash 4:

"Mini" + "Gate"                  ->   "Mini" add "Gate"
_parent.yourName == "MiniGate"   ->   ../:yourName eq "MiniGate"
yourName != "BigGate"            ->   yourName ne "BigGate"

In Flash 4, Boolean values are converted to numbers like 0 and 1. When you actually write code, you can use true or false. However, remember that the Boolean values are perceived as 1 or 0.

firstData = true;
secondData = false;
result = firstData add " : " add secondData;
trace(result);	//trace is "1 : 0"

In Flash 4, there is no reference to instance. You have to type a "string" format when you need to type an instance name for a parameter to use a built-in function. For example, in the case of tellTarget(), the target instance name can be identified when you insert "/instance/sub", not /instance/sub.

This can be confusing when you work with Flash 4. It works out easily if you keep in mind that there is no reference to an instance.

Incorrect example:

tellTarget(myInstance) {}

Correct example:

tellTarget("myInstance") {}

In the incorrect example, myInstance is identified as a variable, not a movie clip, which will be considered the same as tellTarget("") {}.

Use FSCommand2()

Flash Lite uses FSCommand2() to retrieve the device information of the iRiver U10. There are several commands in FSCommand2(). By default, the most common commands specific to the U10 are as follows (see also Figure 3):

  • Command that retrieves the date from the device:
    Date(Year, Month, Day)
fscommand2 ("GetDateYear");
fscommand2 ("GetDateMonth");
fscommand2 ("GetDateDay");
  • Command that retrieves the time from the device:
    Time(Hour, Minute, Second)

fscommand2 ("GetTimeHours");
fscommand2 ("GetTimeMinutes");
fscommand2("GetTimesec");
  • Command that retrieves the name of the device:
    fscommand2 ("GetDevice", "devicename");
// Retrieve the name of device.
fscommand2 ("GetDevice", "devicename");
trace(devicename); // Trace is "iriver U10"ta
  • Command that retrieves the battery level:
    Total battery level
    fscommand2 ("GetMaxBatteryLevel");

    Current battery level
    fscommand2 ("GetBatteryLevel");
// Retrieve total battery level.
maxBatt = fscommand2 ("GetMaxBatteryLevel");
// Retrieve current battery level.
battLevel = fscommand2 ("GetBatteryLevel");
tellTarget ("battery") {
// Move the battery movie clip by the extent that the current battery level indicates.
gotoAndStop (../:battLevel + 1);
}
  • Command that retrieves in-memory of the device:
    Total amount of memory
    fscommand2 ("GetTotalPlayerMemory");

    Amount of available memory
    fscommand2 ("GetFreePlayerMemory");

  • Command that retrieves the image information of the device:

    Number of images
    fscommand2("Get", "Picture", "Total", "totalpic")

    Path of images
    fscommand2("Get", "Picture", "Path", pic_num, "url")
totalpic = 0 // the number of images
pic_num = 1 // Image index number
// Retrieve the number of images that U10 contains.
status = fscommand2("Get", "Picture", "Total", "totalpic")
if (totalpic > 0) {
// Retrieve the image path that corresponds to the image index number.
status = fscommand2("Get", "Picture", "Path", pic_num, "url")
// Retrieve an image to the back movie clip.
loadMovie(url, "back");
}
  • Command that ends the appropriate Flash animation
    fscommand2 ("Quit");
Examples of common commands specific to the U10 (sample3.swf)

Figure 3. Examples of common commands specific to the U10 (sample3.swf)