Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Reply
 
Thread Tools Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
Old 07-12-2008, 05:42 PM   #1
corgan1003
Registered User
 
Join Date: Jul 2008
Posts: 2
Red face Flex bug? Dynamically changing background color messes up layout!

I developed a widget and would like users to be able to customize the colors. For this reason, I have provided a JS external interface to access color properties. Users can also pass in color properties as flash parameters.

When my widget is rendered, it will take a flash parameter for the background color. Setting the background color of my application container to the passed in color parameter screws up my widget layout for some reason. I have actually fixed this by making a call to validateNow() right after I set the new background color.

I thought this was the solution to my problem. Anytime someone used my external interface to change the background color of my widget, I could simply set the backgroundColor property to the new value, and then call validateNow() to force a redraw (I am not worried about this operation being heavy...does not matter in my situation). The strange thing is this does not work.

The first time I set a new background color and call validateNow() like so:
ActionScript Code:
if(applicationParameters.background_color != undefined){      background_color = applicationParameters.background_color; }else{      background_color = 0xffffff; //default } this.validateNow();
the layout is fixed. But after that first time, if a user accesses my external interface:
ActionScript Code:
public function setBackgroundColor(rgb:String):void {     background_color = uint(rgb);     this.validateNow();     trace("changing back ground color to: " + background_color); }
and submits a color change, validateNow() does not fix the issue

Can anyone even point me in the right direction on how to solve this issue? I am really stuck

Thank you!
corgan1003 is offline   Reply With Quote
Old 07-13-2008, 01:12 AM   #2
fathwad
Registered User
 
Join Date: Jul 2008
Posts: 52
Default

backgroundColor is a style, not a property.

Try this:

ActionScript Code:
setStyle("backgroundColor",0x0000ff);
fathwad is offline   Reply With Quote
Old 07-13-2008, 01:13 AM   #3
fathwad
Registered User
 
Join Date: Jul 2008
Posts: 52
Default

Oh, and, calling validateNow() would be unnecessary.
fathwad is offline   Reply With Quote
Old 07-14-2008, 12:00 AM   #4
corgan1003
Registered User
 
Join Date: Jul 2008
Posts: 2
Default

I was using the term "property" loosely. For my code, calling setStyle does the same thing as setting the variable "backgroundColor" because that variable is binded to the VBox component backgroundColor style. This is the mxml:

ActionScript Code:
<mx:VBox id="application_container" width="100%" height="100%" verticalGap="0" paddingLeft="2" paddingBottom="2" paddingRight="2" paddingTop="2" backgroundColor="{background_color}" >

Anyway, I removed the binding and set the backgroundColor explicitly with setStyle as you suggested, but it made no difference.

Also, I am not sure why validateNow() was fixing the layout the first time I called it, but it certainly was.

Any other thoughts as to why changing the backgroundColor would mess up my widget layout?

Thanks
corgan1003 is offline   Reply With Quote
Old 07-14-2008, 06:29 PM   #5
fathwad
Registered User
 
Join Date: Jul 2008
Posts: 52
Default

That is quite strange. The only thing I can think of is that if you do not have a background color, you may have a different size as compared to when you have a background color set. This may potentially screw up your layout. That said, it seems this isn't your issue...
fathwad is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Flex Styler Application - no Layout styling? RR_QQ Flex 2, 3 & 4 1 05-14-2008 05:28 PM
Is it possible to create your own Grid Layout container & add GridRow dynamically tanusree Flex 2, 3 & 4 4 09-25-2007 07:25 PM
changing text size dynamically vish_dude ActionScript 2.0 1 12-09-2006 11:51 AM
Changing MovieClip depths dynamically rolandvvv ActionScript 2.0 2 06-23-2006 07:59 AM
Changing background colour during movie maltonbranch Animation and Effects 1 05-06-2003 08:50 PM


All times are GMT. The time now is 11:55 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.