A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [F8] Listener for Movie Clip Rollover

  1. #1
    Member
    Join Date
    Feb 2007
    Posts
    56

    [F8] Listener for Movie Clip Rollover

    I working on a diagram of a skeleton.

    For each bone in the body, I've got three movie clips, the image of the bone, the name of the bone and a line pointing to the bone. When the viewer rolls over the bone or the text clps they change colour and the line becomes visible.

    This now works great, thanks to input from forum members.

    Trouble is, my code for each bone runs to a few lines of script :

    PHP Code:
    // ------------thigh ---------\\
    this.thightext_mc.onRollOver = function() {
        
    appear("thigh");
    };
    this.thightext_mc.onRollOut = function() {
        
    fade("thigh");
    };
    this.thigh_mc.onRollOver = function() {
        
    appear("thigh");
    };
    this.thigh_mc.onRollOut = function() {
        
    fade("thigh");
    }; 
    For all the bones I'm doing that means quite a lot of code - though I've done hallf of them already! Is there a way I can cut down the code with a listener to detect which clip is being rolled over (and rolled out of) and extract the name of the bone from the movie clip name, as a string, and send that string to various functions ('appear' and 'fade')?

  2. #2
    Senior Member
    Join Date
    Nov 2004
    Location
    Toronto, Canada
    Posts
    194
    if you had an array of all the bone names you could loop through at the start adding the code
    Code:
    for(1=0;i<bones.length;i++)
    {
    var clip = _root[bones[i]][bones[i] + "_mc"];
    clip.onRollOver = function(){appear(bones[i])}
    ...same for others
    }

  3. #3
    Member
    Join Date
    Feb 2007
    Posts
    56
    Thanks, Ogrell. I'll try that.

  4. #4
    Member
    Join Date
    Feb 2007
    Posts
    56
    Thanks very much, but I'm afraid that doesn't do anything. I move the mouse around the stage, over the graphics (movie clips) and nothing happens. The mouse arrow stays as an arrow - doesn't even turn into a hand.

    I need Flash to recognise which movie clip I've rolled over and then send part of the movie clips name to the functions.

    Any other suggestions?

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