Groups | Blog | Home
all groups > flash (macromedia) > august 2004 >

flash (macromedia) : Re: Open SWF file in a new window?


Polonius
8/4/2004 10:47:22 PM
Thank you to bloodforge and Pete Hughs. That worked. But how do I get the new
window to be the same size as the swf file? Now, when the new window opens, the
swf file (which is only 230x230 pixels) is floating in the middle of a large
window. I'd like it to be a tight little window just big enough for the new
page. Thanks in advance.
TomEnokR
8/4/2004 11:06:35 PM
I use javascript.

On your web page where you have your flash file embedded, use the following
code in your header:

<script language="JavaScript">
self.name = 'mainFrame';
function winBRopen(theURL, Name, popW, popH, scrOpt) { // V 1.0
var winleft = (screen.width - popW) / 2;
var winUp = (screen.height - popH) / 2;
winProp = 'width='+popW+',height='+popH+',left='+winleft+',top='+winUp+',
scrollbars='+scrOpt+', resizable'
Win = window.open(theURL, Name, winProp)
if (parseInt(navigator.appVersion) >= 4) { Win.window.focus(); }
}

function loadSWF(URLtoOpen, windowName) {
wid = 230;
hei = 230;
scrOpt = 'No';
winBRopen(URLtoOpen, windowName, wid, hei, scrOpt);
}
</script>

Description:
the wid = is where you define your window width
the hei = is where you define window height
scrOpt = is where you determine if scrolling is turned on or off.
function = loadSWF is where you define the name of the function to call in
your swf to load it....

that's step 1.

Step two is to call the function in your flash file. In this example, the
loadSWF function is called through the onRelease of a button:

on (release) {
getURL ("javascript:loadSWF('name.html', 'Swf File');");
}

Description:
javascript:loadSWF is where you are calling the javascript function
name.html is the name of the NEW window you want to pop up (you have to create
this window in advance, of course)
SWF File is the name of the window. It will appear in the header of the
browser that pops up.

Hope this helps!

-Shaun
clint317
8/5/2004 4:26:02 AM
Here is the correct way to use javascript in Flash to open a new resizable
widow:


getURL("javascript:void(window.open('/path/page.html?variables=values','some_nam
e','height=500, width=500, location=no, menubar=no, status=no, toolbar=no,
scrollbars=no, resizable=no'));");

Passing variables is optional.
urami_
8/5/2004 11:38:20 AM


[quoted text, click to view]

first let me point out that is not recommended to open SWF directly w/o HTML.
If uses had no plugin , he/she will end up with window fill up with bunch of characters
or will be prompt the DOWNLOAD / SAVE AS dialog. Also the window will not have
title , in title bar you will have full path to your SWF on server.
You can't open SWF outside the browser , the only way is in new window.
Best is to place it in html , make sure you reduce the margins to zero so there is now white spaces
around the file. Than call the HTML from flash.
TomEnokR's code sample is fine , but a bit over coded for such basic function in javascript like
new window. Here you have sample , just this flash action w/o any html body code :

on (release) {
getURL("javascript:n_name=window.open('file.htm','new_name','width=230,height=230');void(0);");
}


--


Regards


urami_*

<hol>
http://flashfugitive.com/
</hol>


By The way:
If you try to mail me , DO NOT *laugh*
AddThis Social Bookmark Button