Filter doesn't work

Posted by user1206761 
Filter doesn't work
May 16, 2012 12:41PM
I have a simple component for which I have copied the code from the tutorial file "2 Apply a FlashEff2 filter".
I am using Flash Builder 4.5, so I have changed the code according to the instructions in the forum.
Still, I don't see anything on the stage, it doesn't work. If I remove the filter I do see the image.
Following is my code, please help:

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="[ns.adobe.com];
		 xmlns:s="library://ns.adobe.com/flex/spark"
		 xmlns:mx="library://ns.adobe.com/flex/mx"
		 width="95" height="65" contentBackgroundColor="#3F3F3F" >
	<!-- The target object will be an image called "myImage" - you have to define the name property. -->
	<!-- It is a good practice to set the size for the Image object to the actual
	size of the image, otherwise the effects will not work due to an incorrect size
	of the Image component -->
	<mx:Image width="400" height="300" source="myImage.jpg" id="myImage" name="myImage" autoLoad="true" scaleContent="true" complete="loadComplete()" />
	<fx:Script>
		<![CDATA[
			import FlashEff2Flex;
			
			import com.jumpeye.flashEff2.filter.reflection.FEFReflection;
			
			private var myEffect:FlashEff2Flex;
			private var reflection:FEFReflection;
			
			private function init(e:Event):void
			{
				myEffect._targetInstanceName = "myImage";
				reflection = new FEFReflection();
				reflection.refresh = false;
				reflection.reflectionAlpha = 0.8;
				reflection.reflectionRatio = 150;
				reflection.reflectionDistance = 0;
				
				// Add the filter to the FlashEff2Flex instance.
				myEffect.addFilter(reflection);
			}
			
			private function loadComplete():void {
				// Once the image has been loaded, create the FlashEff2Flex component
				// instance, set it up and apply it on the image.
				myEffect = new FlashEff2Flex();
				myEffect.addEventListener(Event.ADDED_TO_STAGE, init);
				addElement(myEffect);
				
				// Create the reflection filter instance and set it up as you like.
				
				
				// Set the target object to the FlashEff2Flex instance. Once you do this,
				// the filter will be applied immediately.
				
			}
		]]>
	</fx:Script>
</s:Group>

Re: Filter doesn't work
May 17, 2012 05:46AM
I have solved the problem.
I have added a setTimout function that will set the target after a delay of 100 milliseconds, and it works.
Re: Filter doesn't work
May 17, 2012 02:55PM
I'm glad to hear that you manage to find the problem and thank you for pointing it out.
Sorry, you do not have permission to post/reply in this forum.