I am using AS3.0.
I want to change the color of a colorpicker programmatically.
I am doing this by directly setting the "selectedColor" property and then am trying to dispatch a change event.
The code is here:
//colPicker is the ColorPicker object;
colPicker["selectedColor"] = 10079232;
colPicker.dispatchEvent(new ColorPickerEvent(ColorPickerEvent.CHANGE));//mx API
The color is changong,but I am getting the following error for the dispatchEvent:
Error #1034: Type Coercion failed: cannot convert mx.events::ColorPickerEvent@c90aa89 to mx.events.ColorPickerEvent.
If,however, I also try:
colPicker.dispatchEvent(new Event(Event.CHANGE));//flash API
I get the following error:
Error #1034: Type Coercion failed: cannot convert flash.events::Event@c95d8e1 to mx.events.ColorPickerEvent.
As Alex HarUI said in one of my earlier posts, this is bcoz Im trying to integrate the Flex framework with a non-Flex classes.
So, I want to know how to dispatch a CHANGE event for ColorPicker from AS3.
This works but I need to dispatch the change event to completely simulate ColorPicker user interaction.
That is, even though I am setting it programmatically, I want to mimic user interaction.
If I set off an event handler for ColorPicker change, then this wont get fired if I just do a value commit.
I guess I need to dispatch a change event in this case.
Using the value commit WOULD mimic user interaction seeing as how it is dispatched for both user interaction and programmatic changes.