Jump to content
Search Community

Type Coercion failed: cannot convert 1 to Array.

andytwoods test
Moderator Tag

Recommended Posts

Hi,

I've a simple Tween:

TweenMax.to(this, 1, {alpha:.2, repeat:1});

 

I get this error:

 

TypeError: Error #1034: Type Coercion failed: cannot convert 1 to Array.
    at com.greensock::TweenLite/_initProps()[C:\Users\Andy\Desktop\xperiment\classes\com\greensock\TweenLite.as:551]
    at com.greensock::TweenLite/_init()[C:\Users\Andy\Desktop\xperiment\classes\com\greensock\TweenLite.as:522]
    at com.greensock::TweenMax/render()[C:\Users\Andy\Desktop\xperiment\classes\com\greensock\TweenMax.as:959]
    at com.greensock.core::SimpleTimeline/render()[C:\Users\Andy\Desktop\xperiment\classes\com\greensock\core\SimpleTimeline.as:166]
    at com.greensock.core::Animation$/_updateRoot()[C:\Users\Andy\Desktop\xperiment\classes\com\greensock\core\Animation.as:546]
 
TweenMax.to(this, 1, {alpha:.2, repeat:[1]});
works though.
 
Perhaps I am being silly, but I think repeat:1 is the correct way to specify repeat. 
 
Cheers,
Andy.
Link to comment
Share on other sites

Nope, you're not being silly - repeat:1 is the correct way. I'm not able to reproduce that issue - can you please post a very simple FLA that demonstrates the problem? And what version of TweenMax are you using? I'd definitely recommend using the latest one.

Link to comment
Share on other sites

I BET this relates to these hacks I had to introduce because of Air to IOS compilation 'pain in the assness': http://forums.greensock.com/topic/6664-multiple-errors-in-flash-builder-47/

 

I'll have a quick look to see if errors arise near my hacks and report back.

cheers,

Andy.

 

PS Just downloaded Tween* the other day in reponse to IOS silliness.

Link to comment
Share on other sites

yep (in tweenLite). Error at that long If statement

 

 

protected function _initProps(target:Object, propLookup:Object, siblings:Array, overwrittenProps:Object):Boolean {
            var p:String, i:int, initPlugins:Boolean, plugin:Object, a:Array;
            if (target == null) {
                return false;
            }
            for (p in vars) {
                if (p in _reservedProps) {
                    a = vars[p]
                    if (p === "onStartParams" || p === "onUpdateParams" || p === "onCompleteParams" || p === "onReverseCompleteParams" || p === "onRepeatParams") if (a) {
                        i = a.length;
Link to comment
Share on other sites

and this is how I should have done it:

 

for (p in vars) {
				if (p in _reservedProps) {
					if (p === "onStartParams" || p === "onUpdateParams" || p === "onCompleteParams" || p === "onReverseCompleteParams" || p === "onRepeatParams"){
						a = vars[p]
						if (a) {
							i = a.length;
							while (--i > -1) {
								if (a[i] === "{self}") {
									a = vars[p] = a.concat(); //copy the array in case the user referenced the same array in multiple tweens/timelines (each {self} should be unique)
									a[i] = this;
								}
							}
						}
					}
					

 

 

My bad after all.  Sorry bout that. 

cheers,
Andy.

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