Add flashEff to dynamically created MC with Actionscript

Posted by aigarinsh 
Add flashEff to dynamically created MC with Actionscript
August 09, 2008 12:11PM
Hi!
Can anyone help me with this one? I have simple slide show with XML, where everything is created in lvis class. When I try to add flashEff to MC where image is already loaded it throws me this error: [FLASHEFF ERROR] You must set a non-null DisplayObject.

Main movie is completely empty with document class lvis and just flashEff and FESSquareScale in its library and the code for lvis.as is like this:
package {
	import flash.display.*;
	import flash.events.*;
	...
	
	public class lvis extends MovieClip {
		...
		public var lvis1:MovieClip = new MovieClip();
		...
		public function lvis() {
			addChild(lvis1);
		}
		...
		public function loadFirstTime(e:Event):void {
			lvis1.addChild(loader);
			var myEffect:FlashEff = new FlashEff();
			myEffect.showTransitionName = "com.jumpeye.flashEff.symbol.squareEffect.FESSquareScale";
			this.addChild(myEffect);
			myEffect._targetInstanceName = "lvis1";
		}
	}
}

I'm kinda knew to AS3 and classes.
Re: Add flashEff to dynamically created MC with Actionscript
August 14, 2008 08:24AM
aigarinsh

You are very close. You can find the example you're looking for inside the attached zip archive

This is the code you can find in class file:

package 
{
	import flash.display.Loader;
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.net.URLRequest;
	
	/**
	* ...
	* @author Daniel Demian
	*/
	public class Ivis extends MovieClip 
	{
		public var lvis1:MovieClip = new MovieClip();

		/**
		 * Contructor
		 */
		public function Ivis() {
			addChild(lvis1);
			loadImage();
		}

		/**
		 * Loads the image
		 */
		private function loadImage():void
		{
			var request:URLRequest = new URLRequest("image.jpg")
			var loader:Loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded)
			loader.load(request);
		}
		
		/**
		 * Image complete handler
		 * @param	evt The event object dispatched
		 */
		private function imageLoaded(evt:Event):void
		{
			this.lvis1.addChild(evt.currentTarget.loader);
			applyEffect();
		}
		
		/**
		 * Apply effect on the 1vis target
		 */
		private function applyEffect():void {
			var myEffect:FlashEff = new FlashEff();
			myEffect.showTransitionName = "com.jumpeye.flashEff.symbol.squareEffect.FESSquareScale";
			this.addChild(myEffect);
			myEffect.target = this.lvis1;
		}

	}
	
}
Attachments:
open | download - example.zip (249.5 KB)
Re: Add flashEff to dynamically created MC with Actionscript
August 14, 2008 09:11AM
Thank you very much! I thought it had to be something really simple as just replacing myEffect._targetInstanceName = "lvis1"; with myEffect.target = this.lvis1;
Re: Add flashEff to dynamically created MC with Actionscript
August 14, 2008 10:22AM
You're right ...
if you pass target_instanceName that should be the real instanceName not the name of the reference to your MoviClip.

To set the instanceName for an Mc you have to do something like this :

lvis1.name = "lvis1"


B)-
Sorry, you do not have permission to post/reply in this forum.