Changing a Components Visibility

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Changing a Components Visibility

bilbosax
I have a mobile app that has several different components that are displayed in various states of the app.  So that I can get the app to look right on every device, when a state is entered and the component created, I set up the dimensions of the various buttons and textInputs and lists once the creationComplete fires.  The problem is that the first time the component is created, there is a little "dancing" that goes on while the objects are sized and positioned, the component does not just enter it's state fully formed.  It only lasts a frame or two, but is very noticeable and looks unprofessional.  The component is based on a Group.  I have tried setting the alpha property for the group to 0, sizing and positioning all of the objects in the component, and then setting the alpha for the group back to 1.  No joy.  I even tried setting the alpha of the main group to 0, sizing and position all of the objects in the component, and then setting the alpha for the group back to 1 using callLater.  Again, no joy.

Any thoughts??

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
                 xmlns:s="library://ns.adobe.com/flex/spark"
                 xmlns:ns="http://flex.apache.org/experimental/ns" 
                 creationComplete="sizeComponent(event)" xmlns:fxgAssets="fxgAssets.*" alpha="0">

<fx:Script>
               
<![CDATA[

			protected function sizeComponent(event:FlexEvent):void {
				
				[Size and position all of my various components]

				callLater(changeAlpha);
			}
			
			protected function changeAlpha():void {
				this.alpha = 1;
			}
               ]]>

</fx:Script>
</s:Group>
Reply | Threaded
Open this post in threaded view
|

Re: Changing a Components Visibility

bilbosax
I think I found an acceptable solution, but am not sure why it works.  Rather than setting the alpha property to 0 and then 1, I set the visible property to false and then true.  This allows the component to not show up until fully drawn, but I don't understand why this works but the alpha property did not???
Reply | Threaded
Open this post in threaded view
|

Re: Changing a Components Visibility

clintm
flash player will still render the object with alpha 0… it won't render the
object if visible is set to false

On Sat, Jun 17, 2017 at 2:02 PM, bilbosax <[hidden email]> wrote:

> I think I found an acceptable solution, but am not sure why it works.
> Rather
> than setting the alpha property to 0 and then 1, I set the visible property
> to false and then true.  This allows the component to not show up until
> fully drawn, but I don't understand why this works but the alpha property
> did not???
>
>
>
> --
> View this message in context: http://apache-flex-users.
> 2333346.n4.nabble.com/Changing-a-Components-Visibility-tp15334p15335.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: Changing a Components Visibility

Nemi
In reply to this post by bilbosax
"Dancing"  is because you make it dance a bit more after its creationComplete.  
For better performance: Instead of creationComplete use initializationComplete() like this:

override protected function initializationComplete():void {
        // enter here sizing and position code...

        super.initializationComplete();
}

From my experience, using initializationComplete instead of adding more code to creationComplete handler, makes Flex app much more smooth. IMHO this should be written with bold letters in any Flex docs!