Swap transition problem

Posted by krumedia 
Swap transition problem
March 31, 2011 04:53PM
I have created a test project to experiment on the swap mode.

What is wrong with the following code? At runtime there appears a FLASHEFF2 ERROR: ReferenceError: Error #1069: Property _swapTransitionStartCommands not found on FlashEff2Flex and there is no default value.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" 
	xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
	creationComplete="application1_creationCompleteHandler()">
	
	<fx:Script><![CDATA[
			import com.jumpeye.flashEff2.symbol.equalizer.FESEqualizer;
			import com.jumpeye.flashEff2.symbol.pixelate.FESPixelate;
			import com.jumpeye.flashEff2.symbol.waves.FESWaves;
			
			private var showPattern1:FESEqualizer = new FESEqualizer();
			private var showPattern2:FESPixelate = new FESPixelate();
			private var hidePattern:FESWaves = new FESWaves();
			
			private var myEffect:FlashEff2;

			protected function application1_creationCompleteHandler():void
			{
				myEffect = new FlashEff2Flex();
				
				myEffect.showTransition = showPattern2;
				myEffect.swapTransition = showPattern1;
				myEffect.hideTransition = hidePattern;
				
				myEffect.useSwapInsteadHide = true;
				myEffect.swapType = FlashEff2.SWAP_TYPE_HIDE_AND_SHOW;
				
				this.addElement(myEffect);
				myEffect.target = g1;
				myEffect.swapTarget = g2;
			}
	]]></fx:Script>
	
	<s:Button label="Restart" click="myEffect.show();" />
	
	<s:Graphic x="100" y="100" id="g1">
		<s:Rect width="400" height="300">
			<s:fill>
				<s:SolidColor color="#00ff00" />
			</s:fill>
		</s:Rect>
	</s:Graphic>
	
	<s:Graphic x="200" y="100" id="g2">
		<s:Rect width="400" height="300">
			<s:fill>
				<s:SolidColor color="#ff0000" />
			</s:fill>
		</s:Rect>
	</s:Graphic>
	
</s:Application>
Re: Swap transition problem
April 01, 2011 06:59AM
Instead of myEffect = new FlashEff2Flex(), try this myEffect = new FlashEff2() and see if do the trick.
Re: Swap transition problem
April 01, 2011 02:31PM
Yes, FlashEff2 will work since it is a dynamic class and FlashEff2Flex is not. But FlashEff2 will not initialize needed assets. But i was able to overcome this problem by declaring my derived class as dynamic.

Calling swap() multiple times first results for me in a FLASHEFF2 ERROR: The swapTarget property is null, a hide transition will be applied. It seems swapTarget is reset after calls to swap() and is not swapped with target.
Re: Swap transition problem
April 01, 2011 03:17PM
A solution in my opinion might be:

		override public function swap(newTarget:DisplayObject = null, swType:String = ""):void 
		{
			if (newTarget == null && this.swapTarget == null)
			{
				newTarget = this.crossSwapTarget;
			}
			
			super.swap(newTarget, swType);
		}
		
		private function effectStarting(e:FLASHEFFEvents):void 
		{
			if (this.currentTransitionType == "swap")
			{
				this.crossSwapTarget = this.target;
			}
		}
Re: Swap transition problem
April 04, 2011 11:32AM
Thank you for posting the solution here.
Re: Swap transition problem
April 04, 2011 06:27PM
What is the proper way to swap an element if the swap transition is currently playing? I think i should force an immediate end of the running swap transition and start a new swap transition.

At the moment if the user clicks faster than the transition is playing the error occurs:

RangeError: RangeError: Error #2006: The supplied index is out of bounds.
	at flash.display::DisplayObjectContainer/addChildAt()
	at FlashEff2/addSwapFlashEff2()
	at FlashEff2/transitionEffect()
	at FlashEff2/hide()
	at FlashEff2/swap()
Re: Swap transition problem
April 05, 2011 12:17PM
Try to call removeEffect method before calling the swap method.
Re: Swap transition problem
April 05, 2011 01:50PM
removeEffect() does not solve the problem. I think when the swap transition is completing some needed code is executed that is not executed, if i call removeEffect(). Another thing to note is, that i swap only from one element to a second element and vice versa.
Re: Swap transition problem
April 06, 2011 01:31PM
Open a ticket [www.jumpeyecomponents.com] and send us the source and we will take a look at the problem
Re: Swap transition problem
December 14, 2011 08:39PM
I am still getting the same error.
I am really stuck in slideshow.
Please share the complete code .
Sorry, you do not have permission to post/reply in this forum.