...

View Full Version : Please check my code for pop ups in flash!



noob
04-16-2009, 05:02 PM
Hi,

I couldn't find a thread with my exact problem..basically I have this button in flash to popup a window:

on (release) {
//customize the window that gets opened
// 0 equals NO.
// 1 equals YES.
address = "/RG_Map.pdf", "_blank";
target_winName = "R G Community Map";
width = 700;
height = 700;
toolbar = 0;
location = 0;
directories = 0;
status = 0;
menubar = 0;
scrollbars = 0;
resizable = 0;
//sends data back to the function
openWinCentre(address, target_winName, width, height, toolbar, location, directories, status, menubar, scrollbars, resizable);
}

It works fine in Firefox, Safari and Chrome, but I cannot open it in IE7. Has anyone found a solution? The window simply won't popup. This has occured on many machines, so I don't think it's a blocker.

Thanks so much!

gnomeontherun
04-19-2009, 08:40 PM
Do you have the code for the openWinCentre function?

noob
04-20-2009, 01:52 PM
Thanks for your response.

Surprisingly (or stupidly) I don't have the code for openwincentre -it was a copy and paste from some button tutorial. I did a quick search on it and read that openwincentre must be on the _root first frame.

How would I input the _root code? (My popup windows are different sizes) or
Is the openwincentre necessary?

Thanks.

gnomeontherun
04-20-2009, 03:05 PM
Do you have a link to this tutorial? I can't really help with this specific code without knowing more.

noob
04-20-2009, 08:12 PM
I used the tutorial found here:

http://www.kirupa.com/developer/mx/centered_popup.htm

Thanks!

gnomeontherun
04-20-2009, 09:34 PM
Ok yes that function is necessary, and you should place it on the first frame in the main timeline.

Its a bit complex, you could also just have


on (release) {
getURL ("javascript:NewWindow=window.open('ShowPopup.php','newWin','width=400,height=300,left=0,top=0,
toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No'); NewWindow.focus();
void(0);");
}

http://www.flash-db.com/PopUp/JavaScriptPopUp.php?page=2

noob
04-20-2009, 10:37 PM
Ok, I inputted that code into the first frame in the main timeline and it still doesn't work. This is what I put in:


_root.openWinCentre = function (url, winName, w, h, toolbar, location, directories, status, menubar, scrollbars, resizable) {

getURL ("javascript:var myWin; if(!myWin || myWin.closed){myWin = window.open('" + url + "','" + winName + "','" + "width=" + w + ",height=" + h + ",toolbar=" + toolbar + ",location=" + location + ",directories=" + directories + ",status=" + status + ",menubar=" + menubar + ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",top='+((screen.height/2)-(" + h/2 + "))+',left='+((screen.width/2)-(" + w/2 + "))+'" + "')}else{myWin.focus();};void(0);");

}



I then tried your second recommendation and the Flash compiler identified a few errors that I couldn't fix.

What do you recommend?

gnomeontherun
04-21-2009, 11:30 AM
Well the fact that it worked the first time around in all but IE, really does suggest that its a popup blocker. I just tested the file on the tutorial site and it blocked it on my IE. Are you 100% sure its not a blocker?

noob
04-21-2009, 01:27 PM
I'm certain it's not. I downloaded the tutorial files into my domain and it worked. I then copied the exact code from the tutorial and pasted it into my flash file and it didn't work. The only thing I can think of is that that button is not on the main layer, as the tutorial button is?

gnomeontherun
04-21-2009, 02:06 PM
So we are still at square 1? It works in all but IE, can you load it onto a site so I can test it with my IE?

noob
04-21-2009, 02:17 PM
My site is:

www.rossdalegreen.ca

I could send you the flash file as well.

Thanks!

gnomeontherun
04-21-2009, 04:26 PM
I'm getting JS errors. Honestly that function is a bit...much so lets cut it down. Also the winName probably should be one word.



on (release) {
//customize the window that gets opened
// 0 equals NO.
// 1 equals YES.
address = "/RG_Map.pdf", "_blank";
target_winName = "RGCommunityMap";
width = 700;
height = 700;

//sends data back to the function
openWinCentre(address, target_winName, width, height);
}



_root.openWinCentre = function (url, winName, w, h) {

getURL ("javascript:window.open('" + url + "','" + winName + "','" + "width=" + w + ",height=" + h + ");");

}

noob
04-21-2009, 05:08 PM
So, I tried your code and it still doesn't work.. I used the first part of the code for the button and the second part for the main frame. The only difference now is the newly coded button does not display a "Error on page." notice like the other buttons do.

I appreciate the help, Jeremy.

gnomeontherun
04-22-2009, 08:36 AM
Well thats progress. The button is working, something with the javascript is not. Honestly its not my strength, perhaps you should ask there. Either way, you can test Javascript directly by putting it into the address bar. I am also guessing its possible one of our parameters is off?


address = "/RG_Map.pdf";


If you don't care to have a function for this, then just try this.


on (release) {
getURL ("javascript:window.open('/RG_Map.pdf','RGCommunityMap','width=700,height=700');");
}



Here is a reference for the window.open method

http://www.pageresource.com/jscript/jwinopen.htm

noob
04-22-2009, 02:58 PM
It worked! It created another problem, though: the window pops up fine, but the main window goes white and displays this:

[object]

So close!

gnomeontherun
04-22-2009, 07:13 PM
Put the full URL in there


on (release) {
getURL ("javascript:window.open('http://www.rossdalegreen.ca/RG_Map.pdf','RGCommunityMap','width=700,height=700');");
}

noob
04-22-2009, 08:21 PM
Your previous comment made the pop up window work (your last response also works). I should clarify that it is the parent window (not the pop up window) is displaying the [object] comment.:confused:

gnomeontherun
04-22-2009, 09:36 PM
Best to ask in the Javascript forum about that line of javascript.

noob
04-22-2009, 10:53 PM
Thanks for your patience and help on this problem, Jeremy. I've gone to the Javascript boards to see if they can resolve this.

If you're ever in NY (until May 27), I owe you some beer.

gnomeontherun
04-22-2009, 11:38 PM
Haha, thanks but I'll be in Germany and unable to share one, at least not in person :) You going somewhere after May 27th? If you hit Europe I'll get you a half-liter of Deutschlands finest just for making the trip.

Please keep posting as you have other questions or if you can help others, its great to have new people around the forums!

noob
04-23-2009, 01:09 AM
Coincidentally, yes, I will be in Europe:

Vegas May 28-31, Spain and France in June, Italy and western Europe in July.

Think of it as a recession induced excursion..



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum