Solved

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

Posted on 2006-11-10
2
157 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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Embedded Video Download (Flash) 3 1,163
Adobe Flash Player - PPAPI plugin 6 720
Adobe Flash Player won't install on Windows 7 3 259
Virus or Outlook 2007 problem, how to tell? 8 88
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

830 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