I’m currently trying to adapt some sample code and have hit a snag when trying to replace hardcoded coordinates with a variable.
The following sample code works:
TweenMax.to(sp,
5,
{bezierThrough:[{x:250,y:100},{x:50,y:200},{x:500,y:200}],
onUpdate:drawme,
onUpdateParams:[sp]});
But when I try to replace the bezier points with a variable, I get a runtime error saying property 0 of Shape doesn’t exist. sp is of type Shape. (Full error below).
var centralLinePoints:Array = new Array();
for (var i:int = 0; i < data.nodes.length; i++)
{
var foo:Object = data.nodes[i].data.abc;
var bar:Number = data.nodes[i].data.def;
if (foo != null)
{
centralLinePoints.push({x: bar, y: foo});
}
}
TweenMax.to(sp,
5,
{bezierThrough:[centralLinePoints],
onUpdate:drawme,
onUpdateParams:[sp]});
I’ve found this documentation: http://www.greensock.com/as/docs/tween/com/greensock/plugins/BezierThroughPlugin.html but I’m not sure what type is implied.
Full error:
ReferenceError: Error #1069: Property 0 not found on flash.display.Shape and there is no default value.
at com.greensock.plugins::BezierPlugin/init()[C:[…]\greensock-as3\com\greensock\plugins\BezierPlugin.as:99]
at com.greensock.plugins::BezierThroughPlugin/onInitTween()[C:[…]\greensock-as3\com\greensock\plugins\BezierThroughPlugin.as:68]
[sorry about the formatting]
As the third param to
TweenMax.toyou pass an object with 3 properties. The first is theArrayof objects havingxandyas properties.Try to remove the square parenthesis: