Re: [flexcoders] Runtime CSS problem with SWFLoader

2007-09-30 Thread Jason Y. Kwong
Yes, I had originally thought that you meant to load the CSS swf into the
the current domain.  However, StyleManager.loadStyleDeclarations() does not
give the option of specifying a LoaderContext.  It has a trustContent
argument, but setting that to true fails when loading a local SWF (I've not
tried from the network yet).

The thing is, I wonder if it really is about not being able to see classes.
For instance, my CSS file has a selector like this:

.chickButton
{
up-skin: Embed('assets/chicklet_button_up.png');
}

When the subswf loads this CSS at runtime, the button's upskin does not
update on-screen (as before).  However, I can see the class in the subswf.
I trace this inside the subswf:

   var decl: CSSStyleDeclaration = StyleManager.getStyleDeclaration
(.chickButton);
   trace(decl.getStyle(upSkin));

and I get output like:

   [class newstyles__embed_css_assets_chicklet_button_up_png_1372914861]

And as stated in my last post, if I force a refresh of styles, the upskin
does then update on-screen.  It seems to me that the SystemManager of the
subswf is not being told to refresh its styles after the CSS file is loaded.


On 9/30/07, Alex Harui [EMAIL PROTECTED] wrote:

Uh, sorry, I wasn't clear.  You need to set the app domain in
 loadStyleDeclaration, not in SWFLoader.



 Every SWF has a copy of ModuleManager in it.  That code is used to load
 every module including CSS files.  Since that code says to make a child
 appdom of the ModuleManager's app dom, when your app is the main app, the
 style classes are loaded into a child domain and share common class
 definitions.



 When you load your app from a shell app, the ModuleManager is in the
 shell.  Your sub-app gets a child app domain and so does the css file, which
 means that your app and the css file have sibling appdoms, which means the
 cannot share classes and that messes up your styling.  By specifying the app
 domain in loadStyleDecl, you are telling it not to load the css into a child
 domain, but rather, to load it into the shell's appdom so it can be seen by
 other appdoms like your app.  You can also specify your sub-apps app-dom or
 child of your sub-app's appdom, but they key is to load the CSS into a place
 where its classes share classes with your app.


  --

 *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
 Behalf Of *Jason Y. Kwong
 *Sent:* Saturday, September 29, 2007 9:34 PM
 *To:* flexcoders@yahoogroups.com
 *Subject:* Re: [flexcoders] Runtime CSS problem with SWFLoader



 Thank you for your reply, Alex.  I tried doing the following with the
 SWFLoader:

var lctx: LoaderContext = new LoaderContext();
lctx.applicationDomain = ApplicationDomain.currentDomain;
loader.loaderContext = lctx;
loader.load(MyApp.swf);

 However, when MyApp loads a runtime CSS SWF, its styles are still not
 updating.  Both the loading SWF and the MyApp SWF are local files in the
 same directory.

 I poked around in the StyleManager code and saw that it calls the
 styleDeclarationsChanged() method after a CSS SWF has been loaded.  It looks
 like this:

 public function styleDeclarationsChanged():void
 {
   var sms:Array /* of SystemManager */ =
 SystemManagerGlobals.topLevelSystemManagers;
   var n:int = sms.length;
   for (var i:int = 0; i  n; i++)
   {
 var sm:SystemManager = SystemManager(sms[i]);
 sm.regenerateStyleCache(true);
 sm.notifyStyleChangeInChildren(null, true);
   }
 }

 When I stepped through this, I saw that the sms array contains only the
 SystemManager for the main application.  So I decided to have MyApp
 explicitly update its own SystemManager after a CSS SWF is loaded:

