[flexcoders] Re: How to verify a URL before loading it OR how to catch IOException

2007-09-26 Thread Sandeep Malik
Hi,

The reason this approach will not work is that the error you are 
getting is an asynchronous error, i.e. something that happens in a 
different code path (when you response return from server). 'try-
catch' can only protected in the current execution stack.

A simple look up at the StyleManager API reveals that 
loadStyleDeclarations() returns an IEventDispatcher!

All you need is :

try {
  var ed : IEventDispatcher = StyleManager.loadStyleDeclarations
(MyTheme.swf);
  ed.addEventListener(StyleEvent.ERROR,myErrorHandler);
} 

Regards,
Sandeep

--- In flexcoders@yahoogroups.com, tjcox1969 [EMAIL PROTECTED] wrote:

 I have a compiled theme SWF that I want to load at runtime.  The
 problem is that if the theme.swf does not exist, I get Flash/Flex's
 ugly default error dialog at runtime saying:
 
 Error: Unable to load style(Error #2035: URL Not Found. URL:
 MyTheme.swf): MyTheme.swf.
 
 I don't mind catching the exception on load time but catching
 exceptions doesn't freakin work!  So frustrating...
 
 How does one catch this exception?  I have spent hours on 
this...even
 looking into how URLLoader handles exceptions and catching 
exceptions
 on that does not work for me either - I get the default Flex error
 dialog.  I tried catching IOError, Error, etc  HELP!!??
 
 Here is what I am doing, but the catch statement never happens:
 
 try {
   StyleManager.loadStyleDeclarations(MyTheme.swf);
 } catch (e:Error) {
 
   Alert.show(Error);
 }





[flexcoders] Re: How to verify a URL before loading it OR how to catch IOException

2007-09-26 Thread tjcox1969
Yup.  That worked!  Thanks a lot.

--- In flexcoders@yahoogroups.com, Sandeep Malik [EMAIL PROTECTED]
wrote:

 Hi,
 
 The reason this approach will not work is that the error you are 
 getting is an asynchronous error, i.e. something that happens in a 
 different code path (when you response return from server). 'try-
 catch' can only protected in the current execution stack.
 
 A simple look up at the StyleManager API reveals that 
 loadStyleDeclarations() returns an IEventDispatcher!
 
 All you need is :
 
 try {
   var ed : IEventDispatcher = StyleManager.loadStyleDeclarations
 (MyTheme.swf);
   ed.addEventListener(StyleEvent.ERROR,myErrorHandler);
 } 
 
 Regards,
 Sandeep
 
 --- In flexcoders@yahoogroups.com, tjcox1969 tjc1969@ wrote:
 
  I have a compiled theme SWF that I want to load at runtime.  The
  problem is that if the theme.swf does not exist, I get Flash/Flex's
  ugly default error dialog at runtime saying:
  
  Error: Unable to load style(Error #2035: URL Not Found. URL:
  MyTheme.swf): MyTheme.swf.
  
  I don't mind catching the exception on load time but catching
  exceptions doesn't freakin work!  So frustrating...
  
  How does one catch this exception?  I have spent hours on 
 this...even
  looking into how URLLoader handles exceptions and catching 
 exceptions
  on that does not work for me either - I get the default Flex error
  dialog.  I tried catching IOError, Error, etc  HELP!!??
  
  Here is what I am doing, but the catch statement never happens:
  
  try {
StyleManager.loadStyleDeclarations(MyTheme.swf);
  } catch (e:Error) {
  
Alert.show(Error);
  }