Sunteți pe pagina 1din 10

Game Development in Flash & PHP

Presenter: Tianyang (TYLER Projects)‫‏‬


For PHP User Group 21-02-2008
Overview
FLASH
  Embedding

  Preloaders

  Communicating with PHP

  Security

PHP
  Database

  Security

Q&A
Embedding Flash
<embed
src="file.swf"
width="300"
height="300"
flashvars="myvar=99&myvar2=200"
/>

Eolas and XHTML problems

- Use free SWFObject javascript to create embed


code
Preloader
Large files – Important to show download progress

function loadClient() {
var loader:Loader = new Loader();
configureListeners(loader.contentLoaderInfo);
var request:URLRequest = new URLRequest(url);
loader.load(request);
addChild(loader);
}
function configureListeners(dispatcher:IEventDispatcher):void {
dispatcher.addEventListener(Event.COMPLETE, completeHandler);
}
function completeHandler(event:Event):void {
removeChild(loaderClip); // Remove preloader progress clip
}
IOErrorEvent.IO_ERROR // File not found etc...
HTTPStatusEvent.HTTP_STATUS // 404 error etc...
ProgressEvent.PROGRESS // Update progress bar
Misc other events: Event.UNLOAD, OPEN, INIT etc...
Communicating with PHP

var req:URLRequest =
new URLRequest(“submit.php”);

var variables:URLVariables = new URLVariables();

variables.op = "getResource"; // Data to send


req.data = variables;
req.method = URLRequestMethod.POST;

var loader:URLLoader = new URLLoader(req);


loader.addEventListener(Event.COMPLETE,loadInfoHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR,ErrorHandler);
Communicating with PHP

function loadInfoCompleteHandler(event:Event):void {
var xml:XML = new XML(event.target.data);
var tobj = xml.elements('myoutputlist');
mydata = xml.elements('myoutputlist')[0].attribute("var1");
}
Security

  Client-side
  Not secured

  Variables easily changeable via memory editors

  Single-player games vs Multi-player

  Decompiler

Solution
  Obfuscation

  Manipulating variables

  Server-side processing
Storing Player Data
Data to store:
  Highscore List

  User IDs, Name

  Resources: Cash, Items etc...

  Game variables

Table Types
  Static

  MyISAM vs InnoDB

  Memory

Do query caching for highscore



Proper indexing
Security

Clean Inputs:
 Use intval() for all integer values

 Filter special characters for strings


Q&A

To show:
Demo from battlestations.
Contact: contact@mobileweapon.net
Try the game:
http://apps.facebook.com/battlestations

S-ar putea să vă placă și