|
Show/hide if not applied already February 09, 2011 02:50PM | Registered: 2 years ago Posts: 25 |
Hello,
calling hide() on a hidden element will repeat the hide transition. How do i achieve the transition is only played once?
This is what i tried: (my try was to add a helper method to a derived class of FlashEff2Flex)
So frustrating: Closed source is such a pain like walking with tied hands.
calling hide() on a hidden element will repeat the hide transition. How do i achieve the transition is only played once?
This is what i tried: (my try was to add a helper method to a derived class of FlashEff2Flex)
public function toVisibility(visible:Boolean):void
{
if (this.isTransitioning)
{
var toTransitionType:String = visible ? "show" : "hide";
if (this.currentTransitionType == toTransitionType)
{
return;
}
this.stop();
}
else if (target.visible == visible) // won't work!
{
return;
}
if (visible) this.show();
else this.hide();
}So frustrating: Closed source is such a pain like walking with tied hands.
|
Re: Show/hide if not applied already February 10, 2011 12:43AM | Admin Registered: 5 years ago Posts: 514 |
|
Re: Show/hide if not applied already February 10, 2011 08:15AM | Registered: 2 years ago Posts: 25 |
|
Re: Show/hide if not applied already February 10, 2011 09:22AM | Admin Registered: 5 years ago Posts: 514 |
|
Re: Show/hide if not applied already February 10, 2011 10:31AM | Registered: 2 years ago Posts: 25 |
Hi kneo,
this is the original setter:
To enable FlashEff my first approach is:
But there is a problem: If the target's visibility equals value (the setter argument) no animation should be played.
There are two cases the animation should not play:
- initial calls to show()/hide() result in the same visibility:
this is the original setter:
public function set showDescription(value:Boolean):void
{
descriptionArea.visible = value;
}To enable FlashEff my first approach is:
public function set showDescription(value:Boolean):void
{
if (value) effect.show();
else effect.hide();
}But there is a problem: If the target's visibility equals value (the setter argument) no animation should be played.
There are two cases the animation should not play:
- initial calls to show()/hide() result in the same visibility:
<fx:Script>
private function test():void
{
effect.hide(); // call to hide() should do nothing since myControl.visible == false already
}
</fx:Script>
<my:Control id="myControl" visible="false" />
- show()/hide() has been called and a second call of show()/hide() is made
<fx:Script>
private function method1():void
{
effect.hide(); // will hide myControl
}
private function method2CalledLater():void
{
effect.hide(); // should not play the hide transition again
}
</fx:Script>
<my:Control id="myControl" />
|
Re: Show/hide if not applied already February 11, 2011 05:26AM | Admin Registered: 5 years ago Posts: 514 |
Try to use this code.
The method that you used works only if you have a movieclip as a target and not a textfield.
package
{
public class MyFlashEff extends FlashEff2Flex
{
public function MyFlashEff()
{
super();
}
protected var visibility:Boolean = false;
override public function show(arg0:*=null):void{
super.show(arg0);
visibility=true
}
override public function hide():void{
super.hide();
visibility = false;
}
public function toVisibility(visible:Boolean):void
{
if (this.isTransitioning)
{
var toTransitionType:String = visible ? "show" : "hide";
if (this.currentTransitionType == toTransitionType)
{
return;
}
}
else if (visibility == visible) // won't work!
{
return;
}
if (visible) this.show();
else this.hide();
}
}
}The method that you used works only if you have a movieclip as a target and not a textfield.
|
Re: Show/hide if not applied already February 24, 2011 05:33AM | Registered: 2 years ago Posts: 25 |
This is the final version that will work:
public class MyFlashEff extends FlashEff2Flex
{
protected var endingVisibility:Boolean = false;
public function MyFlashEff()
{
super();
this.includeInLayout = false;
this.visible = false;
this.showAutoPlay = false;
this.hideAutoPlay = false;
addEventListener(FLASHEFFEvents.TRANSITION_START, effectStarting);
addEventListener(FLASHEFFEvents.TRANSITION_END, effectEnding);
}
override public function set target(value:DisplayObject):void
{
this.endingVisibility = value != null && value.visible;
super.target = value;
}
override public function show(arg0:* = null):void
{
this.endingVisibility = true;
super.show(arg0);
}
override public function hide():void
{
this.endingVisibility = false;
super.hide();
}
public function toVisibility(visible:Boolean):void
{
if (visible != this.endingVisibility)
{
if (visible) this.show();
else this.hide();
}
}
private function effectStarting(e:FLASHEFFEvents):void
{
this.visible = true;
}
private function effectEnding(e:FLASHEFFEvents):void
{
if (currentTransitionType == "hide")
{
this.visible = false;
}
}
}
Sorry, only registered users may post in this forum.






