Question

I have a flex application and I want to add a new custom component with action script at runtime. This works fine. I have created my custom component and added the following code:

var freeView:FreeView=new FreeView();
freeView.setStyle("showEffect",this.fadeIn);
freeView.setStyle("hideEffect",this.fadeOut);
freeView.visible=false;
this.addChild(freeView);
freeView.visible=true;

But my problem is the fade in effecto is not working. I know I've declared the effect correctly because if I use it in another component (like a panel) it works fine. Can anybody help me with this issue? Best regards!

Was it helpful?

Solution 2

Finally I solve the problem in a different way. Instead adding the component at run time I have added the component to the application with visible property set to false and I change it to true when I need.

OTHER TIPS

Ensure that you call any overridden Flex super-functions in your FreeView subclass.

Especially updateDisplayList and commitProperties:

override protected function updateDisplayList(w:Number, h:Number)
{
    super.updateDisplayList(w, h);

    // Your code here.
}


override protected function commitProperties()
{
    super.commitProperties();

    // Your code here.
}

Are you overriding one of the high-level container classes (e.g. Canvas or HBox) or UIComponent?

you can do it the other way around by setting effects target to your new element

<mx:Fade id="showFlag" alphaFrom="0" alphaTo="1" duration="5000"/>

var flag:Image = new Image;
flag.source = flagSource;

something.addElement(flag);

showFlag.target = flag;
showFlag.play();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top