[flexcoders] Flex / Web Integration

2007-09-20 Thread byte.sensei
I have a Flex 2.0 app that has to open a URL used to configure a 
shopping cart item. When finished configuring an item and you return 
to Flex, Flex calls a web service to retrieve the item configuration 
and all is good.

Currently, I'm opening a new browser window using navigateToURL() 
with _blank for the target.  This presents a couple of problems:

1) When the item configuration is done and the window is closed 
(using Javascript) I get the annoying The webpage you are using is 
trying to close the window and you have to verify that you want to 
close the window.

2) I don't have any good way to detect the window was closed and then 
fire off the web service to get the item configuration -- I basically 
have to wait for the user to do something back in the Flex app that 
causes an event to fire that I can trigger on. (I'm currently using 
the focusOut event of the Quantity field in the item data grid, but 
there's no guarantee the user will click/tab into a quantity field 
and then back out after configuring an item...)

So, does anyone know of a way I could open a new window/url for the 
item configuration, but then return to the Flex app without the Do 
you want to close this window? dialog box AND in a way that would 
fire a Flex event I can use to trigger the web service call?

I don't have any control over the item configuration URL/code -- 
it's a 3rd party application I'm integrating with...

Thanks in advance for any insight/help!





Re: [flexcoders] Flex / Web Integration

2007-09-20 Thread Stephen Allison

 1) When the item configuration is done and the window is closed
 (using Javascript) I get the annoying The webpage you are using is
 trying to close the window and you have to verify that you want to
 close the window.
If you don't have any control over the code in the window that's  
closing the window it's hard to see how you can overcome this - am I  
right in thinking that the javascript involved here comes from teh  
3rd party you mention?
 2) I don't have any good way to detect the window was closed and then
 fire off the web service to get the item configuration -- I basically
 have to wait for the user to do something back in the Flex app that
 causes an event to fire that I can trigger on. (I'm currently using
 the focusOut event of the Quantity field in the item data grid, but
 there's no guarantee the user will click/tab into a quantity field
 and then back out after configuring an item...)
You could listen for the 'activate' event on the Application object  
(or anything else, I think everything can fire it), that should be  
triggered whenever the Flash player regains focus.  This would avoid  
the problem of the user not clicking in the right place that you have  
with onFocus.

As to detecting the window closing, , I seem to remember that in  
DHTML the window object fires an event called 'unload' when it is  
closed, you could listen for the closing of the configuration window  
in the HTML containing your SWF and then use external interface to  
call back into Flex.  You are at risk of opening the cross-browser  
compatability can of worms with this though.

Hope this is of some help...
Stephen