Best example I can give right now is part of a current project.
The end result of this project is to provide an online storage & interface to stash/manage everything from ringtones to Java applications for mobile phones, the example comes from the PC side of the project.
While I can cover every aspect of management from a single Flash interface I ran into the problem of keeping client session state without wasting bandwidth to resend all of the details of a users filespace. (queried & loaded via XML on initial load of the movie) when uploading new files.
I could use a new window to get the same results this gives but creating an iframe dynamically with the src set to my upload form makes for a friendlier interface.
The CSS,
body{background:URL("imgs/lineBG.gif"); margin:0px;}
div#upload{position:absolute; top:60px; left:50%; width:340px; height:490px; visibility:hidden;}
td#left{background:URL("imgs/lineEdgeL.gif"); height:100%; width:20px;}
td#right{background:URL("imgs/lineEdgeR.gif"); height:100%; width:20px;}
- body{background:URL("imgs/lineBG.gif"); margin:0px;}
- div#upload{position:absolute; top:60px; left:50%; width:340px; height:490px; visibility:hidden;}
- td#left{background:URL("imgs/lineEdgeL.gif"); height:100%; width:20px;}
- td#right{background:URL("imgs/lineEdgeR.gif"); height:100%; width:20px;}
The Javascript, (Flashs IE VBscript hook excluded)
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the the FSCommand messages in a Flash movie
function default_DoFSCommand(command, args) {
var defaultObj = document.getElementById("default");
if(command == "showUpload"){
//var myArgs = args.split("|");
document.getElementById("upload").innerHTML = "<iframe id='uploadFrame' frameborder='0' style='width:100%; height:100%;' src='uploadForm.cfm?sid="+args+"'></iframe>";
document.getElementById("upload").style.visibility = "visible";
}else if(command == "hideUpload"){
document.getElementById("upload").innerHTML = "";
document.getElementById("upload").style.visibility = "hidden";
}
- var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
- // Handle all the the FSCommand messages in a Flash movie
- function default_DoFSCommand(command, args) {
- var defaultObj = document.getElementById("default");
- if(command == "showUpload"){
- //var myArgs = args.split("|");
- document.getElementById("upload").innerHTML = "<iframe id='uploadFrame' frameborder='0' style='width:100%; height:100%;' src='uploadForm.cfm?sid="+args+"'></iframe>";
- document.getElementById("upload").style.visibility = "visible";
- }else if(command == "hideUpload"){
- document.getElementById("upload").innerHTML = "";
- document.getElementById("upload").style.visibility = "hidden";
- }
The HTML,
<div align="center">
<table cellspacing="0" cellpadding="0"><tr>
<td id="left"></td>
<td id="flash">
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ID="default" WIDTH="700" HEIGHT="600" ALIGN="">
<PARAM NAME=movie VALUE="default.swf">
<PARAM NAME=menu VALUE=false>
<PARAM NAME=quality VALUE=best>
<PARAM NAME=wmode VALUE=opaque>
<PARAM NAME=devicefont VALUE=true>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src="default.swf" menu=false quality=best wmode=opaque devicefont=true bgcolor=#FFFFFF WIDTH="700" HEIGHT="600" swLiveConnect=true ID="default" NAME="default" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
</OBJECT>
</td>
<td id="right"></td>
</tr></table>
</div>
<div id="upload"></div>
- <div align="center">
- <table cellspacing="0" cellpadding="0"><tr>
- <td id="left"></td>
- <td id="flash">
- <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ID="default" WIDTH="700" HEIGHT="600" ALIGN="">
- <PARAM NAME=movie VALUE="default.swf">
- <PARAM NAME=menu VALUE=false>
- <PARAM NAME=quality VALUE=best>
- <PARAM NAME=wmode VALUE=opaque>
- <PARAM NAME=devicefont VALUE=true>
- <PARAM NAME=bgcolor VALUE=#FFFFFF>
- <EMBED src="default.swf" menu=false quality=best wmode=opaque devicefont=true bgcolor=#FFFFFF WIDTH="700" HEIGHT="600" swLiveConnect=true ID="default" NAME="default" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
- </OBJECT>
- </td>
- <td id="right"></td>
- </tr></table>
- </div>
- <div id="upload"></div>
Notice the "opaque" state of the swf & the emptiness of the div tag that will contain the iframe ?
My iframe has no border, it will hover above the centered swf positioned absolute at top:60px; left:50%; which will allow me to blend it in with the flash interface rather than open a new window.
If flash "fscommand" will be used from buttons to trigger javascript that writes the iframe to the page, when the iframes form is submitted the server saves the files, adds them to the database but instead of having flash reload the entire updated details later, the form submit also writes theese new details to a temporary area of that persons database entry & sends back the upload form with confirmation details on it this time.
When the user is done uploading files they press a gallery button which will trigger flash to load only the new details set aside in the database earlier (then delete them from the db) & append them to the existing details in Flash.
In this particular project watching filesize & other such restrictions between uploads wasn't needed, it's not like you need anything more than the confirmation page between uploads anyway..
Now if only everyone had Flash enabled phones, my life would be sooo much easier
(no I can't show a link to this yet.)
Strong with this one, the sudo is.