dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: problem with buttons and functions

  1. #1
    Junior Member
    Join Date
    Aug 2007
    Posts
    3

    [ FIXED ] problem with buttons and functions

    ok, so I have an invisible button symbol acting as my hit area and on a layer under that, I have a movieclip with with 5 sub-movieclips inside it as my buttons. I wrote this messy code and it works perfectly:

    Code:
    button1.onRollOver = function() {
    movie1.submovie1.gotoAndPlay("_over");
    movie1.submovie2.gotoAndPlay("_over");
    movie1.submovie3.gotoAndPlay("_over");
    movie1.submovie4.gotoAndPlay("_over");
    movie1.submovie5.gotoAndPlay("_over");
    }
    	
    button1.onRollOut = function() {
    movie1.submovie1.gotoAndPlay("_out");
    movie1.submovie2.gotoAndPlay("_out");
    movie1.submovie3.gotoAndPlay("_out");
    movie1.submovie4.gotoAndPlay("_out");
    movie1.submovie5.gotoAndPlay("_out");
    The problem is, I have a lot of buttons and I don't wanna have to keep writing basically same code for every button and for every button state (onRollOver, onRollOut, onPress, onRelease, etc), so I wrote a function to trim it down:

    Code:
    function myButton( x1:Button, y1:MovieClip) : Void {
    	 x1.onRollOver = function() {
    		y1.gotoAndPlay("_over");
    		trace(x1);                 //just for testing
    		trace(y1);                 //purposes
    	}
    	x1.onRollOut = function() {
    		y1.gotoAndPlay("_out");
    	}
    }
    
    myButton(button1, movie1.submovie1);
    myButton(button1, movie1.submovie2);
    myButton(button1, movie1.submovie3);
    myButton(button1, movie1.submovie4);
    myButton(button1, movie1.submovie5);
    The problem I'm getting with this is when I trace y1 ( movie1.submovie[x] ), only the last submovie gets traced and that's the only animation that appears when I hover over the mouse and the output screen shows it getting traced over and over everytime I hover over.

    Does anyone know what's going on or have a solution?
    Last edited by DrFlipside; 08-11-2007 at 12:04 PM. Reason: fixed problem

  2. #2
    Junior Member
    Join Date
    Aug 2007
    Posts
    3

    [solved]

    nm, I just figured it out.

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