Hello.
I'm returning Flash developer. Abandoned AS3 like 5 years ago, but there's a new project entirely in Flash.
Also I never used TweenMax before. (only caurina)
my question is how to translate JSON to TweenMax correctly?
there's standart syntax :
public static function from(target:Object, duration:Number, vars:Object):TweenMax
and it works fine when I use it like that from AS3
TweenMax.from(mc, 4, { x: -100, alpha:0, ease: Back.easeOut.config(1.7) } );
no surprises.
But I have specific task to load animation instructions from JSON. And I've already made a little test:
This example works fine:
json object =
{"alpha": 0,"x": -100,"rotation":-100,"scaleX":0}
TweenMax.from(mc, 4, JSON.parse(json));
It works pretty good. I was happy to see such fast and forward instructions conversion to TweenMax properties.
But then there's a need to specify ease.
"ease":"Back.easeOut.config(1.7)" doesn't work
even "ease": "Back.easeOut"
I'm not talking about custom ease for now. But we will also need this.
That's all understandable
inside TweenLite.as _Init there's a code
if (vars.ease is Ease) {
_ease = (vars.easeParams is Array) ? vars.ease.config.apply(vars.ease, vars.easeParams) : vars.ease;
so it's clear that <string> can not be straightly converted to ease type. Also there are additional parameters like config(1.7) and strings can not be translated to those functions.
Keywords like "x", "alpha", "rotation" translated correctly because they have numeric values. But "easeType" can't be recognized that way.
So how to solve this? I believe if I start my own string to ease converter I will be lost on the way. Maybe there's an other intentional usage?
Please help me to translate pure json to TweenMaxVars.
// sorry for poor english.
/// if somebody need this. I can upload json file. but it's pretty simple actually.