Jump to content
Search Community

I can't get this to work

dmcdowell test
Moderator Tag

Recommended Posts

I've looked at the getting started section, I've looked for a trouble shooting section, I've looked through the first 10 pages of results in this forum, and I still can't figure out why I can't get anything working.

 

I'm using CS3 and AS 2.0

 

The com folder is in the same folder as my FLA.

 

I have a mc called movie1, and this is the code I have:

import com.greensock.*;
import com.greensock.easing.*;

TweenLite.to(movie1, 1.5, {x:1000});

 

This should work, correct?

Link to comment
Share on other sites

in AS3 you need an _ (underscore) before all the properties like _x _y _alpha

 

so the code is simply

 

TweenLite.to(movie1, 1.5, {_x:1000});

 

If you go to http://www.greensock.com/tweenlite/ and look at the Interactive Demo - Tweening Basics you can toggle between as3 and as2 code previews.

 

The syntax for tween creation / control in the AS2 v AS3 versions is virtually identical except for this little _ issue, which only exists because AS3 removed the _ from all properties.

 

Also, from the top of my head, a majority if not all the code examples on the site here are going to be in AS3 as it is more current. The AS2 version works great though and yes some of us still are required to AS2 for banners and such.

 

welcome aboard

 

Carl

Link to comment
Share on other sites

Thanks Carl. I've now gotten it to work.

 

Now, another question. I want to do something like this:

ridingArray = new Array ("movie1","movie2","movie3");

for (i=0;i<3;i++){
TweenMax.to(ridingArray[i], 3, {colorTransform:{tint:0xff0000, tintAmount:0.5}, ease:Elastic.easeOut});
}

 

This won't work unfortunately, but I imagine you can see what I'm wanting to do. I have 300+ variables that I want to apply a color change to, so I need to do it in some sort of loop

Link to comment
Share on other sites

try removing the quotes in your array

 

ridingArray = new Array (movie1,movie2,movie3);

 

for (i=0;i

TweenMax.to(ridingArray, 3, {colorTransform:{tint:0xff0000, tintAmount:0.5}, ease:Elastic.easeOut});

}

 

 

Also, for an alternate approach you can try TweenMax.allTo which will automatically loop through an array of objects for you

This one 1 line of code replaces your loop

 

TweenMax.allTo(ridingArray, 3, {colorTransform:{tint:0xff0000, tintAmount:0.5}, ease:Elastic.easeOut});

 

notice how you just have to pass in the name of the array that includes all your objects that need to be tweened

Link to comment
Share on other sites

Thanks again, Carl.

 

Removing the quotes in the Array made it work no problem, but it presents another issue for me now.

 

Previously this is the type of structure I was using to change the color of a movieclip:

import com.greensock.*;
import com.greensock.easing.*;

var getProjection:LoadVars = new LoadVars();
getProjection.load("http://localhost/fedblog/election.php");

getProjection.onLoad = function() {

ridingNames = this.ridings.split("|");
libSupport = this.libSupport.split("|");
conSupport = this.conSupport.split("|");
ndpSupport = this.ndpSupport.split("|");
bqSupport = this.bqSupport.split("|");

	for(i=0;i<30; i++){

	var Lib:Number = libSupport[i];
	var Con:Number = conSupport[i];
	var NDP:Number = ndpSupport[i];
	var BQ:Number = bqSupport[i];

	var ridingArray:Array = [{PP:"Lib",Count:Lib, Colour:0xFF0000, lColour:0xFFB8B8},{PP:"Con",Count:Con, Colour:0x0000FF,lColour:0xB8B8FF},{PP:"NDP",Count:NDP, Colour:0xF0BB42,lColour:0xFBECCA},{PP:"BQ",Count:BQ, Colour:0x0FDAF0, lColour:0xBCF5FB}];
	ridingArray.sortOn("Count", Array.DESCENDING | Array.NUMERIC);
	currentRiding = "riding"+[i+1];

		if ((ridingArray[0].Count - ridingArray[1].Count) >= 7) {
			var my_color:Color = new Color(currentRiding);
			my_color.setRGB(ridingArray[0].Colour);
	        }	
}


 

I want to replace this code below, with a tweenlite class

 

var my_color:Color = new Color(currentRiding);
my_color.setRGB(ridingArray[0].Colour);

 

However, the naming rules I'm using for

currentRiding = "riding"+[i+1];

won't allow that.

 

Thoughts?

Link to comment
Share on other sites

try currentRiding = this["riding"+[i+1]];

 

if "this" doesn't work try _root

 

 

basically it says evaluate the expression and use it to refer to an object with that name

 

what you had before was just generating a String value that was the same as some object's name.

 

its weird to explain.

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