systemManager.mx_internal::regenerateStyleCache(true);
systemManager.mx_internal::notifyStyleChangeInChildren (null, true);

 This actually got all the styles to update on-screen.  So what's not
 working right here?  Is it related to the application domain or is it
 something else?

  On 9/29/07, *Alex Harui* [EMAIL PROTECTED] wrote:

 That's a common tripping point with runtime  CSS.  In a subswf config, you
 have to specify the applicationDomain parameter to be
 ApplicationDomain.currentDomain.  If you care why, see my modules
 presentation on my blog (blogs.adobe.com/aharui)


  --

 *From:* [EMAIL PROTECTED] ups.com [mailto:[EMAIL PROTECTED] ups.com] *On
 Behalf Of *Jason Y. Kwong
 *Sent:* Saturday, September 29, 2007 1:05 PM
 *To:* flexcoders@yahoogroups.com
 *Subject:* [flexcoders] Runtime CSS problem with SWFLoader



 I've got an app which loads different runtime CSS SWFs to change its
 appearance at runtime.  Everything works fine.  However, if I load this app
 inside another app using SWFLoader, the style changes don't happen.  At
 best, some of the new styles are applied, but never all.  I can confirm that
 the CSS SWF is indeed being loaded (I get info in the console about it),
 it's just that the new styles

RE: [flexcoders] Runtime CSS problem with SWFLoader

2007-09-30 Thread Alex Harui
My bad, I was looking at the 3.0 api.  There is a separate issue that a
subswf won't see the style changes after it has created its components.
Both are fixed in 3.0

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Jason Y. Kwong
Sent: Sunday, September 30, 2007 9:09 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Runtime CSS problem with SWFLoader

 

