Jump to content
Search Community

How can I initiate through xml

flasp test
Moderator Tag

Recommended Posts

I trying to initiate a timeLineMax-tweening through xml, but cant make it work (see snippet);

 

Im getting these errors, that Im not sure what to make of.

1084: Syntax error: expecting colon before rightbrace.

1084: Syntax error: expecting identifier before rightbrace.

 

How do initiate the tween though xml.

 

 

import com.greensock.*
import com.greensock.easing.*
var animXML:XML= x
var tween=animXML.animate.text();
var tl:TimelineMax = new TimelineMax();
tl.append(TweenLite.to(green, 2, {tween}));

Link to comment
Share on other sites

you need to find away to parse that string value and create an object.

 

what you are doing is creating a string that looks like a TweenLite vars object, but really isn't.

 

what you are doing, appears to flash like this:

 

tl.append(TweenLite.to(green, 2, {"x:400,y:300"}));

 

flash is trying to create an Object out of a string to pass into TweenLite and can't do it.

 

Fortunately others have tried to do this.

I edited the code from this discussion: http://stackoverflow.com/questions/1510 ... pt-3-0-as3

 

the following will work with your approach. no guarantees for support of additional features.

 

 

import com.greensock.*
import com.greensock.easing.*
var animXML:XML= 


var serializedObject:String = animXML.animate.text();
var tween:Object = new Object()

var contentWithoutBraces:String = serializedObject.substr(serializedObject.indexOf('{') + 1)
contentWithoutBraces = contentWithoutBraces.substr(0, contentWithoutBraces.lastIndexOf('}'))

var propertiesArray:Array = contentWithoutBraces.split(',')

for (var i:uint = 0; i {
   var objectProperty:Array = propertiesArray[i].split(':')

   var propertyName:String = objectProperty[0]
   var propertyValue:String = objectProperty[1]

   tween[propertyName] = Object(propertyValue)
}


var tl:TimelineMax = new TimelineMax();
tl.append(TweenLite.to(green, 2, tween));

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...