PDA

View Full Version : Binding vars to Flex component


MDiddy
12-06-2007, 07:19 AM
This might be a simple request, but I'm having problems finding a solution. I have states setup for my text color, and I need have the color values change based on an event. I thought I could just make a bindable var for the number associated with the color value but I get an error #1119.

"1119: Access of possibly undefined property selectedColor through a reference with static type module3_inlineComponent1."

I'm assuming this is a scoping issue - that that my states are not in the same scope as the actioncript code where I define the var, thought its in the same MXML file. Here's the pertient code:


[Bindable] public var selectedColor:uint;

private function loadLayout(index:Number):void {
this.selectedColor = moduleXML.getSelectedTextColorAt(index);
trace("color", this.selectedColor);
}

//States
<qs:states>
<mx:State id="navState" name="selected">
<SetProperty name="filters">
<value><Array>
<f:GlowFilter color="#FFFFFF"/>
</Array></value>
</SetProperty>
<SetStyle id="sColor" name="color" value="{this.selectedColor}" />
</mx:State>
<mx:State name="hilighted">
<SetProperty name="filters">
<value>
<Array>
<f:GlowFilter color="#BBBBBB"/>
</Array>
</value>
</SetProperty>
</mx:State>
</qs:states>

dr_zeus
12-06-2007, 06:20 PM
Everything looks fine there, except your ActionScript is not in an <mx:Script> block.

MDiddy
12-06-2007, 06:55 PM
Everything looks fine there, except your ActionScript is not in an <mx:Script> block.
It's inside a script block in my code. I don't know if this helps but the error I get is at compile-time, not runtime.

dr_zeus
12-06-2007, 09:36 PM
Can we see some more of your code?

MDiddy
12-07-2007, 11:28 PM
Here's all the source code as it stands. http://harrisondesign.biz/flex/srcview/index.html

It's a horribly hacked together modifiation of the FishEye component (http://www.quietlyscheming.com/blog/components/fisheye-component/) as I'm still learning AS 3 & MXML. :)

Basically I want to change the selected color of the nav at the bottom when a new layout swf is loaded.

Thanks very much for looking!