Ultrashock Forums > Flash > ActionScript
AS - Popups From Flash - Solution

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes
<|1|2| Page 2 of 2
Sundev Sundev is offline Sundev lives in United States 2008-06-27 #41 Old  
Getting Safari to work with Popups
It's pretty dirty, but not as dirty as I remember. I did have to change Nutrox's popup.js file. And this javascript no longer returns whether it was successful or not; I should probably fix this. But I have attached the zip file. For an explanation, see my previous post and let me know if you have any questions. I found the browser detection script online. The credits are in the file.

PopUpEx.zip
Reply With Quote  
johnbarrett johnbarrett is offline johnbarrett lives in United States 2008-07-25 #42 Old  
Hi, Can I ask what is the deal with safrai and opening a new window, popup or anything? I am a newbie at flash, but I can't seem to get anything to work in safrai. I tried both the zip examples here, both work with Camino(1.6) and FireFox(3.1) but no love on Safrai(3.12) I am on mac.

Could anybody offer and coding help to resolve this issue for be. I am currently using AS 2 as I am about to get flash CS 3 in about a month.
Reply With Quote  
Sundev Sundev is offline Sundev lives in United States 2008-07-25 #43 Old  
My and Nutrox's examples are both done in as3. If your decent at programming, you could probably go through the code and modify it for as2. But my hack is a big hack for safari and not as cleanly written as nutrox's, but good luck.
Reply With Quote  
avnik avnik is offline avnik lives in India 2008-09-16 #44 Old  
Last edited by avnik : 2008-09-16 at 02:27.
I tried Nutrox's popup blocker bypass through flash but it only works in Firefox it still is not able to bypass the IE7 popup blocker. Even in the demo its not working. Also is there any way this could be done in flash 8 instead of flash CS3. I searched all over the internet for opening a browser window through flash and not getting blocked by the popup blocker on IE7 but my every attempt failed. The solution by Nutrox seemed to be most promising but its still not working for me. Am i doing something wrong. Or do the securities for IE7 popup blocker makes any difference. Can someone help? Thanks in advance.
Reply With Quote  
RM100 RM100 is offline RM100 lives in United States 2008-10-29 #45 Old  
Hi Nutrox,

I need some help with one of the three buttons on the form to auto fire (autoclick) when the page is loaded. I tried to do it with method onLoad() { sampleButtonB.Click(); } but i got some errors. So basically when your page with the three buttons shows up, i want immediately the Google page popup to show up as well.

Thanks in advance.
Reply With Quote  
Nutrox's Avatar Nutrox Nutrox is offline Super Moderator Nutrox lives in United Kingdom 17 Creative Assets 2008-10-29 #46 Old  
You should not (and in most situations cannot) open windows with "auto-clicks" any more, it is an intrusive and impolite thing to do. Modern browsers are designed to only open new windows during "real" user interaction.
Reply With Quote  
RM100 RM100 is offline RM100 lives in United States 2008-10-30 #47 Old  
Thanks Nutrox.
Reply With Quote  
Itzamna Itzamna is offline Itzamna lives in United Kingdom 2008-12-14 #48 Old  
Hi is there a way of getting this working in flash mx 6 i cant even open your flash file from the zip downloaded. I am using geturl in my flash code.
Reply With Quote  
Sundev Sundev is offline Sundev lives in United States 2008-12-14 #49 Old  
talk about legacy code. why do you need it for flash 6? are you adding to an old project? the short answer is no there is no easy way to get this to work in mx. you'll have to go through the code and determine what will work or what is equivalent in mx
Reply With Quote  
Itzamna Itzamna is offline Itzamna lives in United Kingdom 2008-12-14 #50 Old  
reason 1 - i have flash mx and have been using it for years not for anything complicated just to make images move and a a bit on navigation.

reason 2 - i know very little of the scripting in flash. Have been using html, php, mysql for a couple of years and not had time to expand my flash coding, so converting yours to make mine work would be hard.

reason 3 - i dont have a newer version of flash.

reason 4 - you might just have known the way to get it working saving me money and time.

So will have to get a newer version of flash. thanks.
Reply With Quote  
calpolyarc calpolyarc is offline calpolyarc lives in United States 2008-12-22 #51 Old  
Thanks Nutrox for shedding some light on this subject. I've had a heck of a time finding any info on it.

