A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: 'get time' ---> Timeline

  1. #1
    Member
    Join Date
    Jan 2001
    Posts
    66
    Hi, I wanna make some sort of 'horizontal clock': Picture a bar from 0-24 where the actual time sets the position on the bar.

    Example: if its 12:00h the indicator on the bar is in the middle, at 23:00 it's almost at the end when it reaches 24:00 the indicator starts over again.

    I want to make a bar for the hours and 1 for the minutes.

    Can anyone help me with some actionscript to set this up?

    Thanks!

  2. #2
    Senior Member
    Join Date
    Jun 2001
    Posts
    2,943
    Assuming you have your hours and minutes in two variables 'myHour' and 'myMin'...

    The trick would be to convert each of those into a percentage and use that to scale a bar.

    For the hours, myHours = 0 to 23, so 23 equals the bar at 100%.

    Draw a horizontal bar and turn it into a movie clip. Size it so that it corresponds to the maximum size (24:00), and give it an instance name ('barHour').

    You can set the scale of the bar movie clip to 50% (for example)using:
    Code:
    setProperty("barHour",_xscale,50);
    So to alter it dynamically, you could use:
    Code:
    setProperty("barHour",_xscale,(myHour/23*100));
    That ought to work. And just do the same for the minutes bar.

    Oh, and just change _xscale to _yscale for a vertical bar.

    You could combine the bars inside a movie clip and use onClipEvent to have them refresh every frame cycle.

  3. #3
    Member
    Join Date
    Jan 2001
    Posts
    66
    Tnx,

    But what i try to accomplish is a bar (or timeline) with an indicator:

    example:
    02:00 would look like this

    --|----------------------

    12:00 like this

    ------------|------------

    I can build that with keyframes with actionscript wich point to wich keyframe is should play.

  4. #4
    Senior Member
    Join Date
    Jun 2001
    Posts
    2,943
    OK. That wasn't clear, but I understand what you mean.

    It is still the same, more or less, to the way I described - except the position of the clip is set instead of the scale.

    Create a movie clip that corresponds to your indicator.

    For the sake of argument, let's say you want to move it between 0 pixels and 250 pixels on the x axis for 0 - 23 hours.
    Code:
    setProperty("barHour",_x,(myHour/23*250));
    Do the same kind of thing for the minutes hand.

    And put them all inside movie clips, because then you really can design them to work from 0 pixels without having to worry whereabouts on screen they are placed.

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