Unexpected screen flicker

 

Are you experiencing unexpected screen flicker?
Does your component takes a long time to show up on the first time?
 
These may be caused by setting a newly created style declaration at runtime, most probably made by third party component you use
(we used PositionedTabNavigator) .
 
A common practice for component developers is to specify default styles as follows:
 
//The component try to get its style.
var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration( "MyStyle" );
 
//If not exist, create new style declaration and set it.
if( !style )
{  //You should avoid getting here !!
style = new CSSStyleDeclaration();
      StyleManager.setStyleDeclaration( "MyStyle", style, true );
}
 
//Set the styles.
if( style.defaultFactory == null )
{
style.defaultFactory = function():void
   {
         this.position = "top"
};
}
 
Adobe docs mention that setStyleDeclaration is computationally expensive and you can prevent Flash Player from applying or clearing the new styles immediately by setting the update parameter to false.
However, when you pass false for the update parameter, the Player stores the selector but does not apply the style, so it might solve your flickering issue, but the style won't be applied.
 
In order to both avoid the flicker and get the default style, all you need to do is avoid its creation by specifying the style selector in advance. For example, in your css file add an empty selector:
MyStyle {}
 
By using an empty style selector, the default style selector will take effect, without creating a new one.
 
Any style declared by you in the selector will override the default:
 
MyStyle {
position:bottom;
}
 
I'd like to mention that Ilan is a partner in this post.
Front End Developer

Frontend Group
Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com