just wanted to share

Posted by nabbs1 
just wanted to share
February 05, 2010 06:56PM
I see a lot of requests for "random" effect use. I had a similar need but instead of random I just made an array then counted up on each slide advance. At first I did a even odd check and had it alternating between two patterns. This got boring fast so now I have 5 effects in use and they change with each slide of content. Not random but still good for what I needed. I will post the dirty code here and maybe my idea will help others find their own solution.

It would be easy to set up more effects and just randomize the array.

I have a hide() call in another part of the swf. After it hides I have it fire the show. I got this idea from the old flashEff tut on the usage of xml.

Peace
-Todd


import FlashEff2Code;
import com.jumpeye.Events.FLASHEFFEvents;


// Performs blur transitions based on one single default preset.
// Preset: default
import com.jumpeye.flashEff2.symbol.blur.FESBlur;
import com.jumpeye.flashEff2.symbol.squareEffect.FESRoundedSquareScale;
import com.jumpeye.flashEff2.symbol.desertIllusion.FESDesertIllusion;
import com.jumpeye.flashEff2.symbol.photo.FESPhoto;
import com.jumpeye.flashEff2.symbol.slide.FESSlide;
import com.jumpeye.flashEff2.symbol.alpha.FESAlpha;

var myEffect:FlashEff2Code = new FlashEff2Code();
myEffect.addEventListener(FLASHEFFEvents.TRANSITION_END, endTrans);

myEffect.showDelay = .5;

addChild(myEffect);





//////////// starting effect //////////////
myEffect.addEventListener(FLASHEFFEvents.TRANSITION_START, effectStarting);
function effectStarting(evt:FLASHEFFEvents):void {
	trace ("effect start")
}
///////// start hides //////////////
var hideEffect:FESRoundedSquareScale = new FESRoundedSquareScale();
hideEffect.preset = 9;
hideEffect.squareWidth = 35;
hideEffect.squareHeight = 35;
hideEffect.cornerRadius = 25;
hideEffect.groupDuration = 1.2;
hideEffect.tweenDuration = 1.8;
hideEffect.tweenType = "Strong";
hideEffect.easeType = "easeInOut";
myEffect.hideTransition = hideEffect;

var hideEffect2:FESDesertIllusion = new FESDesertIllusion();
hideEffect2.waveSize = 80;
hideEffect2.wavesIntensity = 80;
hideEffect2.blurQuality = 1;
hideEffect2.smooth = true;
hideEffect2.tweenDuration = 1.5;
hideEffect2.tweenType = "Quadratic";
hideEffect2.easeType = "easeNone";

var hideEffect3:FESBlur = new FESBlur();
hideEffect3.blurX = 25;
hideEffect3.blurY = 25;
hideEffect3.blurQuality = 2;
hideEffect3.tweenDuration = 1.5;
hideEffect3.tweenType = "Strong";
hideEffect3.easeType = "easeInOut";

var hideEffect4:FESAlpha = new FESAlpha();
hideEffect4.preset = 9;
hideEffect4.gradientWidth = 50;
hideEffect4.tweenDuration = 0.5;
hideEffect4.tweenType = "Strong";
hideEffect4.easeType = "easeNone";

var hideEffect5:FESSlide = new FESSlide();
hideEffect5.preset = 1;
hideEffect5.positionX = 50;
hideEffect5.positionY = 50;
hideEffect5.blurX = 50;
hideEffect5.blurY = 50;
hideEffect5.blurQuality = 2;
hideEffect5.tweenDuration = 0.5;
hideEffect5.tweenType = "Back";
hideEffect5.easeType = "easeInOut";


//**////**////**////**////**////**//
//**////**////**////**////**////**//
//**////**////**////**////**////**//

var showEffect:FESRoundedSquareScale = new FESRoundedSquareScale();
showEffect.preset = 9;
showEffect.squareWidth = 35;
showEffect.squareHeight = 35;
showEffect.cornerRadius = 25;
showEffect.groupDuration = 1.2;
showEffect.tweenDuration = 1.8;
showEffect.tweenType = "Strong";
showEffect.easeType = "easeInOut";
myEffect.showTransition = showEffect;

