views:

281

answers:

1

Hi, I have simple combobox component in flash cs4, I try to add and event listener like this

mycombo.addEventListener(Event.ADDED_TO_STAGE, added);

function added(e:Event):void
{
trace("HI");
}

never get called even if I have the component in the stage manually or via AS, but if I add a listener to MouseOver it works, why the ADDED_TO_STAGE event don't work, also I have a problem with the textFormat style if I use

mycombo.setStyle("textFormat", tf);//suppose tf is a TextFormat object

doesn't work too, but if I put that line inside the MouseOver event it work's why?? please help thanks!!

A: 

Problem 1 Reason:

It appears that ADDED_TO_STAGE can occur before the trigger.

From https://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/events/Event.html#ADDED_TO_STAGE

The DisplayObject instance being added to the on stage display list, either directly or through the addition of a sub tree in which the DisplayObject instance is contained. If the DisplayObject instance is being directly added, the added event occurs before this event.

Problem 2 Reason:

Again, I believe the event is occurring before the event trigger. Thus the style never gets processed.

Todd Moses