Game Development Reference
In-Depth Information
tables, this won
t matter. However, more sensitive data such as user
information should be hidden. We
'
ll explore ways to overcome this
security deficiency in an online bonus chapter on flashgamebook.com.
'
One More Example: XML versus Flash Vars
A popular way of getting information into a SWF file from its con-
taining HTML page is through the use of Flash Vars. If you
re not
familiar with them, Flash Vars are essentially name/value pairs that
are passed into the SWF upon loading. Say you had a site in which
users could log in and you wanted to display a player
'
sname
inside the game. A traditional solution to this problem would be to
add the username to the object and embed tags in the HTML
page. It would look like as follows:
'
<
object classid=
"
clsid:d27cdb6e-ae6d-11cf-96b8-444553540000
"
codebase=
http://download.macromedia.com/pub/shockwave/cabs/
flash/swflash.cab#version=10,0,0,0
"
"
width=
"
500
"
height=
"
600
"
">
< param name= " allowScriptAccess " value= " sameDomain " / >
< param name= " allowFullScreen " value= " false " / >
< param name= " movie " value= " CrosswordPuzzle.swf " / >
< param name= " quality " value= " high " / >
< param name= " bgcolor " value= " #ffffff " / >
< param name= " flashvars " value= " username=Chris " / >
< embed src= " CrosswordPuzzle.swf " quality= " high "
bgcolor= " #ffffff " width= " 500 " height= " 600 " name= " Crossword
Puzzle " align= " middle " allowScriptAccess= " sameDomain "
allowFullScreen= " false " type= " application/x-shockwave-flash "
pluginspage=http://www.adobe.com/go/getflashplayer
flashvars= " username=Chris " / >
< /object >
id=
"
CrosswordPuzzle
"
align=
"
middle
If you have multiple pieces of information you need to pass into
Flash, they are separated by
s, just like a URL in a browser. There
are a couple of drawbacks to using this system that become very
apparent when you start using more than one or two variables. One
reason is that you
&'
'
re limited to only single name/value pairs; you
can
t store any type of complex data in a Flash Var. The other one is
that it becomes tricky to manage them in the page, and one typo or
error processing could render all of them unavailable. To add to
their annoyance during troubleshooting, any special characters must
be URL-encoded, increasing their lack of readability.
A better option is to use a single Flash Var, maybe called config .
The value of this variable is a path to either a static or a dynamic
XML file. It would probably look something like the following:
'
< param name= " flashvars " value= " config=configuration.xml " / >
Search Nedrilad ::




Custom Search