Access presets via AS3

Posted by bhobman 
Access presets via AS3
August 25, 2009 07:34PM
Question Pt 1:
Is there a way to access presets through FlashEff2Code without having to manually enter the settings?
Example - using 'Emerge' pattern I want to use the 'Color2Center' preset. Since it looks like the preset prop only accepts numbers, I would assume it would be something like:
showEffect:FETEmerge = new FETEmerge();
showEffect.preset = 2;

There was another post that said a preset list should be forthcoming. Couldn't find it.

Thanks for any help.
Re: Access presets via AS3
August 26, 2009 06:58AM
Yes, you are right, the presets are numbers, some patterns have 4 presets some have 55 presets so it's better if you look in the panel first.
To use a pattern from code you should do something like this:

import FlashEff2Code;
import com.jumpeye.flashEff2.symbol.slide.FESSlide;
var effect:FlashEff2Code = new FlashEff2Code();
addChild(effect);
var showEffect:FESSlide = new FESSlide();
showEffect.preset = 3
effect.showTransition = showEffect;
effect._targetInstanceName = pic_mc.name;

I could have write all the parameters from code but since I want them to be the default value I did not mention them at all.
Hope this helps, let me know if you run into any more problems,

-Ionut



Edited 1 time(s). Last edit at 08/26/2009 08:51AM by Ionut.
Re: Access presets via AS3
August 26, 2009 05:08PM
Thanks Ionut, but still doesn't seem to be working. I have a dynamic text field w/ embedded font on stage called 'myText'. I'm going off the presets found here: Online Test Drive.

Assuming the following of the Text Emerge Pattern:
Preset 'None' = 0
Preset 'Default' = 1
Preset 'Color2Center' = 2
etc etc....

where:
import FlashEff2Code;
import com.jumpeye.flashEff2.text.emerge.FETEmerge;
myText.text = "The quick brown fox jumps over the lazy dog with some stuff in it's mouth blah blah";
var effect:FlashEff2Code = new FlashEff2Code();
addChild(effect);
var showEffect:FETEmerge = new FETEmerge();
showEffect.preset = 3;  //Would expect '3' to be 'Color2CenterDown'
effect.showTransition = showEffect;
effect.target = myText;
effect.show();

I've changed the preset numbers around all over the place and nothing seems to change.

Also.. is there a list pattern presets and their corresponding numbers? Would be pretty helpful.
Re: Access presets via AS3
August 27, 2009 06:35AM
Hi,

Try this:

import FlashEff2Code;
import com.jumpeye.flashEff2.text.emerge.FETEmerge;
myText.text = "The quick brown fox jumps over the lazy dog with some stuff in it's mouth blah blah";
var effect:FlashEff2Code = new FlashEff2Code();
addChild(effect);
var showEffect:FETEmerge = new FETEmerge();
showEffect.preset = 3;//Would expect '3' to be 'Color2CenterDown'
showEffect.groupDuration = 0.5
effect.showTransition = showEffect;
effect.target = myText;
effect.show();

Now, what you did wrong was you have set the groupDuration to 1.3, actually that was the default value, meaning that each character would be animate for 1.3 seconds. This would be fine for a smaller text but in your case the text was big and the entire animation was only 2 seconds long. So you didn't actually see it animate in a way or another.
Now, if you set the group duration to 0.5 (like in my example) or set the tweenDuration to 5 you'll see each word animate in it's own way and you'll see a difference between each preset.
I know this can get confusing so if it does, please feel free to ask anything,

-Ionut
Re: Access presets via AS3
August 27, 2009 06:56PM
Yeah... I should have thought of that. Whoops. Thanks!

Out of curiosity.. I would expect larger number = longer duration. Why is 0.5 longer than 1.3 for this prop?
Re: Access presets via AS3
August 28, 2009 07:55AM
0.5 sec is not longer than 1.3.
0.5 represents the time that the animation uses to animate every group of characters (depending what you selected could be letters, words, line, etc).
If you want each of the chracters to animate for a longer time you'd have to set the group duration to, let's say 1.5, and the tweenDuration to 5 and then you'd see a difference.
Now, to answer your question,
0.5 is not longer than 1.3 sec, the entire animation is still 2 seconds long only that, while the groupDuration is set to 0.5, each group of animation has it's delay. The math behind this is: (tweenDuration-groupDuration)/characters (I think).

Hope this helps,

-Ionut.
Re: Access presets via AS3
September 01, 2009 02:12PM
It took me a while to figure this out, but here's what I understand about the 'preset' property:

- Some effects have multiple preset effects which use the same value. For example, if you look at the preset effects for FESAlpha, you'll see that the AlphaHorizClose and HorizCloseSmooth preset effects both use a preset value of 11. It appears that the 'preset' property itself contains its own set of properties which aren't accessible via ActionScript. Among these is (in some cases) the direction of the animation (left, right, up, down, diagonal left down...).

- Some effects don't have a 'preset' property for any of the effect's presets. FESDesertIllusion is one, and FESDisc is another. It seems that these preset effects rely only on the effect properties which are accessible via ActionScript.
Re: Access presets via AS3
September 01, 2009 02:52PM
Thanks Terry. Yeah... it just doesn't seem to work quite right. I'd expect the preset to be just that... a preset that works just like it would in the flasheff panel. I think I'm going to just do it the old fashioned way... manually set up all props via actionscript. At least I can be sure of the effect then.
Sorry, you do not have permission to post/reply in this forum.