PHP code – passing variables between flash and PHP

16 10 2008

Flash

// first we make a new loadvars object to hold the variables that are being loaded from the php file
myData = new LoadVars();
//this is the part where we execute the function that handles the loaded data
myData.onLoad = function(){
 VariableLoad
();//call the function
};
//here we load in the php file, make sure you set the right path to your file
myData.load(“http://localhost/index.php”);

//this is the function that handles the data.
//the variables now sorta live in the loadVars object we set named myData
//So we can call em like myData.myVariableInthePhpPrintedString
//just look at the script and whatch carefully how its being called and it should become clear to ya. 
VariableLoad = function(){
 txtBox1.text = myData.textbData1;
 txtBox2.text = myData.textbData2;
 txtBox3.text = myData.textbData3;
};

PHP

<?php
/*Getting the variable ‘toPHP’ sent from flash using the ‘POST’ method*/
$fromFlash = $_POST['toPHP'];
/*Encrypting the $fromFlash and storing it as $encrypted*/
$encrypted = md5($fromFlash);
/*getting ready to send a variable to flash named toFlash using ‘&variableName=’*/
$toFlash = “&toFlash=”;
/*Asigning the encrypted variable to $toFlash AFTER the ‘=’*/
$toFlash .= $encrypted;
/*echoing out $toFlash so that flash can read it*/
echo $toFlash;
?>





New behaviours

15 10 2008

1. When happy:

  • Moves around at a faster speed
  • if it becomes happy it can duplicate

2. When unhappy:

  • Doesnt sleep
  • Moves around slower
  • Eats other cells?
  • Wont duplicate

These are additional behaviour patterns to the ones from my previous post (if your lazy click here to go to the post im talking about)

Sleeping has now been achieved!!!





We love the petri dish idea

15 10 2008

So as part of our “break” from writing code for about 6 hours, we thought we would quickly do a design for the background image of our site this will all be mounted onto.

We are going for a science table theme and in the petri dish is our annie organism. Obviously we will upload the swf over the center of this image (minus the petri dish) so it will look nice and flush.

Even though we are using flash for the coding, we dont want it to look like its been done in flash…

our science desk

our science desk





Our 1st cell… IT LIVES!!!

15 10 2008

Our 1st cell attempt can be viewed here

Cell attempt 1

Using a pong like scenario, the cell is confined to the petri dish, we have it moving and we have it staying in the dish… we also have the backbone of the code completed and fully tested to add more cells at a later date.





Starting the production

15 10 2008

We have come up with countless skins and design ideas for this organism, now we have to start testing the code out. We have identified the types of languages we will be writing in and which parts will do what. PHP and SQL will be in control of storing our data and calling it into the actionscript. From here the actionscript will hold the rule set needed to ‘behave’.

  • We will look at the collision detection tutorials for AS2 and try and use those concepts to make a box for the organism to be contained within.
  • We will look at storing flash variables to PHP and then storing those to an SQL database. We will then look at recalling these variables through PHP and inputting that back into flash. This memory function will operate the behaviour of the creature to go feed on its own.
  • Look at putting it all together
  • Look at developing our organism – dependant on time left!




15 10 2008

“the idea drives the project.”





Yet another change of direction

15 10 2008

We have found our limits with googles “im feeling lucky” button. It was going to be our main method for obtaining the URLs, which would then be stringed for the ‘food’. We have found that the search function cannot be used in an automated way ie, it requires the onsubmit function to work. We are then asking ourselves what makes the URL source for food so amazing? We ended up coming up with the idea of user submitted food. Instead of typing random food or words in we are getting users to submit their email address. From this we can string it just like the URL and also use the email as a form of interactivity with the organism (this will be explained once we have thought about it).

Another thing we have decided to change is the way its displayed, we feel there isnt enough feedback to get the true experience of evolution and what we do want it to do is not achievable in the short space of time we have. We have instead decided to go for a motion theme whereby the organism is bouncing around using pixel collision code, and the food changes its speed and size. We also have scope to develop the ‘reproducing’ part of our life cycle by adding more organisms to the same box. These will also react with each other.

Although these are fairly big changes, we feel it is still based around the same concepts as our original idea, we still have mood states which affect behaviour now both in appearance and in movement!

button.addEventListener(MouseEvent.CLICK, callLink);
function callLink(event:MouseEvent):void {
var url:String = “http://google.co.uk”;
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request, ‘_self’);
} catch (e:Error) {
trace(“Error occurred!”);
}
}

We got this part to work with the getURL function, but popup blockers and flash settings would actually restrict certain people from visiting the website therefor not supplying our organism with the food it needs! This is the main reason we had to scrap it.








Follow

Get every new post delivered to your Inbox.