As this is my first post here, I’d like to say hi to everyone!
As for my problem… here’s the deal. I need a solution for the following:
Given a SWF in a webpage, i need to be able to change the SWF when clicking a link or a php function/query. I think this translates to ‘change the SWF by a php GET method’.
If I have a link such as ‘…/index.php?=apartment’, the flash file should change from the current to the ‘…apartment.swf’.
I’m sorry I’m not very familiar to data integration/communication methods, and maybe it needs an xml, maybe Java, AJAX… And I would appreciate it if you could give me working actionscripts for the .fla or a working example. Please help, as I haven’t been able to find anything suitable on the web, and have searched for different strings.
I think you are going about it wrong. Why not in PHP do something like:
<?php
switch($_GET['action']) {
case "apartment":
//show apartment stuff inc the code to displace the apartment swf in html
break;
case "house":
//show house stuff inc the code to display the home swf in html
break;
case "mansion":
//show mansion stuff inc the code to display the mansion swf in html
break;
default:
//nothing shows if $_GET['action'] matches none of those.
}
?>
Ok, but what kind of ‘action’ ? Give me an example please!
And I was thinking more like sending variables to flash. I know it should be possible, and I think they should be sent via GET method in php… Rather than having lots of of swfs, I’d prefer just one and with the given variables, to jump to another frame within it.
OH well, you said load different SWFs. With that said, you assume you have more than one. If it is just one movie and you jsut want it to land on a different frame, you would use the load method. Also,
…/index.php?=apartment
isnt a valid link. Thats like saying undefined=apartment. You need to set something equal to apartment which is why I used ‘action’. It can really be anything you want. The only way I can think of doing this would be using like SWF object + PHP:
<script type="text/javascript">
var so = new SWFObject("yourfile.swf", "yourfile", "590", "300", "9", "#000000");
so.addVariable("whatToLoad", "<?php echo $_GET['action']; ?>");
so.write("flashcontent");
</script>
And then in your flash movie, _root.whatToLoad, will be whatever is in your urlbar. So if it was action=apartments, it would say apartments in flash. Then you just do a switch case in flash:
switch (_root.whatToLoad)
{
case "apartments" :
//load apartment frame
break;
case "houses" :
//load houses frame
break;
case "mansion" :
//load mansion frame
break;
default :
trace("couldnt load variable");
}