Groups | Blog | Home
all groups > flash actionscript > august 2005 >

flash actionscript : JS to open SWF in seperate window?


withhisstripes
8/19/2005 8:48:30 PM
Heya,
I can't figure out how to get my .swf website to open in a seperate
window when users click on the "enter" button in my html file. Does anyone know
how to get it to do that? JS maybe?

-Spence
d tizzle
8/19/2005 9:46:59 PM
:cool;

DT

// in your text
<a href='asfunction:openWindow'>open macromedia in a new window</b></a>

// frame one of your movie (assuming that your text is in the same timeline)

function openWindow(){

getURL("javascript:popUp('http://www.macromedia.com',"+"
'request','toolbar=yes, location=no, "+" directories=no, status=no, menubar=no,
"+" scroolbar=yes, resizeable=no, height=575, "+" width=610, top=20,
left=380')");
}

in the <HEAD> of your HTML page
<SCRIPT LANGUAGE="JavaScript">
<!--
function popUp(url, windowName, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops =
'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resiz
able';
win = window.open(url, windowName, winprops);
if (parseInt(navigator.appVersion) >= 4) {
win.window.focus();
}
}
// -->
</SCRIPT>
withhisstripes
8/19/2005 10:20:16 PM
Thanks, but I still need some help:
- "frame one of your movie (assuming that your text is in the same timeline)"
what are you referring to when you say text?
- When I preview it Firefox says that the asfunction is not a registered
protocal, whahuh?
d tizzle
8/19/2005 10:28:46 PM
send me a provat message with your email address and ill send a fully functioning fla, swf, html version

d tizzle
8/20/2005 1:02:54 AM
Originally posted by: withhisstripes
Thanks, but I still need some help:
- "frame one of your movie (assuming that your text is in the same timeline)"
what are you referring to when you say text?

place a textbox instance on the stage give it a name, say "myTextbox"
in the actions window place this code: myTextbox.htmlText="<a
href='asfunction:openWindow'>open macromedia in a new window</a>"


- When I preview it Firefox says that the asfunction is not a registered
protocal, whahuh?
you will have to view the html page that your swf is embeded into in order for
the javascript to function properly

its my guess that you are viewing the swf directly insteadof it being in a
html page with the "popUp" script in its <head> tag)
if you dont view the html page your openWindow() function in flash never
reaches the javascript thus causing your browser error

BTW: i tested it in firefox and it works fine


AddThis Social Bookmark Button