Yes, I had originally thought that you meant to load the CSS swf into
the the current domain.  However, StyleManager.loadStyleDeclarations()
does not give the option of specifying a LoaderContext.  It has a
trustContent argument, but setting that to true fails when loading a
local SWF (I've not tried from the network yet). 

The thing is, I wonder if it really is about not being able to see
classes.  For instance, my CSS file has a selector like this:

.chickButton
{
up-skin: Embed('assets/chicklet_button_up.png'); 
}

When the subswf loads this CSS at runtime, the button's upskin does not
update on-screen (as before).  However, I can see the class in the
subswf.  I trace this inside the subswf:

   var decl: CSSStyleDeclaration =
StyleManager.getStyleDeclaration(.chickButton);
   trace(decl.getStyle(upSkin));

and I get output like:

   [class newstyles__embed_css_assets_chicklet_button_up_png_1372914861]

And as stated in my last post, if I force a refresh of styles, the
upskin does then update on-screen.  It seems to me that the
SystemManager of the subswf is not being told to refresh its styles
after the CSS file is loaded. 



On 9/30/07, Alex Harui [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
wrote:

Uh, sorry, I wasn't clear.  You need to set the app domain in
loadStyleDeclaration, not in SWFLoader.  

 

Every SWF has a copy of ModuleManager in it.  That code is used to load
every module including CSS files.  Since that code says to make a child
appdom of the ModuleManager's app dom, when your app is the main app,
the style classes are loaded into a child domain and share common class
definitions.

 

When you load your app from a shell app, the ModuleManager is in the
shell.  Your sub-app gets a child app domain and so does the css file,
which means that your app and the css file have sibling appdoms, which
means the cannot share classes and that messes up your styling.  By
specifying the app domain in loadStyleDecl, you are telling it not to
load the css into a child domain, but rather, to load it into the
shell's appdom so it can be seen by other appdoms like your app.  You
can also specify your sub-apps app-dom or child of your sub-app's
appdom, but they key is to load the CSS into a place where its classes
share classes with your app.

 



From: [EMAIL PROTECTED] ups.com [mailto:[EMAIL PROTECTED] ups.com
http://ups.com ] On Behalf Of Jason Y. Kwong
Sent: Saturday, September 29, 2007 9:34 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Runtime CSS problem with SWFLoader

 

Thank you for your reply, Alex.  I tried doing the following with the
SWFLoader:

   var lctx: LoaderContext = new LoaderContext();
   lctx.applicationDomain = ApplicationDomain.currentDomain;
   loader.loaderContext = lctx;
   loader.load(MyApp.swf);

However, when MyApp loads a runtime CSS SWF, its styles are still not
updating.  Both the loading SWF and the MyApp SWF are local files in the
same directory.

I poked around in the StyleManager code and saw that it calls the
styleDeclarationsChanged() method after a CSS SWF has been loaded.  It
looks like this:

public function styleDeclarationsChanged():void
{
  var sms:Array /* of SystemManager */ = 
SystemManagerGlobals.topLevelSystemManagers;
  var n:int = sms.length;
  for (var i:int = 0; i  n; i++)
  {
var sm:SystemManager = SystemManager(sms[i]);
sm.regenerateStyleCache(true);
sm.notifyStyleChangeInChildren(null, true);
  }
}

When I stepped through this, I saw that the sms array contains only the
SystemManager for the main application.  So I decided to have MyApp
explicitly update its own SystemManager after a CSS SWF is loaded:

   systemManager.mx_internal::regenerateStyleCache(true);
   systemManager.mx_internal::notifyStyleChangeInChildren (null, true);

This actually got all the styles to update on-screen.  So what's not
working right here?  Is it related to the application domain or is it
something else?

On 9/29/07, Alex Harui [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
wrote:

That's a common tripping point with runtime  CSS.  In a subswf config,
you have to specify the applicationDomain parameter to be
ApplicationDomain.currentDomain.  If you care why, see my modules
presentation on my blog (blogs.adobe.com/aharui
http://blogs.adobe.com/aharui )

 



From: [EMAIL PROTECTED] ups.com [mailto:[EMAIL PROTECTED] ups.com
http://ups.com ] On Behalf Of Jason Y. Kwong
Sent: Saturday, September 29, 2007 1:05 PM
To: flexcoders

[flexcoders] Runtime CSS problem with SWFLoader

2007-09-29 Thread Jason Y. Kwong
I've got an app which loads different runtime CSS SWFs to change its
appearance at runtime.  Everything works fine.  However, if I load this app
inside another app using SWFLoader, the style changes don't happen.  At
best, some of the new styles are applied, but never all.  I can confirm that
the CSS SWF is indeed being loaded (I get info in the console about it),
it's just that the new styles are not applied.  Is this a bug?  I'm using
Flex Builder 2.01.


RE: [flexcoders] Runtime CSS problem with SWFLoader

2007-09-29 Thread Alex Harui
That's a common tripping point with runtime  CSS.  In a subswf config,
you have to specify the applicationDomain parameter to be
ApplicationDomain.currentDomain.  If you care why, see my modules
presentation on my blog (blogs.adobe.com/aharui)

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Jason Y. Kwong
Sent: Saturday, September 29, 2007 1:05 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Runtime CSS problem with SWFLoader

 

I've got an app which loads different runtime CSS SWFs to change its
appearance at runtime.  Everything works fine.  However, if I load this
app inside another app using SWFLoader, the style changes don't happen.
At best, some of the new styles are applied, but never all.  I can
confirm that the CSS SWF is indeed being loaded (I get info in the
console about it), it's just that the new styles are not applied.  Is
this a bug?  I'm using Flex Builder 2.01.

 



Re: [flexcoders] Runtime CSS problem with SWFLoader

2007-09-29 Thread Jason Y. Kwong
Thank you for your reply, Alex.  I tried doing the following with the
SWFLoader:

   var lctx: LoaderContext = new LoaderContext();
   lctx.applicationDomain = ApplicationDomain.currentDomain;
   loader.loaderContext = lctx;
   loader.load(MyApp.swf);

However, when MyApp loads a runtime CSS SWF, its styles are still not
updating.  Both the loading SWF and the MyApp SWF are local files in the
same directory.

I poked around in the StyleManager code and saw that it calls the
styleDeclarationsChanged() method after a CSS SWF has been loaded.  It looks
like this:

public function styleDeclarationsChanged():void
{
  var sms:Array /* of SystemManager */ =
SystemManagerGlobals.topLevelSystemManagers;
  var n:int = sms.length;
  for (var i:int = 0; i  n; i++)
  {
var sm:SystemManager = SystemManager(sms[i]);
sm.regenerateStyleCache(true);
sm.notifyStyleChangeInChildren(null, true);
  }
}

When I stepped through this, I saw that the sms array contains only the
SystemManager for the main application.  So I decided to have MyApp
explicitly update its own SystemManager after a CSS SWF is loaded:

   systemManager.mx_internal::regenerateStyleCache(true);
   systemManager.mx_internal::notifyStyleChangeInChildren (null, true);

This actually got all the styles to update on-screen.  So what's not working
right here?  Is it related to the application domain or is it something
else?


On 9/29/07, Alex Harui [EMAIL PROTECTED] wrote:

That's a common tripping point with runtime  CSS.  In a subswf config,
 you have to specify the applicationDomain parameter to be
 ApplicationDomain.currentDomain.  If you care why, see my modules
 presentation on my blog (blogs.adobe.com/aharui)


  --

 *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
 Behalf Of *Jason Y. Kwong
 *Sent:* Saturday, September 29, 2007 1:05 PM
 *To:* flexcoders@yahoogroups.com
 *Subject:* [flexcoders] Runtime CSS problem with SWFLoader



 I've got an app which loads different runtime CSS SWFs to change its
 appearance at runtime.  Everything works fine.  However, if I load this app
 inside another app using SWFLoader, the style changes don't happen.  At
 best, some of the new styles are applied, but never all.  I can confirm that
 the CSS SWF is indeed being loaded (I get info in the console about it),
 it's just that the new styles are not applied.  Is this a bug?  I'm using
 Flex Builder 2.01.

  



RE: [flexcoders] Runtime CSS problem with SWFLoader

2007-09-29 Thread Alex Harui
Uh, sorry, I wasn't clear.  You need to set the app domain in
loadStyleDeclaration, not in SWFLoader.  

 

Every SWF has a copy of ModuleManager in it.  That code is used to load
every module including CSS files.  Since that code says to make a child
appdom of the ModuleManager's app dom, when your app is the main app,
the style classes are loaded into a child domain and share common class
definitions.

 

When you load your app from a shell app, the ModuleManager is in the
shell.  Your sub-app gets a child app domain and so does the css file,
which means that your app and the css file have sibling appdoms, which
means the cannot share classes and that messes up your styling.  By
specifying the app domain in loadStyleDecl, you are telling it not to
load the css into a child domain, but rather, to load it into the
shell's appdom so it can be seen by other appdoms like your app.  You
can also specify your sub-apps app-dom or child of your sub-app's
appdom, but they key is to load the CSS into a place where its classes
share classes with your app.

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Jason Y. Kwong
Sent: Saturday, September 29, 2007 9:34 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Runtime CSS problem with SWFLoader

 

Thank you for your reply, Alex.  I tried doing the following with the
SWFLoader:

   var lctx: LoaderContext = new LoaderContext();
   lctx.applicationDomain = ApplicationDomain.currentDomain;
   loader.loaderContext = lctx;
   loader.load(MyApp.swf);

However, when MyApp loads a runtime CSS SWF, its styles are still not
updating.  Both the loading SWF and the MyApp SWF are local files in the
same directory.

I poked around in the StyleManager code and saw that it calls the
styleDeclarationsChanged() method after a CSS SWF has been loaded.  It
looks like this:

public function styleDeclarationsChanged():void
{
  var sms:Array /* of SystemManager */ = 
SystemManagerGlobals.topLevelSystemManagers;
  var n:int = sms.length;
  for (var i:int = 0; i  n; i++)
  {
var sm:SystemManager = SystemManager(sms[i]);
sm.regenerateStyleCache(true);
sm.notifyStyleChangeInChildren(null, true);
  }
}

When I stepped through this, I saw that the sms array contains only the
SystemManager for the main application.  So I decided to have MyApp
explicitly update its own SystemManager after a CSS SWF is loaded:

   systemManager.mx_internal::regenerateStyleCache(true);
   systemManager.mx_internal::notifyStyleChangeInChildren (null, true);

This actually got all the styles to update on-screen.  So what's not
working right here?  Is it related to the application domain or is it
something else?



On 9/29/07, Alex Harui [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
wrote:

That's a common tripping point with runtime  CSS.  In a subswf config,
you have to specify the applicationDomain parameter to be
ApplicationDomain.currentDomain.  If you care why, see my modules
presentation on my blog (blogs.adobe.com/aharui
http://blogs.adobe.com/aharui )

 



From: [EMAIL PROTECTED] ups.com [mailto:[EMAIL PROTECTED] ups.com
http://ups.com ] On Behalf Of Jason Y. Kwong
Sent: Saturday, September 29, 2007 1:05 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Runtime CSS problem with SWFLoader

 

I've got an app which loads different runtime CSS SWFs to change its
appearance at runtime.  Everything works fine.  However, if I load this
app inside another app using SWFLoader, the style changes don't happen.
At best, some of the new styles are applied, but never all.  I can
confirm that the CSS SWF is indeed being loaded (I get info in the
console about it), it's just that the new styles are not applied.  Is
this a bug?  I'm using Flex Builder 2.01.