Jump to content
Search Community

Tweening MC's in an Array

Cyrael test
Moderator Tag

Recommended Posts

I've been racking my brain on this one. I have an array of movie clips and am trying to tween them out based on their position in the array.

 

var navArray:Array = new Array(mc1, mc2, mc3);
TweenLite.to(navArray[0], 0.5, {x:50, y:50, scaleX:50});

 

Each time I try and do this, I get 13 instances of this error:

 

ReferenceError: Error #1069: Property scaleX not found on String and there is no default value.

at com.greensock::TweenLite/init()

at com.greensock::TweenLite/renderTime()

at com.greensock.core::SimpleTimeline/renderTime()

at com.greensock::TweenLite$/updateAll()

 

Regardless of what the final tween property is, it claims it is the error. So, if I remove everything but the x property it claims that 'Property x not found...'.

 

Any ideas? Is this a casting issue? I am hoping this is something simple, but I need some help!

Link to comment
Share on other sites

Sounds like you're trying to tween a String instead of the actual object/MovieClip/Sprite. That's like if your name was "Bob" and I told your name to walk 5 steps instead of telling you (the person) to walk 5 steps. So in your code, what do mc1, mc2, and mc3 refer to? Are they just the names of your MovieClips or are they references to the actual MovieClips? Feel free to post a super-simple example FLA that we can publish and see the errors (zip it first).

Link to comment
Share on other sites

They are the instance names of the movie clips on the stage.

Below is the full code. The implementation is really strange as we are trying to emulate an interface for an on-wall device that uses a linear carousel design with 5 objects visible on screen that change position and size relative to what is selected.

 

import com.greensock.*

var navArray:Array = new Array(mc1, mc2, mc3, mc4, mc5, mc6, mc7, mc8, mc9); //mc1-9 are the instance names of objects on the stage.
const pos0X:Number = -200;
const pos0Y:Number = 78;
const pos0Scale:Number = 0.25;

const pos1X:Number = -150;
const pos1Y:Number = 40;
const pos1Scale:Number = 0.37;

const pos2X:Number = 10;
const pos2Y:Number = 0;
const pos2Scale:Number = 0.67;

const pos3X:Number = 249;
const pos3Y:Number = 40;
const pos3Scale:Number = 0.37;

const pos4X:Number = 366;
const pos4Y:Number = 78;
const pos4Scale:Number = 0.25;


init();

function init():void
{
navArray[0].x = pos0X;
navArray[0].y = pos0Y;
navArray[0].scaleX = pos0Scale;
navArray[0].scaleY = pos0Scale;

navArray[1].x = pos1X;
navArray[1].y = pos1Y;
navArray[1].scaleX = pos1Scale;
navArray[1].scaleY = pos1Scale;

navArray[2].x = pos2X;
navArray[2].y = pos2Y;
navArray[2].scaleX = pos2Scale;
navArray[2].scaleY = pos2Scale;

navArray[3].x = pos3X;
navArray[3].y = pos3Y;
navArray[3].scaleX = pos3Scale;
navArray[3].scaleY = pos3Scale;

navArray[4].x = pos4X;
navArray[4].y = pos4Y;
navArray[4].scaleX = pos4Scale;
navArray[4].scaleY = pos4Scale;


}



function navLeft(e:MouseEvent):void
{
var theFirst:String = navArray.shift();
navArray.push(theFirst);
trace(theFirst + " is shifted");
trace(navArray);
tweenItLeft();
}

function navRight(e:MouseEvent):void
{
var theLast:String = navArray.pop();
navArray.unshift(theLast);
trace(theLast + " is popped.");	
trace(navArray);
tweenItRight();

}

function tweenItRight():void
{
TweenLite.to(navArray[0], 0.5, {x:pos1X, y:pos1Y, scaleX:pos1Scale});
}

function tweenItLeft():void
{

}

Link to comment
Share on other sites

without seeing a working example I think the culprit lies in here:

 

 

function navLeft(e:MouseEvent):void

{

vartheFirst:String = navArray.shift();

navArray.push(theFirst);

trace(theFirst + " is shifted");

trace(navArray);

tweenItLeft();

}

 

function navRight(e:MouseEvent):void

{

var theLast:String = navArray.pop();

navArray.unshift(theLast);

trace(theLast + " is popped.");

trace(navArray);

tweenItRight();

 

}

 

 

you are pushing popping and shifting Strings in your navArray. I imagine something you are doing is putting a String value at navArray[0]

 

I'd start there.

 

best,

 

Carl

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