PDA

View Full Version : Flash Navigation to DIV



mattjp18
May 25th, 2008, 10:22 AM
Hi,

Is there any way to have a flash header in a website using navigatetoURL to load in different content into a DIV container on the site?

Thanks,

amarghosh
May 26th, 2008, 03:42 AM
if u know how to do it with javascript (embedded in html / written in AS code), i can tell u how to call that javascript method from Flash :)

ExternalInterface.call("method");

http://www.actionscript.org/forums/showthread.php3?t=171832

sparkdemon
May 26th, 2008, 04:49 AM
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style>
#demo
{
width:500pt;
height:400pt;
font-family:Arial, Helvetica, sans-serif;
font-size:medium;
background-image:url("images/bground3.gif");
background-repeat:repeat;
}
</style>
<script type="text/javascript">
function changeSettings(thiscolor, thisfont, thissize, thisbg){

var bg='images/'+thisbg+'.gif';
document.getElementById("demo").style.backgroundImage="url("+bg+")";
document.getElementById("text").style.color = thiscolor;
document.getElementById("text").style.fontSize=thissize;
switch (thisfont)
{
case 'Arial':

document.getElementById("demo").style.fontFamily = "Arial, Helvetica, sans-serif";
break;

case 'Verdana':

document.getElementById("demo").style.fontFamily = "Verdana, Arial, Helvetica, sans-serif";
break;

case 'Times New Roman':

document.getElementById("demo").style.fontFamily = '"Times New Roman", Times, serif';
break;

case 'Courier':

document.getElementById("demo").style.fontFamily = '"Courier New", Courier, monospace';
break;
}
}
</script>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
-----------------------------------------------------------------------------

the body contains another div called text:

<div id="text">
Your message will appear here.
</div>

this is a sample html code ... that changes color, background image, and font with dhtml with command from flash....


flash calls the changeSettings function as :

this.getURL("javascript:changeSettings('"+fntcolor+"','"+fntName+"','"+fntSize+"','"+bgimage+"')");

or you could also use externalInterface if you dont favour old flash players :)

amarghosh
May 26th, 2008, 05:02 AM
first of all getURL is not AS3 - its AS2 (and older may be)

so if u favor AS3 (which i think u do, since u posted in an AS3 forum) use ExternalInterface or navigateToURL;

and if u want any return value back from the js method (not that u need it in this particular case, but in general), i don't think navigateToURL can give u that
:)

mattjp18
May 26th, 2008, 09:44 AM
Thanks everyone, I wasn't aware of the externalInterface in as3, I think this is exactly what I need. I'll try it later today and let you know.