Link to home
Start Free TrialLog in
Avatar of Karessa
Karessa

asked on

Movie Clip Speed

Hello:

I've been examining this tutorial for creating a class that effectively moves the objects associated with it randomly around the screen. The objects move at a slow speed, and what I don't understand is why they're moving slowly.

http://www.macromedia.com/devnet/flash/articles/mc_subclasses_v2_04.html

I'm creating a simple series of functions that moves an objects _x point across the screen. I'm not using classes and all my coding is done at the movie clip level. I understand that the default rate of 12 fps is making my object move so quickly that I can't see it. I want to understand the difference in speed between my functions and this class. Can someone briefly explain it to me?

Thanks!

Karessa
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

Hi Karessa,

for a smooth animation, use should set framerate of your swf to 25 fps for sure

and if you are using setinterval to call the function which is responsible for moving object's x or y.

then please understand this, whether you have been given a smaller interval time for function call but frame will be painted with the fps of the swf.

I would recommend set ur swf framerate to 25 fps
and
if setInterval is being used, set the interval time to 50 (50 miliseconds)

Rgds
Aneesh
Avatar of Karessa
Karessa

ASKER

Thanks for your comments, Aneesh, but my problem isn't that I need my animation to play more quickly. It's that it's already playing so fast that I can't see it! I need to slow it down somehow. I don't understand why the objects in the tutorial move slowly without a setInterval function???

Thanks again.
Karessa,

can you please upload your Sample FLA,
I assure that I can fix it and return you the fixed one in half an hour.

you may use http://www.yousendit.com to upload your file

Step1: just enter a dummy sender email address,
Step2: browse the file to upload
Step3: click send

it will upload and show the download link on next page
just copy and paste that link in the post.


Aneesh
I briefly looked at the example, and I was wondering what you are doing to change the velocity of the ball, becase that effects its speed.  If you changed a value in the velocity function of the ball somewhere, that could have affected the speed greatly.

As Aneesh said as well, the framerate is also important.
Avatar of Karessa

ASKER

Thanks to you both --

Aneesh, it's so nice of you to offer to fix it for me but I'm afraid that if I don't work through it I'll never learn it. Thanks again for offering. Maybe you or ritetek can help this way:

The code is now running at a beautiful speed, but only if I don't have a while loop in there that limits the distance that the x travels. I need the while loop or the function just keeps running and running! Here is my code. I can't upload the flash file because it's against company policy....sorry:


var stageRightBoundary:Number, stageLeftBoundary:Number, curtainVelocity:Number = 30;
//get the x and y positions for the curtains
var rightCurtainX = this.curtainOpening_mc.rightCurtain_mc._x;
var leftCurtainX = this.curtainOpening_mc.leftCurtain_mc._x;
//set boundary for stage
stageRightBoundary = rightCurtainX+401;
//set curtain edges to invisible
curtainOpening_mc.rightCurtainEdge_mc._visible = false;
curtainOpening_mc.leftCurtainEdge_mc._visible = false;
curtainOpening_mc.rightCurtainEdgeBack_mc._visible = false;
curtainOpening_mc.leftCurtainEdgeBack_mc._visible = false;


//
//
//
//
function moveCurtains() {
//THIS IS WHERE THE WHILE WOULD BE
//while (rightCurtainX < stageRightBoundary){
      curtainOpening_mc.rightCurtainEdge_mc._visible = true;
      curtainOpening_mc.leftCurtainEdge_mc._visible = true;
            curtainOpening_mc.rightCurtain_mc._x = rightCurtainX;
            curtainOpening_mc.rightCurtainEdge_mc._x = rightCurtainX-85;
            curtainOpening_mc.leftCurtain_mc._x = leftCurtainX;
            curtainOpening_mc.leftCurtainEdge_mc._x = leftCurtainX+500;
            //curtainOpening_mc.leftCurtainEdge_mc._x = leftCurtainX + 85;
            rightCurtainX = rightCurtainX+curtainVelocity;
            leftCurtainX = leftCurtainX-curtainVelocity;
// } THIS WOULD END THE IF STATEMENT  
    }

//call curtain movement function upon entering movieclip frame
this.curtainOpening_mc.onEnterFrame = function() {
      moveCurtains();
      };




ASKER CERTIFIED SOLUTION
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Karessa

ASKER

Hello Aneesh

When I attached the functions to buttons instead of having them trigger onEnterFrame they worked much better! Thanks for trying to help me. I really appreciate it.

Karessa