Is there a way I can open up one of these popup windows and also send variables to it? I'm currently using:
Code:
checkout_button.onRelease = function (): Void {
LoadVars.send = ("https://www.paypal.com/cgi-bin/webscr", "_blank", "POST");
}
to send a customer to paypal after populating a shopping cart. Using this code I get popup blocked by IE and Firefox. I've tried a few of the simple fixes that people have suggested like changing "_blank" to a named window... and changing the wmode of the index.html to opaque. I've also tried using an onMouseEvent to try and open the new window... no luck.

So my question is if it's possible to send variables to the new window using your popup method?

Also, when testing your sample, it worked great when the popup blocker was 'on', but once I chose 'allow popups from this site' it would open 2 Google windows which I suppose is 'ok' but of course not 'ideal'.

One last interesting note, when firefox blocks the popup and you choose 'allow popups from this site' the popup message goes away and you can click on the 'checkout' button again and everything is gravy. However with IE when you choose 'allow popups from this site' the site gets reloaded! Which clears the shopping cart... this is VERY troublesome!

Again, thanks for the time you've put into this.
Reply With Quote  
udaybiz udaybiz is offline udaybiz lives in India 2008-12-23 #52 Old  
Thanks Nutrox! It's working.
Reply With Quote  
Nutrox's Avatar Nutrox Nutrox is offline Super Moderator Nutrox lives in United Kingdom 17 Creative Assets 2008-12-23 #53 Old  
@udaybiz
No problem.

@calpolyarc
You could send variables but they would have to be sent as a query string, so we're talking GET not POST.
Reply With Quote  
ddivine ddivine is offline ddivine lives in United States 2009-02-19 #54 Old  
Need a solution for AS2
Quote: Originally Posted by Nutrox View Post
Sorry mate, there is no AS2 version of the PopupWindow class so you will need to convert it to AS2 yourself or find someone else to do it for you. Apart from posting the odd bit of AS2 code around the forum now and again I don't do AS2 development any more.

I know you guys have closed the case once u got it working for As3, but you can't let that old car sit there and rot in your garage, can't ignore the fact that so many huge apps were written in AS2, and people are trying to modify projects in AS2 since they can't rewrite the whole app for AS3, since they are already integrated into the works. If you really got the brains to beat this beast, AS2 solution be your last challenge.

So it's like this, if the old cars are not popular and are rotting in your words, why are so many people still riding Hot Rods and Classics. They ain't got automatic window open and close buttons
Reply With Quote  
Sundev Sundev is offline Sundev lives in United States 2009-02-19 #55 Old  
Well old cars don't have some of the newfangled contraptions like power windows and locks. You could rig up some little motor that runs on a 9 volt and rolls the window down, but that would just look silly. I'm not exactly sure where I was going with this, but in all honesty, I haven't worked in AS2 in about a year and a half and don't look forward to ever going back. I think I've forgotten everything anyway.
Reply With Quote  
ddivine ddivine is offline ddivine lives in United States 2009-02-19 #56 Old  
I hear ya! Honestly, i wouldn't even work in AS2 myself, since I think that AS3 is way cooler and I have been working with it very successfully, but I just got this project for work written in AS2, and pop-up blocker is killing me. Safari sucks big time! I search and search and no one seem to have any answers. Thanks anyways.
Reply With Quote  
Nutrox's Avatar Nutrox Nutrox is offline Super Moderator Nutrox lives in United Kingdom 17 Creative Assets 2009-02-19 #57 Old  
If I remember, and if I don't get sidetracked by personal projects - or by World of Goo - then I will try and tackle an AS2 version for you guys this weekend.

Reply With Quote  
ddivine ddivine is offline ddivine lives in United States 2009-02-19 #58 Old  
Yay! Thanks Nutrox you will rule the the World of Action Scripting! Cause honestly this thread offers the only real solution to the pop-up problem and I have been searching the whole day!
Reply With Quote  
rosaysh rosaysh is offline rosaysh lives in United States 2009-04-09 #59 Old  
Quote: Originally Posted by psyked View Post
grok - the problem you're likely to be having is more due to the Flash security sandbox than a problem with this method - I daresay that if you made an interface to communicate between loaded SWF files and the parent SWF, and then had the parent SWF launch the window - it would work. Externally loaded movieclips are quite limited in what they can do, so they can't compromise the original Flash file... (or something like that)
Hello - I am new to this forum (stumbled through google search here) and flash.
I am having the exact same problem as grok mentions above. Is there a way to allow
externally loaded swf launch a popup window? Basically, grant full trust to the external swf.
Reply With Quote  
ericscott's Avatar ericscott ericscott is offline ericscott lives in New Zealand 2009-04-26 #60 Old  
I am using the following script, which i modified after reading this thread.

