Click to See Complete Forum and Search --> : Javascript "Popups" for flash


foxache
11-13-2003, 10:06 AM
Hey guys. Maybe kinda easy this one (for some)

I have created some windows that popup when you click on a button in flash. Everything works fine except when you click on another one, it goes in the same window as the previous and stays the same size (oh by the way each "popup" is a different size) and here is the script I am using:


on (release) {
getURL("javascript:var mypopup = window.open('/esc','mySite','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width= 562,height=237,top='+eval((screen.availHeight - 237) / 3)+',left='+eval((screen.availWidth - 500) / 2));mypopup.focus();");
}

how would I launch the windows as entirely new ones. Ie as a "_blank" window?

Thanks

migwich
11-13-2003, 12:06 PM
To launch a new window, simply replace 'mySite' with a dynamic value. This is the NAME of the new window, if each instance has the same name, it'll call the same window. To alter the size, you'll want to pass variables as the width & height.

Timeline Code:
function newWin($X,$W,$H){
getURL("javascript:var mypopup = window.open('/ esc','"+$X+"','toolbar=0,location=0,directories=0,
status=0,menubar=0,scrollbars=0,resizable=0,width=
"+$W+",height="+$H+",top='+eval((screen.availHeight - 237) / 3)+',left='+eval((screen.availWidth - 500) / 2));mypopup.focus();");
}

Button1 Code:
on (release) {
newWin('someName',562,237);
}

Button2 Code:
on (release) {
newWin('anotherName',300,400);
}

foxache
11-14-2003, 03:30 AM
Thanks a lot. Though i think i've misunderstood something there. I pasted the code into the timeline and the other into the button, but it didn't work. Nothing happened when I clicked on the button. :-(

migwich
11-14-2003, 07:57 AM
Whooops! Sorry about that. :) (blush)
Try the attached file. It is Flash 5.

The Timeline code must occur in the same frame as the buttons. In addition to that, I corrected the code.
Make sure that there are no linebreaks in the getURL line and the newWin lines.

// TimeLine:
function newWin($URL,$X,$W,$H){
getURL("javascript:var mypopup = window.open('"+$URL+"','"+$X+"','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width="+$W+",height="+$H+",top='+eval((screen.availHeight - 237) / 3)+',left='+eval((screen.availWidth - 500) / 2));mypopup.focus();");
}

// Button:
on (release) {
newWin('http://www.yahoo.com','someName',562,237);
}

foxache
11-14-2003, 11:14 AM
Cheers, works a treat. A simple yet annoying problem - solved! Thanks a lot.