A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: Rotating Clock Hands help!!

  1. #1
    Junior Member
    Join Date
    Sep 2004
    Posts
    11

    Rotating Clock Hands help!!

    Ok I'm fairly new to flash, made alot of ad banners and basic transitional stuff, very little actionscript.

    Due to go on the actionscripting stage of the official courses next month.

    However been trying to figure out how to make 2 clock hands rotate independently around an axis.

    Don't need it to tell the actual time its more to demonstrate the feeling of time flying by, so it'll be the hands spinning round this axis.

    Tried using movie clip transition in 45degree steps, but it kind of jiggles around and doesn't stick to the axis!!

    Any help would be appreciated, thanks in advance

  2. #2
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    Make you sure put the pivot point of the hands at the co-ordinates 0,0. As you said you don't need a clock but here's one anyway. You can change it for your needs just by going hours._rotation += 30 or the like.
    Attached Files Attached Files

  3. #3
    Junior Member
    Join Date
    Sep 2004
    Posts
    11
    Ahh thanks very much I'll have a tinker with that and see what I can do with it

  4. #4
    Living Proof mave_the_rave's Avatar
    Join Date
    May 2002
    Location
    East Dulwich
    Posts
    1,006
    If using tweens , put your hour and minute hands on different layers
    If someone tells you it can't be done,
    it's probally because they don't know how.

  5. #5
    Junior Member
    Join Date
    Sep 2004
    Posts
    11
    Yeah I have that already, the problem I'm finding is fixing one end point to the central axis, it kind of jiggles around the centre point.

    Maybe its my understanding of the math.

  6. #6
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    The easiest thing to do is make your clock hand into a movie clip, with the pivot point at 0,0. Place it on the stage, call it hour_mc and use this code
    Code:
    this.onEnterFrame = function() {
       hour_mc._rotation += 30;
    }

  7. #7
    Junior Member
    Join Date
    Sep 2004
    Posts
    11
    Hmm this is where my lack of actionscript knowledge in general is letting me down.

    Think I've done it correctly

    http://www.maliceguild.net/clock.fla

    Theres the FLA. But it doesn't rotate.

    Can't wait to go on this course, sure it'll all become shockingly clear

    Thanks again for all the help so far

  8. #8
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    That doesn't seem to be a valid link

  9. #9
    Junior Member
    Join Date
    Sep 2004
    Posts
    11
    Hmm ok try this one, thats definitely there

    http://www.maliceguild.net/clok2.fla

  10. #10
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    You need to name the Instance of the movie clip so Flash can recognise it at run-time.

    Click on the MC, in the properties panel put hour_mc in the box where it says <Instance Name>.

  11. #11
    Junior Member
    Join Date
    Sep 2004
    Posts
    11
    Haha!!

    Success, now I understand why all the tutorials been ploughing through mention naming instances of Movie Clips as THE thing to know

    Thanks very much!!

  12. #12
    Junior Member
    Join Date
    Sep 2004
    Posts
    11
    Ok thats working fine now, I thought that just adding another instance of that 'arm' and repeating the actionscript underneath:

    Something like:

    this.onEnterFrame = function() {hour_mc._rotation += 30;}

    this.onEnterFrame = function() {hour1_mc._rotation += 40;}
    Would play both instances of the movie clip together.

    But it only plays the bottom one. Is this more to do with the 'this' part of the onEnterFrame command?

    As that 'this' command seems very specific to that particular element.

    Hence it only controlling the one part.

  13. #13
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    'this' in this case is just referring to the timeline it's on. It's just something to attach the onEnterFrame function to, you can also use _root or a MC for example.

    The reason that it's only doing the bottom one is because you're overwriting the first function. You just need to put both statements in the same function
    Code:
    this.onEnterFrame = function() {
    	hour_mc._rotation += 30;
    	hour1_mc._rotation += 40;
    }

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