Code:
function openWindow(ur:String, wh:Number, he:Number, sc:Number, re:Number):void {
	
	function openWin1(address, winName, hWindow, wWindow, toolbar, menubar, scrol, resiz, location, directories, status)
	{
		if (ExternalInterface.available)
		{
			ExternalInterface.call("window.open", address,  winName, 'height=' + hWindow + ', width=' + wWindow +', toolbar=' + toolbar + ', menubar=' + menubar + ', scrollbars=' + scrol + ', resizable=' + resiz + ', location=' + location + ', directories=' + directories + ', status=' + status + ', top=(screen.height/2)+('+hWindow/2+'), left=(screen.width/2)+('+wWindow/2+')');
		} else {
			
		}
	}

	var address = ur;
	var winName = "design";
	var wWindow = wh;
	var hWindow = he;
	var toolbar = 0;
	var menubar = 0;
	var scrollbars = sc;
	var resizable = re;
	var location = 0;
	var directories = 0;
	var status = 0;
	
	openWin1(address,winName,wWindow,hWindow,toolbar,menubar,scrollbars,resizable,location,directories,status);
}
It work accept for the top and left positioning values. It works with static numbers. so it doesn't seem to be calculating the stage.width and stage.height properties.

Does anyone know why this doesn't work. I had a similar script for as2 and it works perfectly.
Reply With Quote  
erico564 erico564 is offline erico564 lives in United States 2009-04-26 #61 Old  
@ericscott - if you use stage.stageWidth and stage.stageHeight, those should work for AS3 (versus stage.width and stage.height which are AS2 values).
Reply With Quote  
ericscott's Avatar ericscott ericscott is offline ericscott lives in New Zealand 2009-04-26 #62 Old  
Sorry, I meant screen.width and screen.height Java values toward the end of my ExternalInterface.call.
Reply With Quote  
Nutrox's Avatar Nutrox Nutrox is offline Super Moderator Nutrox lives in United Kingdom 17 Creative Assets 2009-04-26 #63 Old  
You can't expect JavaScript to execute that math at the end of the ExternalInterface call line because those parameters are sent as strings. What you are trying to do is something like this:

Code:
window.open( "page.htm", "mywin", "left=(x+y)/z,top=(x+y)/z" );
That isn't going to work. You will need to calculate those values in ActionScript before sending them to JavaScript, or call a JavaScript function that appends those values to the parameters before opening a window.

Is there any reason why you are nesting the openWin1() function like that?
Reply With Quote  
ericscott's Avatar ericscott ericscott is offline ericscott lives in New Zealand 2009-04-26 #64 Old  
Last edited by ericscott : 2009-04-26 at 17:28.
I am nesting the variables because I while I was building this I wanted to keep straight which ones are static, probably pointless, and I just decided to use your class anyway, but I modified the popup.js so I can close the window as well.

Code:
var my_window

function openPopupWindow( uri, name, opts )
{
	my_window = window.open( uri, name, opts );

	if( my_window )
	{
		if( my_window.focus )
		{
			my_window.focus();
		}

		return true;
	}

	return false;
}

function closePopupWindow()
{
	if(false == my_window.closed) 
	{
		my_window.close ();
		}
		else
		{
			alert('Window already closed!');
		}
}
Then added a close function in the PopupWindow.as file.

I will play around with the example you gave me. I will probably have to calculate screen.dimensions before they go into the call function.

I used a very similar script to the one I posted in as2. I am missing the days when you could just write the javascript function straight into a get url and everything worked.
Reply With Quote  
abeall abeall is offline abeall lives in United States 2009-06-16 #65 Old  
Setting wmode = opaque breaks mouse wheel support.
Reply With Quote  
Sundev Sundev is offline Sundev lives in United States 2009-11-05 #66 Old  
Just as an update, my crappy hack isn't needed anymore for the new Safari.
Reply With Quote  
iki_xx iki_xx is offline iki_xx lives in Benin 2010-02-02 #67 Old  
where are the download files ?
Reply With Quote  
<|1|2| Page 2 of 2
Thread Tools
Display Modes Rate This Thread
Rate This Thread: