When setting the fill colors
for a component class at runtime, Flex breaks. It's possible to set the
fill colors for an instance, but not for a class. Take a look at the code
below. The first function, setInstanceStyle, works fine. The second function,
setClassStyle, causes the MenuBar to disappear and the buttons to stop working. It's possible to change
other styles using the same method as is used in setClassStyle. For example, I
can change background color, border color, and text styles using the same
methodology as is used in setClassStyle. But when I try to set fillColors using
that method, the component disappears and the program hangs. As far as I can tell, this
is a bug. I haven't found any other mention of it, though. Does anyone have any more
info on this? Am I missing something? <?xml
version="1.0" encoding="utf-8"?> <mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"> <mx:XML
id="mainMenuData" format="e4x"
source="mainMenu.xml" /> <mx:Script> <![CDATA[ import
mx.styles.*; private
var menuBarStyle:CSSStyleDeclaration = new
CSSStyleDeclaration("menuBarStyle"); private
function setInstanceStyle(event:MouseEvent):void{ mainMenu.setStyle('fillColors',[0xFFFFCC,0xFFFFCC]); } private
function setClassStyle(event:MouseEvent):void{ menuBarStyle.setStyle('fillColors',[0xFFFFCC,0xFFFFCC]); StyleManager.setStyleDeclaration('MenuBar',menuBarStyle,true); } ]]> </mx:Script> <mx:MenuBar
id="mainMenu" dataProvider="{mainMenuData.menuitem}" labelField="@label"
width="100%" /> <mx:Button
id="instanceButton" label="Set Instance Style" click="setInstanceStyle(event);"
x="20" y="40" /> <mx:Button
id="classButton" label="Set Class Style" click="setClassStyle(event);"
x="180" y="40" /> </mx:Application> <!-- Here's the xml used
for the menu (mainMenu.xml) --> <?xml version="1.0"
encoding="utf-8"?> <root> <menuitem
label="File"> <menuitem
label="New" /> <menuitem
label="Open" /> <menuitem
label="Exit" /> </menuitem> <menuitem
label="View"> <menuitem
label="Toolbars" /> <menuitem
label="Source" /> </menuitem> <menuitem
label="Help"> <menuitem
label="Online Help" /> <menuitem
label="About Style Test" /> </menuitem> </root> -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
YAHOO! GROUPS LINKS
|