dro Posted March 13, 2016 Share Posted March 13, 2016 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. Link to comment Share on other sites More sharing options...
Carl Posted March 13, 2016 Share Posted March 13, 2016 Please see EaseLookup in docs: https://www.greensock.com/asdocs/com/greensock/easing/EaseLookup.html Link to comment Share on other sites More sharing options...
dro Posted March 14, 2016 Author Share Posted March 14, 2016 Thank you! That is really helpful! What about customEase or ease with parameters? Or colorTransform for example? Still have to write my own wrapper? Link to comment Share on other sites More sharing options...
Carl Posted March 14, 2016 Share Posted March 14, 2016 Yes if you want to format string values into objects you will need to do your own parsing. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now