Flash FPS

  • shepa006
  • Born
  • Born
  • shepa006
  • Posts: 2

Post 3+ Months Ago

I hope I am posting this in the right area. I am new to Ozzu.

I am looking for a way to change the frames per second rate in flash when the user rolls over an object. Ideally I would have six objects (buttons, or whatever you think would work best) that changed the speed; three different speeds in one direction and three speeds that reverse the direction. My original thought was that it would be something simple like changing the alpha (_alpha = 75;), but I don’t know what the fps term would be.

Thanks All.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Welcome to OZZU. As you see we do have a Flash forum specifically for questions like this. I moved it here for you. Hope it didn't confuse you.
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

You can't adjust the FPS rate through actionscript like that. Only in the settings can you do that. There are a few possible things you can do here, but that all depends on what exactly you are trying to achieve.

These methods are....

1) Extend the length of the tweens so they are shorter or longer

2) Use setInterval() (Flash MX and up only) coupled with nextFrame(); (or prevFrame();) to create a faux frame rate.

3) Use actionscript to move the object.
  • barrax
  • Newbie
  • Newbie
  • barrax
  • Posts: 12
  • Loc: Southampton, UK

Post 3+ Months Ago

Quote:
2) Use setInterval() (Flash MX and up only) coupled with nextFrame(); (or prevFrame() to create a faux frame rate


the functions i use are these:

Code: [ Select ]
stop();
function playfps(){
//params = (funcion name,delay,target movieclip);
    setInterval(playAndLoop,1000,this);
}

function playAndLoop(mc){
    mc.nextFrame();
    if(mc._currentframe == mc._totalframes){
        mc.gotoAndStop(1);
    }
}
playfps();
  1. stop();
  2. function playfps(){
  3. //params = (funcion name,delay,target movieclip);
  4.     setInterval(playAndLoop,1000,this);
  5. }
  6. function playAndLoop(mc){
  7.     mc.nextFrame();
  8.     if(mc._currentframe == mc._totalframes){
  9.         mc.gotoAndStop(1);
  10.     }
  11. }
  12. playfps();
  • emile
  • Newbie
  • Newbie
  • emile
  • Posts: 5
  • Loc: london

Post 3+ Months Ago

barrax wrote:
Quote:
2) Use setInterval() (Flash MX and up only) coupled with nextFrame(); (or prevFrame() to create a faux frame rate


the functions i use are these:

Code: [ Select ]
stop();
function playfps(){
//params = (funcion name,delay,target movieclip);
    setInterval(playAndLoop,1000,this);
}

function playAndLoop(mc){
    mc.nextFrame();
    if(mc._currentframe == mc._totalframes){
        mc.gotoAndStop(1);
    }
}
playfps();
  1. stop();
  2. function playfps(){
  3. //params = (funcion name,delay,target movieclip);
  4.     setInterval(playAndLoop,1000,this);
  5. }
  6. function playAndLoop(mc){
  7.     mc.nextFrame();
  8.     if(mc._currentframe == mc._totalframes){
  9.         mc.gotoAndStop(1);
  10.     }
  11. }
  12. playfps();



Hi, setInterval is great but can also cause problems if you dont use clearInterval to manage its presence. I always use the following when using setInterval.

Code: [ Select ]
stop();
function playfps(){
//params = (funcion name,delay,target movieclip);
        clearInterval(_root.mysetinterval )
    _root.mysetinterval = setInterval(playAndLoop,1000,this);
}
  1. stop();
  2. function playfps(){
  3. //params = (funcion name,delay,target movieclip);
  4.         clearInterval(_root.mysetinterval )
  5.     _root.mysetinterval = setInterval(playAndLoop,1000,this);
  6. }


You may want to read up on setInterval, if you dont store a reference to it (in my example _root.mysetInterval) you could end up with a permant loop you cant get rid off. You will notice that i call clearInterval with the _root.mysetinterval, this is to avoid a memory leak where by calling setInterval again leaves any previous setIntervals running.

I had a screensaver using 78mb of system memory after running through the night because of not tidying up the setInterval.


you might also want to add the clearInterval as below

Code: [ Select ]
         if(mc._currentframe == mc._totalframes){
                clearInterval(_root.mysetinterval )
        mc.gotoAndStop(1);
    }
  1.          if(mc._currentframe == mc._totalframes){
  2.                 clearInterval(_root.mysetinterval )
  3.         mc.gotoAndStop(1);
  4.     }




Another problem with setInterval is when setting them within a movieClip that is removed from the score. If you set an interval and store a reference to it within a movieclip and then kill/remove that movieclip you also remove any chance of clearing the interval from running. Always clear any intervals you have running before removing a movieclip from the score. Its very difficult to debug cos you dont realise its a setinterval is causing problems.
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Emile: Good tips I didn't even think of mentioning. I remember running into these issues when I was first learning setInterval(), it drove me mad!
  • emile
  • Newbie
  • Newbie
  • emile
  • Posts: 5
  • Loc: london

Post 3+ Months Ago

took me 2 days to realise it was the setinterval existing from the previous incarnation of the movieclip that was doing weird stuff to my text. :x
  • shepa006
  • Born
  • Born
  • shepa006
  • Posts: 2

Post 3+ Months Ago

thanks all. i am reading up and learning about the setinterval thanks to your suggestions.

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 9 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.