Jump to content
GreenSock

mrEmpty

Timeline from XML

Recommended Posts

Hello.

 

I am loading a lot of RGB values in from an XML and storing them in an XML List:

 

xmlContent = event.target.content.colour;

 

Each colour tag contains three sub tags, for RGB:

 

<colour>
 <red>147</red>
 <green>223</green>
 <blue>184</blue>
</colour>

 

Which I access with:

 

xmlContent[i].blue

etc etc

 

What I need to do is tween through the values in that list, updating three public vars and using an onUpdate send those numbers out to my DMX controller. In the past I've used something like:

 

playHead.append(new TweenMax(this, 2, {rred:xmlContent[j].red, ggreen:xmlContent[j].green, bblue:xmlContent[j].blue}));

 

which throws no errors but doesn't work either.

 

A more complete chunk of code to look at:

 

private function rainbow(event:MouseEvent):void {
  trace('rainbow called');
  var playHead:TimelineMax = new TimelineMax({onUpdate:rainbowTween});
  for (var j:int = 0; j < xmlContent.length(); j++) {
   playHead.append(new TweenMax(this, 2, {rred:xmlContent[j].red, ggreen:xmlContent[j].green, bblue:xmlContent[j].blue}));
   //TweenMax.to(this, 2, {rred:xmlContent[j].red, ggreen:xmlContent[j].green, bblue:xmlContent[j].blue, onUpdate:rainbowTween});
  }
 }

 private function rainbowTween():void {
  trace('.');
  for(var i:int = 0; i < 100; i++){
  if((i - 1) % 3 == 0){
	   // every 3rd number starting with 1
 MainDMX.sendDmx(rred, i);
   }
   if((i - 2) % 3 == 0){
	   // every 3rd number starting with 2
 MainDMX.sendDmx(ggreen, i);
   }
    if((i - 3) % 3 == 0){
	   // every 3rd number starting with 3
 MainDMX.sendDmx(bblue, i);
   }
  }
 }

 

So my question is how can I tween through my numbers, taking 2 seconds to tween between the values? I can post the entire code if that would help but it's huge :)

Link to comment
Share on other sites

One thing I noticed while tracing out fred in the rainbowTween function was it traced NaN, but if I trace them in the rainbow function I get the correct numbers from the XML.

 

EDIT: I fixed the NAN issue. My problem is on my tween I'm adding the numbers instead of tweening from one number in the XML to the next.

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