var showEffect2:FESDesertIllusion = new FESDesertIllusion();
showEffect2.waveSize = 80;
showEffect2.wavesIntensity = 80;
showEffect2.blurQuality = 1;
showEffect2.smooth = true;
showEffect2.tweenDuration = 1.0;
showEffect2.tweenType = "Quadratic";
showEffect2.easeType = "easeNone";
//**//
var showEffect3:FESBlur = new FESBlur();
showEffect3.blurX = 25;
showEffect3.blurY = 25;
showEffect3.blurQuality = 2;
showEffect3.tweenDuration = 1.5;
showEffect3.tweenType = "Strong";
showEffect3.easeType = "easeInOut";
//**//
var showEffect4:FESAlpha = new FESAlpha();
showEffect4.preset = 10;
showEffect4.gradientWidth = 50;
showEffect4.tweenDuration = 0.5;
showEffect4.tweenType = "Strong";
showEffect4.easeType = "easeNone";
//**//
var showEffect5:FESSlide = new FESSlide();
showEffect5.preset = 1;
showEffect5.positionX = 50;
showEffect5.positionY = 50;
showEffect5.blurX = 50;
showEffect5.blurY = 50;
showEffect5.blurQuality = 2;
showEffect5.tweenDuration = 0.5;
showEffect5.tweenType = "Back";
showEffect5.easeType = "easeInOut";
//**//

myEffect._targetInstanceName = "content__"
myEffect.hideAutoPlay = false;


////////////

var numberFrame:Number = 1;
// When the "hide" transition ends, start the show effect again.
function endTrans(evt:FLASHEFFEvents):void {
	
	trace("END TRANS")
	if (myEffect.currentTransitionType == "hide") {
		content__.alpha = 0;
		content__.nextFrame();
		numberFrame++
		counter++;
		trace("frame "+numberFrame);
		
		
		/*if(numberFrame%2 != 0){
			trace("odd")
			//myEffect.showTransition = showEffect;
			myEffect.hideTransition = hideEffect;
			//myEffect.show();
		} else {
			trace("even")
			myEffect.hideTransition = hideEffect2;
			//myEffect.showTransition = showEffect2;
			//myEffect.show();
		}*/
		
		if (counter < 0){
			counter = myFESarray.length-1;
		} else if (counter > (myFESarray.length-1)) {
			counter = 0;
		}
		//trace("========")
		//trace(myFESarray[counter]);
		//trace("========")
		switch (myFESarray[counter]) {
			
			case "showEffect":
			myEffect.showTransition = showEffect;
			
			myEffect.show();
			
			trace("====showEffect====")
			myEffect.hideTransition = hideEffect;
			break;
			
			case "showEffect2":
			myEffect.showTransition = showEffect2;
			myEffect.show();
			
			trace("====showEffect2====")
			myEffect.hideTransition = hideEffect2;
			break;
			
			case "showEffect3":
			myEffect.showTransition = showEffect3;
			myEffect.show();
			trace("====showEffect3====")
			myEffect.hideTransition = hideEffect3;
			break;
			
			case "showEffect4":
			myEffect.showTransition = showEffect4;
			myEffect.show();
			trace("====showEffect4====")
			myEffect.hideTransition = hideEffect4;
			break;
			
			case "showEffect5":
			myEffect.showTransition = showEffect5;
			myEffect.show();
			trace("====showEffect5====")
			myEffect.hideTransition = hideEffect5;
			break;
			
			default:
			myEffect.showTransition = showEffect;
			myEffect.show();
			trace("====DEFAULT====")
		}
		
	}
	//myEffect.removeAll();
	
}
/// mine ///
var myFESarray:Array = new Array();
myFESarray.push("showEffect");
myFESarray.push("showEffect2");
myFESarray.push("showEffect3");
myFESarray.push("showEffect4");
myFESarray.push("showEffect5");

var counter:int=0;

function TestingTest() {
	
	
}



Edited 2 time(s). Last edit at 02/05/2010 07:21PM by nabbs1.
Sorry, you do not have permission to post/reply in this forum.