I have and issue and am not sure if it is a
PHP issue or actionscript, but believe it to be php. I have written a script that passes a variable from a php page to a swf file that plays a song whenloaded. I have written the script in both action script 2.0 and 3.0. It works in the Flash IDE when I test the movie. I can trace, load and play with no issue. However when I put the code online at my hosted account, it will not play. It is as if it no longer recognizes the same urlencode. I copy verbatim and make all proper references to the correct page, but nothing. Any help would be greatly appreciated. Here is my code:
in php I just keep it simple. This works on the IDE and recognizes and plays the song called “As”. The actionscript is looking for “yorName” and finds it.
<?php
“&yorName=As&”;
?>
Here is the AS3
import flash.events.Event;
import flash.net.*;
var body_txt:TextField = new TextField();
var yourName:String;
body_txt.x = 98;
body_txt.y = 66;
body_txt.autoSize = TextFieldAutoSize.LEFT;
stage.addEventListener(Event.ENTER_FRAME, onFrame);
function onFrame(event:Event):void
{
addChild(body_txt);
yourName = name_txt.text;
}
//this loads the variable, then loads the song, and then plays it.
clickBtn.addEventListener(MouseEvent.CLICK, onClick);
function onClick(event:MouseEvent):void
{
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, varsLoaded);
// read.php contents: “&yorName=As&”
loader.load(new URLRequest(“read.php”));
function varsLoaded (event:Event):void {
trace(loader.data.yorName);
board_txt.text = loader.data.yorName;
var soundReq:URLRequest = new URLRequest(loader.data.yorName + ‘.mp3’);
var sound:Sound = new Sound();
var soundControl:SoundChannel = new SoundChannel();
sound.load(soundReq);
sound.addEventListener(Event.COMPLETE, onComplete);
function onComplete(event:Event):void
{
soundControl = sound.play();
}
stopBtn.addEventListener(MouseEvent.CLICK, stopSound);
function stopSound(event:MouseEvent):void
{
soundControl.stop();
}
}
}
Again this works on in the Flash test center and will even get and show the variable at my hosted account, but will not play it there. Again the song eveything is in the same directory and I have repeated test many times. btw both have php 5.2.2.