A Flash Developer Resource Site

+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Junior Member
    Join Date
    Feb 2002
    Posts
    13
    Hello,

    I modified a simple frame counter to display the frame count not in frames but in secs. Based on 24 frames a sec.

    /:FrameCount24 = z;
    z = _root._currentframe;
    z = z/24;


    That works fine. I can see the secs displayed counting up as the playhead moves along. The thing I don't like is that the counter displays the seconds like this:

    3.8333333333333

    I would only like to be seeing this:

    3.8 or 3.833

    Suggestions?

    Thanks in Advance,
    Mike

  2. #2
    Member
    Join Date
    Mar 2001
    Location
    Lisbon, Portugal
    Posts
    64
    hi,


    try this
    /:FrameCount24 = z;
    z = _root._currentframe;
    z = Math.round (z/24);


    trolljanz

  3. #3
    Junior Member
    Join Date
    Feb 2002
    Posts
    13

    Smile

    Hey thanks for the reply trolljanz,

    Your suggestion worked great. The seconds tick off just right. I didn't know about the use of the "Math.round". I always learn something new when I visit FK. This place rocks!

    Now that I'm seen the "Math.round" in action, I'm starting to wonder if you can use it to display more of the seconds. Before I had two many numbers, now I'm wondering how you bring a few back. So what I see displayed is something like:

    3.8 or 3.833 (But nothing more)

    instead of just "3".

    Just wondering.
    I go read about "Math.round" now.
    Mike

  4. #4
    Member
    Join Date
    Jan 2002
    Location
    Venice, CA
    Posts
    77
    if you want to show digits out to the hundredths position (x.xx), try this:

    z=framerate;
    z=int(z*100);
    z/=100;

    this basically multiplies the huge float number that you have, multiplies it by 100 (thus moving the decimal point two places to the right) converts it to an integer (hacks off everything beyond the decimal) and then divides the result by 100, which in turn moves the decimal back two places to the right, giving you a nice pretty number with only tenths and hundedth past the decimal point.

    snarf,
    brian.


  5. #5
    Junior Member
    Join Date
    Feb 2002
    Posts
    13
    Thanks for the reply monogrey. You understand what I want the final secs to look like. Your discription is great, except I'm having trouble figuring out exactly the whole actionscript. I'm trying to apply your action code. I'm not getting it to work. Here is what I've got that works:

    /:FrameCount24 = z;
    z = _root.movie._currentframe;
    z = z/24;

    OR...

    /:FrameCount24 = z;
    z = _root._currentframe;
    z = Math.round (z/24);

    Now I'm trying to add your comments. I don't think I'm supposed to combine these like this. I'm trying to understand how to read your code... "framerate", is that to be left alone or am I to replace that with my frame rate that's 24fps.

    /:FrameCount24 = z;
    z = _root.movie._currentframe;
    z = z/24;
    z = framerate
    z = int(z*100);
    z/=100;

    I have also tried ( cause I like guessing i guess)

    /:FrameCount24 = z;
    z = _root.movie._currentframe;
    z = framerate
    z = int(z*100);
    z/=100;

    Thanks,
    Mike

  6. #6
    Member
    Join Date
    Jan 2002
    Location
    Venice, CA
    Posts
    77
    in order to make this work in your context just take my last two lines of code (the only lines of code that really do anything) and tack them onto the code that you already have.
    So, once everything's said and done, your script should look like so:

    /:FrameCount24 = z;
    z=_root._currentframe;
    z=z/24;
    z=int(z*100);
    z/=100;

    but see, I have a big problem with how this looks...
    it's just a bunch of lines constantly changing the value of z.

    let's see if we can clean this up a bit...

    /:FrameCount24=z;
    z=(int((_root.currframe/24)*100)/100);

    there. that's better. does the same thing, but with 60% less lines of code.

    cheers,
    brian.

  7. #7
    Junior Member
    Join Date
    Feb 2002
    Posts
    13
    I'm laughing at your post. Clever!

    I was wonder if all that "z"ing related to each other. I figured it did and was wonder if it wasgetting quite out of control. Then you come in and clean it up... nice.

    You know us artist, good in visual, poor in math.

    Thanks again Brian for your help. I'll go test it out!
    Mike

  8. #8
    Junior Member
    Join Date
    Feb 2002
    Posts
    13
    Sweet, Sweet, Sweet!!! Many Thanks monogrey!

    I used this and it works great:

    /:FrameCount24 = z;
    z = (int((_root.movie._currentframe/24)*100)/100);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts




Click Here to Expand Forum to Full Width


HTML5 Development Center