Solved

I NEED TO INPROVE THE CODE ON A MOVIECLIP, TO CONTROL ITS PLAYING SPEED!!

Posted on 2006-11-10
2
159 Views
Last Modified: 2012-05-05
Hi!

I am using this code on a movieClip to make it go from a certain frame to another (backwards or forward) depending on a global variable value. I set the global variable value by pressing buttons.
It works great!

Now: I need to control the playing speed of the movieClip, just by changing a value number directly on the code.
I believe that a 'setInterval' will work, but I don't know exactly where or how.

Can you help me?

Thanks!
Alejandro


CODE:
=============================
// This one goes on the root frame 1. It sets the global variable.
_global.destframe=1

//This one goes on the movieClip that plays backwards or forward, depending on the global variable value.
onClipEvent (enterFrame) {
      if (this._currentframe<_global.destframe) {
            this.nextFrame();
      } else if (this._currentframe>_global.destframe) {
            this.prevFrame();
      }
}
==============================
0
Comment
Question by:alexnexus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
blockage1 earned 500 total points
ID: 17918960
You can use setInterval but you don't need to - in fact its better not to as setIntervals can easily get out sync with the frame update.

I'd also move your destframe property out of the global scope - otherwise you'll only ever be able to control one movieclip.

A simple solution might look like this...

CODE:
=============================
// this goes on the first frame of the movieclip
destframe = 1;
speed = 1; // higher = faster, lower = slower
frameNumber = 1;

function onEnterFrame () :Void
{
     if (_currentframe < destframe) {
          frameNumber += speed;
     } else if (_currentframe > destframe) {
          frameNumber -= speed;
     }
  trace( frameNumber );
     gotoAndStop( Math.round( frameNumber ) );
}
=============================

0
 

Author Comment

by:alexnexus
ID: 17940423
Thanks!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question