Jump to content
Search Community

[BezierThrough] different result [solved]

nokiaddt test
Moderator Tag

Recommended Posts

Class with a bezierThrough function

package home.here {
import com.greensock.TweenMax;
import com.greensock.data.TweenMaxVars;

public class MyClass{
	public function MyClass() {}

	public function bezierThrough (target:Object, toXY:String):void {
		var xyArray:Array = toXY.split(",");
		var tmpArray:Array = new Array(xyArray.length / 2);

		var moveItVars:TweenMaxVars = new TweenMaxVars();
		for(var i:int = 0; i < xyArray.length / 2; i ++) {
			tmpArray[i] = new Object();
			tmpArray[i].x = xyArray[i * 2];
			tmpArray[i].y = xyArray[i * 2 + 1];
		}

		TweenMax.to(target, 5, moveItVars);
	}
}

 

main mxml with an image which location is (70,300)

<?xml version="1.0" encoding="utf-8"?>




 

The motion of image should be start from (70,300) -> (130,0) -> (330,300), but the result is (70,300) -> (200,300) -> (400,600).

Can you tell me where the problem is?

Thanks a lot.

Link to comment
Share on other sites

sorry for wrong code.

actually I have that code like

   public function bezierThrough (target:Object, toXY:String):void {
        var xyArray:Array = toXY.split(",");
        var tmpArray:Array = new Array(xyArray.length / 2);

        var moveItVars:TweenMaxVars = new TweenMaxVars();
        for(var i:int = 0; i < xyArray.length / 2; i ++) {
           tmpArray[i] = new Object();
           tmpArray[i].x = xyArray[i * 2];
           tmpArray[i].y = xyArray[i * 2 + 1];
        }
        moveItVars.bezierThrough(tmpArray)
        TweenMax.to(target, 5, moveItVars);
     }

and hope (or not) you can find the same result like what I said.

Link to comment
Share on other sites

I try to execute the code by my home computer using Flash Builder 4.

And I got the same result. The executable code is ...

Main.mxml

<?xml version="1.0" encoding="utf-8"?>
				   xmlns:s="library://ns.adobe.com/flex/spark" 
				   xmlns:mx="library://ns.adobe.com/flex/mx">






home.nokiddt.BezierThrough.as

package home.nokiaddt {
import com.greensock.TweenMax;
import com.greensock.data.TweenMaxVars;

public class BezierThrough {
	public function BezierThrough() {

	}
	public function bezierThrough (target:Object, toXY:String):void {
		var xyArray:Array = toXY.split(",");
		var tmpArray:Array = new Array(xyArray.length / 2);

		var moveItVars:TweenMaxVars = new TweenMaxVars();
		for(var i:int = 0; i < xyArray.length / 2; i ++) {
			tmpArray[i] = new Object();
			tmpArray[i].x = xyArray[i * 2];
			tmpArray[i].y = xyArray[i * 2 + 1];
		}
		moveItVars.bezierThrough(tmpArray)
		TweenMax.to(target, 5, moveItVars);
	}
}
}

Link to comment
Share on other sites

It looks like the problem is that you're passing Strings instead of Numbers as the values. Remember, TweenMax interprets Strings as relative values, not absolute. So just cast your values as Numbers and you'll be fine:

 

tmpArray[i].x = Number(xyArray[i * 2]);
tmpArray[i].y = Number(xyArray[i * 2 + 1]);

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...