• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • Last Modified:

Playing from one frame to another only

I have a movie clip which has a colour change over 100 frames. Depending on a percentage which is read in from a file, I want to animate the movie clip's colour changing by playing from one frame to another.

i.e. the old percentage is 20, the new one 80

=> play movie clip from frame 20 till frame 80

This has to all be done via actionscript, how do I do it?

0
GraemeScotland
Asked:
GraemeScotland
  • 3
1 Solution
 
henrywwCommented:
that's not too hard.

when u say read in from a file, what sort? xml or txt?
anyway i think u would no problem with reading the data ...

ok ... now ... , make a movieclip with all the different colors u have from frame 1 to 100; say ... name it "color" or whatever u like

have a variable currPercent=80; etc ...
then use a function to monitor changes

//example - root main timeline

//frame 1
var lastPercent;
var currPercent;

// checks the percent continuously
// the rate of moving is the same as the frame rate
_root.onEnterFrame = function () {
    // check for difference
   if (currPercent != lastPercent) {
     if (currPercent > lastPercent) {
     // a bigger percent
     _root.color.nextFrame();
     lastPercent++;
     } else {
     // a smaller percent
     _root.color.prevFrame();
     lastPercent--;
     }
   }
}

//frame X
//read ur file
if the percent is bigger than it will move the color movieclip from current position left to right (nextFrame())
if the percent is smaller than it will move from current position right to left (prevFrame()) until match.

see if this helps.

cheers
0
 
henrywwCommented:
the code is no good??
0
 
GraemeScotlandAuthor Commented:
Sorry mate, it didn't work, I ended up not being able to do it. There wasn't enough time in the timeline to do it effectively. I think it would have probably worked however, and since you're the only person who tried to help, the points are yours :-)
0
 
henrywwCommented:
oh really? why?? ....

well, if u need an working example, i can try and put it together quickly ...
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now