A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Scripting button states

Hybrid View

  1. #1
    Junior Member
    Join Date
    Jun 2002
    Location
    Wellington, New Zealand
    Posts
    6
    I'm trying to make some simple little buttons made of cubes that spin depending on their state

    basically the cube is static until mouseover, where it changes colour and spins.
    on mouseoff I want it to revert to the original colour and slow-down to a stop (rather than the default instant stop flash applies on mouseoff)

    already sitting in my library are the static, spinning, and slow-down animations ready to go.

    my question is, how do I script the button to show the required animation for the corresponding state?

    I'm somewhat of a scripting pleb :/

    any help appreciated
    thanks for your time

  2. #2
    Junior Member
    Join Date
    May 2002
    Location
    Canadian Wilderness
    Posts
    24
    Can you not simply swap the static graphic for the movie of the animated revolving cube in the over state of your button?

    I can further if your not sure what I mean.

  3. #3
    Junior Member
    Join Date
    Jun 2002
    Location
    Wellington, New Zealand
    Posts
    6
    showing the spinning cube isn't the issue
    showing the slow-down after the mouse moves off the button is the part I can't work out

  4. #4
    Junior Member
    Join Date
    Jun 2002
    Posts
    5
    You can solve that problem by using the tell("target") { } command. I would show an example of code, but I don't know how the tags work. If someone tells me, I can show you.
    [EDIT]tell(target) is depreciated. so, you can use the "dot notation," such as
    Code:
    on(rollOut) {
        instanceName.gotoAndPlay(1);
     }
    [Edited by alex_rocks on 06-28-2002 at 09:02 PM]

  5. #5
    Senior Member
    Join Date
    Sep 2001
    Posts
    178
    Hi,
    This problem is rather complicated, as the exact state of the movieclip playing (the spinning cube) has to determine where the slowdown occurs. The only way that I can see to do it accurately is to have a movieclip that has the following setup:

    First Frame: Static state of cube, "stop()" action
    Second Through n-th Frame: Spinning state of cube
    N-th Frame: code:
    Code:
    if (hit) {
    gotoAndPlay (2);
    }
    N+1 through M frame: Slow down animation (from N-th frame state)

    And then the following actions on the movieclip:

    Code:
    onClipEvent (mouseMove) {
        if (!hit && this.hitTest (_root._xmouse, _root._ymouse, true)) {
            this.play()
            hit = 1;
        } else if (hit && !this.hitTest (_root._xmouse, _root._ymouse, true)) {
            hit = 0;
        }
    }
    This will make the cube spin for as long as it needs to, just make sure that the loop from frame n to frame 2 is smooth, and then when the user rolls off, it will continue to spin at the same speed until the playhead reaches frame n, where it will realize that it is time to slow down and will keep playing, eventually reaching the static state again. Hope this helps, and for an example, post the .fla of what you are working with, and I will see what I can do. Chuckles8421

  6. #6
    Junior Member
    Join Date
    Jun 2002
    Location
    Wellington, New Zealand
    Posts
    6

    Smile

    by sheer dumb-luck, I managed to get it working

    the solution was not to script events to an object with behavior 'button', but to use an object with behavior 'movie clip' and then use tellTarget (as suggested above - thx) to script the movie to act like a button, thereby giving me more control over it's state at any one time.

    now it works perfectly

    big thanks to all who gave input, I hope I can return the favour one day


  7. #7
    The world goes - hm.. TheCaramella's Avatar
    Join Date
    Dec 2001
    Location
    Second door on the right, next to the ice bear
    Posts
    642
    Telltarget is dead and gone and has been for two versions now. Isn't there a board for Flash 4 here somewhere? That's where it belongs...

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