Click to See Complete Forum and Search --> : Javascript shake AOL?


hack3rman
12-16-2003, 05:41 PM
I am having a problem with a function that I wrote within a Swish.swf file. The new swish can call javascript from within the flash file. Although I realize this is not a swish forum, I figured the Javascript is the key element and you guys know the most about that.

In the program, I have this command (which executes on from 65).

onFrame (65) {
javascript("function shake(n) { if (parent.moveBy) { for (i = 3; i > 0; i--) { for (j = n; j > 0; j--) { parent.moveBy(0,i); parent.moveBy(i,0); parent.moveBy(0,-i); parent.moveBy(-i,0); } } } } shake(2);");
}


It works perfectly, except in AOL. When broswing with AOL, the screen "restores down" and goes all the way down to the bottom. You can see the effects by browsing through AOL and going to one of the demos that uses this function. (ie. http://www.swishzone.com/movies.php?do=pag...led&link_id=504 )


Is there any way I can detect AOL in this function within the script window and if the browser is AOL, then not have it shake?

Or should I have 2 swf files. In my index.html page call intro-aol.swf if the user is browsing with AOL or intro.swf if anything else? And what would that code be?

Thanks in advance...
John

Kor
12-17-2003, 06:07 AM
Try this

var agt=navigator.userAgent.toLowerCase();
var is_aol = (agt.indexOf("aol") != -1);

The problem is that AOL 3 and AOL 4 are somehow IE compatible and no way (as far as I know) being able to be differentiate...

you may use furthermore

var is_aol3 = (major < 4);
var is_aol4 = ((major == 4) && (ua.indexOf("msie 4")!=-1));
var is_aol5 = (ua.indexOf("aol 5") != -1);
var is_aol6 = (ua.indexOf("aol 6") != -1);

hack3rman
12-17-2003, 06:18 AM
Where would I put that code you suggested?

Kor
12-18-2003, 03:15 AM
well... if you wanna build 2 swf files, use an if statement on a browser detector

<html>
<head>
<script>
function switchSwf(){
var agt=navigator.userAgent.toLowerCase();
this.isaol = (agt.indexOf("aol") != -1);
var aol = new Aol();
var aols = 'swfaol';
var nonaols = 'swfnonaol';
if (aol.isaol) {
document.getElementById('aolid').innerHTML = '<all_the_HTML_and_Flash_parameter_till_the_swffile'+swfaol+'.swf"><rest_of_tags>';
else{
document.getElementById('aolid').innerHTML = '<all_the_HTML_and_Flash_parameter_till_the_swffile'+swfnonaol+'.swf"><rest_of_tags>';
}
}
</script>
</head>
<body onload="switchSwf()">
<div id="aolid"></div>
</body>
</html>

...presumed that your 2 swf file are named swfaol.swf and swfnonaol.swf

hack3rman
12-18-2003, 06:48 AM
Ok, Wow, thanks for your help so far. I think we're almost there. Im just a little unclear where to put some of the swf code that calls the flash file. Here's the code ... where would this go? In the function or in the body.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,42,0"
id="swfaol" width="100%" height="95%">
<param name="movie" value="swfaol.swf" />
<param name="menu" value="false" />
<param name="quality" value="high" />
<param name="bgcolor" value="#FFFFFF" />
<param name="allowScriptAccess" value="sameDomain" />
<script type="text/javascript" language="JavaScript">
<!--
if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) {
document.writeln(' <embed name="swfaol" src="swfaol.swf"');
document.writeln(' menu="false" quality="high" bgcolor="#FFFFFF" swLiveConnect="true" allowScriptAccess="sameDomain"');
document.writeln(' width="100%" height="95%"');
document.writeln(' type="application/x-shockwave-flash"');
document.writeln(' pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>');
} else {
document.writeln('No flash player plugin installed');
}
//-->
</script>
No FLash Player Installed
<noscript>
</noscript>
</object>

Kor
12-19-2003, 02:48 AM
It is not so good what you already have... First at all you must know that the Flkash in inserted once with OBJECT tag (for IE) and than with EMBEDED tag (for NS), so I don't see what is the use of your javascript used there? Will alert the user if he has no Flash plug-in? There is no nedd, as the attribute pluginspage will do this job... And, after all, only those with NS will be alerted, not those with IE

I should use this:


<html>
<head>
<script>
function switchSwf(){
var agt=navigator.userAgent.toLowerCase();
this.isaol = (agt.indexOf("aol") != -1);
var aol = new switchSwf();
var aols = 'swfaol';
var nonaols = 'swfnonaol';
if (aol.isaol) {
document.getElementById('aolid').innerHTML = '<param name="movie" value="'+aols+'.swf" />';
document.getElementById('aolid2').innerHTML = '<embed name="swfaol" src="'+aols+'.swf" menu="false" quality="high" bgcolor="#FFFFFF" swLiveConnect="true" allowScriptAccess="sameDomain" width="100%" height="95%" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';}
else{
document.getElementById('aolid').innerHTML = '<param name="movie" value="'+nonaols+'.swf" />';
document.getElementById('aolid2').innerHTML = '<embed name="swfaol" src="'+nonaols+'.swf" menu="false" quality="high" bgcolor="#FFFFFF" swLiveConnect="true" allowScriptAccess="sameDomain" width="100%" height="95%" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
}
}
</script>
</head>
<body onload="switchSwf()">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,42,0" id="swfaol" width="100%" height="95%">
<div id="aolid"></div>
<param name="menu" value="false" />
<param name="quality" value="high" />
<param name="bgcolor" value="#FFFFFF" />
<param name="allowScriptAccess" value="sameDomain" />
<div id="aolid2"></div>
</object>
</body>
</html>