Hello kirupees,
I just build a simple web server, but now in one of the pages I would have to have a flash (.swf) embbeded.
Maybe an easy task, but also I would like that the .swf receives data from the PhP page, but I cant figure how
Simply that when I push the button in the .swf, the sampletext changes to a variable name I have in php.
I asure you that I’ve tried more than 15 tutorials or guides, and searched a lot of forums so please understand my frustation.
If anyone knows how I would appreciate so much the help.
Thanks a lot in advance.
PHP Page
<html>
<body>
<h1><center>SAMPLE PAGE</center></h1>
<?php
//getting the variable I want to send to flash
$username = $_SESSION[‘playername’];
//send variable to Flash(?)
echo $username;
echo ‘<object width=“800” height=“600”><param name=“movie” value=“test.swf”><embed src=“test.swf” width=“800” height=“600”/></object>’;
?>
</body>
</html>
FLASH AS3
import flash.events.*;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
stop();
button.buttonMode = true;
button.addEventListener(MouseEvent.CLICK, clicked);
function clicked (event:MouseEvent):void {
var request:URLRequest = new URLRequest(“http://localhostroomSolid.php”);
request.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.load(request);
function completeHandler(evt:Event) {
var username = evt.target.data.username;
sampletext.text = username;
}
}
pd: as I have very little code I quoted it so you can have a better idea, again, thanks