View Full Version : Flash header & footer want middle content to be HTML w/o using frames
somnamblst
November 20th, 2006, 06:23 PM
I have a mast head with Flash buttons, content below and then a Flash footer. I would love to change the middle content without reloading the page via the buttons and without using frames. Ideas?
Lemuel
November 20th, 2006, 07:36 PM
If you don't use frames, then the whole page has to chang/reload, no other way, thats why frames were made and used.
Sorry...
Digitalosophy
November 20th, 2006, 08:08 PM
I have a mast head with Flash buttons, content below and then a Flash footer. I would love to change the middle content without reloading the page via the buttons and without using frames. Ideas?
Since you have a Flash header and footer why not just make the content in Flash (since you want the page to reload).
somnamblst
November 20th, 2006, 10:30 PM
Since you have a Flash header and footer why not just make the content in Flash (since you want the page to reload).
I originally did but broke it apart into 2 flash files. I personally like frames because they keep a header front and center. I just always feel like they haven't been adequately crawled even though I use no frameset and meta tags. Same reason for not making the middle content which will be primarily text flash.
simplistik
November 20th, 2006, 11:57 PM
well you could export your content to xml and rss and then it can be made equally as indexable.
duncanhall
November 21st, 2006, 08:44 AM
If you don't use frames, then the whole page has to chang/reload, no other way, thats why frames were made and used.
Sorry...
This is nonsense! Have you been in a coma while 90% of the internet has been screaming about AJAX? Admittedly, creating full blown AJAX calls is probably unneccessary for this purpose, but it most certainly can be done, and without frames.
You'll want to do some reading on the javascript innerHTML object. Basically, when you click on one of the buttons in your flash files you'll want to call a javascript function which changes the innerHTML of your middle section.
Lemuel
November 21st, 2006, 09:59 AM
This is nonsense! Have you been in a coma while 90% of the internet has been screaming about AJAX?
Maybe not a coma, but I haven't been plugged into a variety of web technologies. Never heard of AJAX before.
I was just trying to help based on what I know.
Think i'll go modify my footer now.
duncanhall
November 21st, 2006, 10:32 AM
I'm not trying to piss on your fire, it just may have been better if you'd made it clear that what you were saying was only an educated guess rather than a defintive answer (which I guess is taken care of by your ammended signature). Worst case scenario is that somnamblst read your post, decided it was impossible and gave up on the internet for good, only to spend the rest of his days trying to program an abacus.
Also, now you have heard of AJAX, so you've learned something new. Go read about it.
Lemuel
November 21st, 2006, 10:46 AM
No problem duncanhall.
I just realized that while I know that I don't know everything I should, its hard for others, especially people newer to the business then I am, to know the same. Because after all, its hard to tell whos typing to you, despite whatever is entered into their "Profile"
As for AJAX
Looks interesting, handy, and yet another thing I have to learn.
Thanks for setting somnamblst straight for me.
-Lem
Surrogate
November 22nd, 2006, 02:08 PM
I have a mast head with Flash buttons, content below and then a Flash footer. I would love to change the middle content without reloading the page via the buttons and without using frames. Ideas?
Use AJAX - there's a tutorial here on Kirupa on the frontpage about it
(http://www.kirupa.com/developer/php/ajax_intro.htm)
I made an example for you, that does what you want.
This is the front page, i called it index.html. It contains the AJAX code that the tutorial i refered to has. However, it does not return the data it fetches in a dialog, but it writes it to a <div> tag on the page, with the help of innerHTML.
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript" type="text/javascript">
// You can put in some stuff to show while it loads the page... an animated .gif maybe?
var loadingmessage = "Loading page... Please wait";
var xmlHttp;
function createRequest(){
if(window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
else if(window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); }
}
function loadPage(pageurl){
// It puts the <div> in a variable here, so it can write to the tag.
var content = document.getElementById("content");
// Here the variable loadingmessage is put in, so it will be shown until the page is downloaded.
content.innerHTML = loadingmessage
createRequest();
var url = pageurl;
xmlHttp.open("GET", url, true);
// Here you tell it to run this function when it has fetched the content - pretty much like a flash listener
xmlHttp.onreadystatechange = pageLoaded;
xmlHttp.send(null);
}
function pageLoaded() {
var content = document.getElementById("content");
if(xmlHttp.readyState == 4) {
// Dont ask me about the readyStates, but this works (Read the tutorial i posted)
// The content is here written to the <div>, replacing the loadingmessage variable - voila!
content.innerHTML = xmlHttp.responseText;
}
}
</script>
</head>
<body>
<!-- This should obviously be your fancy flash menu instead -->
<input type="button" onClick="loadPage('test.html');" value="Click here to AJAX it up">
<div id="content"/>
</body>
</html>
This is the page that gets fetched. It shouldn't contain <html> tags, because it will be placed inside a <div> tag.
<h1>This is a page with some content</h1>
<p>Nothing to see here really...</p>
So what you do, is that you make Flash call a Javascript function on the page, that through AJAX loads the content into the current page. Voila, no page reloads.
To call a javascript function from flash, use this for your flash buttons:
somebutton.onRelease() = function() { getURL("javascript:loadPage('test.html);"); }
(I didn't test the flash code, but i think it should work)
I havent tried using this before. But it seems easy to do actually :)
Best of luck!
simplistik
November 22nd, 2006, 03:05 PM
http://dynamicdrive.com/dynamicindex17/indexb.html
somnamblst
November 22nd, 2006, 08:48 PM
Use AJAX - there's a tutorial here on Kirupa on the frontpage about it
(http://www.kirupa.com/developer/php/ajax_intro.htm)
I made an example for you, that does what you want.
To call a javascript function from flash, use this for your flash buttons:
somebutton.onRelease() = function() { getURL("javascript:loadPage('test.html);"); }
(I didn't test the flash code, but i think it should work) Best of luck!
Thanks, I have heard of Ajax.
Flash is saying there are errors
somebutton.onRelease() = function() { getURL("javascript:loadPage('home.html);"); }
Flash is saying there are errors
Left side of assignment operator must be variable or property.
somebutton.onRelease() = function()
duncanhall
November 23rd, 2006, 06:28 AM
Try this:
somebutton.onRelease = function() {
getURL("javascript:loadPage('test.html');");
}
somnamblst
November 23rd, 2006, 09:09 PM
Try this:
somebutton.onRelease = function() {
getURL("javascript:loadPage('test.html');");
}
Happy Thanksgiving everybody!
No errors in that code.
I added the code to the first button in the masthead, published and added the object code to the example above. It's not loading the content I have in the doc I called test.html
Here is what I have:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript" type="text/javascript">
// You can put in some stuff to show while it loads the page... an animated .gif maybe?
var loadingmessage = "Hello, Loading page... Please wait";
var xmlHttp;
function createRequest(){
if(window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
else if(window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); }
}
function loadPage(pageurl){
// It puts the <div> in a variable here, so it can write to the tag.
var content = document.getElementById("content");
// Here the variable loadingmessage is put in, so it will be shown until the page is downloaded.
content.innerHTML = loadingmessage
createRequest();
var url = pageurl;
xmlHttp.open("GET", url, true);
// Here you tell it to run this function when it has fetched the content - pretty much like a flash listener
xmlHttp.onreadystatechange = pageLoaded;
xmlHttp.send(null);
}
function pageLoaded() {
var content = document.getElementById("content");
if(xmlHttp.readyState == 4) {
// Dont ask me about the readyStates, but this works (Read the tutorial i posted)
// The content is here written to the <div>, replacing the loadingmessage variable - voila!
content.innerHTML = xmlHttp.responseText;
}
}
</script>
</head>
<body>
<!--url's used in the movie-->
<!--text used in the movie-->
<!-- saved from url=(0013)about:internet -->
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="600" height="208" id="restYourBackMasthead8" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="restYourBackMasthead8.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="restYourBackMasthead8.swf" quality="high" bgcolor="#ffffff" width="600" height="208" name="restYourBackMasthead8" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
<div id="content"/>
</body>
</html>
Surrogate
November 24th, 2006, 03:40 AM
I've googled abit, and i've found that there is another way to invoke javascript from within Flash.
It's called fscommand - oh and by the way, sorry that my flash code didnt work :s
After alot of testing etc., i made it work, and i will therefor give you the source code.
I followed the guide here;
http://www.moock.org/webdesign/flash/fscommand/
It explains the use of fscommand. Notice that you have to upload your page to a remote server, because of some security reasons neither Firefox or Internet Explorer wants to work locally. (Some security issue - it works in both browsers online though)
I used these commands in the flash:
button1.onRelease = function() {
fscommand("loadPage", "test1.html");
}
The embed code looks like this - notice that i've given the movie a name - it's very important to name it. Also give it the swLiveConnect true attribute.
<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" WIDTH="400" HEIGHT="30" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" ID="flashmenu">
<PARAM NAME="MOVIE" VALUE="menu.swf">
<PARAM NAME="PLAY" VALUE="false">
<PARAM NAME="LOOP" VALUE="false">
<PARAM NAME="QUALITY" VALUE="high">
<PARAM NAME="SCALE" VALUE="SHOWALL">
<EMBED NAME="flashmenu" SRC="menu.swf"WIDTH="400" HEIGHT="30" PLAY="false" LOOP="false" QUALITY="high" SCALE="SHOWALL" swLiveConnect="true" PLUGINSPAGE="http://www.macromedia.com/go/flashplayer">
</EMBED>
</OBJECT>Next i added the javascript to use these fscommands:
<SCRIPT LANGUAGE="JavaScript">
<!--
function flashmenu_DoFSCommand(command, args) {
if (command == "loadPage") {
loadPage(args);
}
}
//-->
</SCRIPT>
<SCRIPT LANGUAGE="VBScript">
<!--
// Catch the fscommand in ie with vbscript, and pass
// it on to JavaScript.
Sub flashmenu_FSCommand(ByVal command, ByVal args)
call flashmenu_DoFSCommand(command, args)
end sub
//-->
</SCRIPT>
When they catch a fscommand from flash, they call the JS function that loads pages.
I'm sorry that i cant show you the example on a link, but the only webserver i have access to is that of a client, and i can't post that :s
Look at the attachment. It should work :)
Hope you get it to work - it seems Flash/Javascript is more trickier than i though.
somnamblst
November 24th, 2006, 12:53 PM
Very cool. I have 1 question. My buttons are a bit more complicated as Flash buttons often are. The buttons' text descends one at a time so the button keyframes are all on different layers and different frames on the timeline. I could abandon this design but for the time being I would prefer to see if I can get it to work.
What my menu buttons look like as the published SWF without all the JS:
http://kids-voting.org/fla/menu2.html
Your version working (and on a server :) ):
http://kids-voting.org/fla/index.html
Your index file with object code simply modified to call my menu2.swf (height and width also changed) I can tell it is not getting to the descended state of the buttons as the sky is also not moving, so apparently stuck on frame1
http://kids-voting.org/fla/indexMenu2.html
The object code Flash generated for my menu2.swf:
<!--url's used in the movie-->
<a href="FSCommand:1"></a>
<a href="FSCommand:2"></a>
<!--text used in the movie-->
<!-- saved from url=(0013)about:internet -->
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="600" height="208" id="menu2" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="menu2.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="menu2.swf" quality="high" bgcolor="#ffffff" width="600" height="208" name="menu2" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
Surrogate
November 24th, 2006, 01:49 PM
Hehe. That's my bad mate :s
<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" WIDTH="600" HEIGHT="208" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" ID="flashmenu">
<PARAM NAME="MOVIE" VALUE="menu2.swf">
<PARAM NAME="LOOP" VALUE="false">
<PARAM NAME="QUALITY" VALUE="high">
<EMBED NAME="flashmenu" SRC="menu2.swf"WIDTH="600" HEIGHT="208" PLAY="false" LOOP="false" QUALITY="high" SCALE="SHOWALL" swLiveConnect="true" PLUGINSPAGE="http://www.macromedia.com/go/flashplayer">
</EMBED>
</OBJECT>Use the code above. You see, i messed up, because my example contained this:
<PARAM NAME="PLAY" VALUE="false">
So... :blush: its just me, not looking at what i copy/paste
Oh, and i just bought myself a webhotel today :P So in the future i can upload examples \o/
somnamblst
November 24th, 2006, 02:33 PM
Obviously I am still doing something wrong in the Flash file. Here is my FLA
http://kids-voting.org/fla/menu3.fla
The button text is descending but the content is not loading
http://kids-voting.org/fla/indexMenu2.html
Surrogate
November 25th, 2006, 07:31 AM
Yeah you did some wrong things in your .fla.
It works here now:
http://www.fedderdesign.dk/somnamblst/index.html (http://www.fedderdesign.com/somnamblst/index.html)
I'll just include the file. I've used actionscript on the buttons now, instead in the stage, as your method doesn't work with stage actionscript :)
There also was some issues with index.html... don't know what was wrong, but i made it work now.
Download the code here:
http://www.fedderdesign.dk/somnamblst/somnamblst.zip (http://www.fedderdesign.com/somnamblst/somnamblst.zip)
This should work, finally! :)
somnamblst
November 25th, 2006, 11:24 AM
It looks great! And it achieves the main thing I was trying to avoid which was using Flash to display lots of text. I have been using scrollpanes but some people don't think they are intuitive enough. I will have to play with presentation. Just out of curiosity how does this differ from AJAX?
Surrogate
November 25th, 2006, 12:18 PM
It looks great! And it achieves the main thing I was trying to avoid which was using Flash to display lots of text. I have been using scrollpanes but some people don't think they are intuitive enough. I will have to play with presentation. Just out of curiosity how does this differ from AJAX?
Well, it doesn't differ - it IS Ajax.
http://en.wikipedia.org/wiki/AJAX <- AJAX is just a technique, using XHTML, CSS, JS, XML and what not, to swap data.
Not that i'm an expert or anything, i'm just beginning to scratch the surface of the technique :)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.