dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Rubbing?

  1. #1
    Member
    Join Date
    Oct 2006
    Posts
    48

    Detecting mouse movements?

    Hello

    I need help pls with figuring out mouse actions that involve movement.

    1. Lets say I want to rub a lamp and make a genie appear. What codes do I need to detect when the mouse is clicked and dragged back and forth the lamp a few times and then the genie effect appears? (Uh, either movieclip or jump to frame??)

    2. I saw the slapping game where u drag ur curser and then the character slaps her enemy. What codes would I need?

    Thanks
    Last edited by humbuged; 09-09-2007 at 03:26 AM.

  2. #2
    Member
    Join Date
    Oct 2006
    Posts
    48
    Well, I came up with this for the rubbing thing

    hxxp://files-upload.com/files/492258/lamprub.fla

    Code:
    A_mc.onRollOver = function () {
        this._visible = false;
        B_mc._visible = true;
        rub = rub + 10;
        trace ("A-hide B-appear");
    };
    
    B_mc.onRollOver = function () {
        this._visible = false;
        A_mc._visible = true;
        rub = rub + 10;
        trace ("B-hide A-appear");
    };
    
    rub = 0; 
    
    if (rub < 100) {
        stop();
    };
    
    if (rub == 100) {
        gotoAndPlay("rubbed");
    };
    Everything works except for the rub varialble. The rub counter goes up everytime the hidden buttons are hit, but it doesnt jump to "rubbed" when it reaches 100.

    Would be nice if someone told me what I'm doing wrong

  3. #3
    Member
    Join Date
    Oct 2006
    Posts
    48
    Well, I got help from the kirupa forums. All I needed was a function that checks the rub variable again & again.

    Here's the results for all interested

    http://img169.imageshack.us/my.php?image=lamprubkf1.swf

    Code:
    A_mc.onRollOver = function() {
        this._visible = false;
        B_mc._visible = true;
        rub += 5;
        trace("A-hide B-appear");
        checks()
    };
    
    B_mc.onRollOver = function() {
        this._visible = false;
        A_mc._visible = true;
        rub += 5;
        trace("B-hide A-appear");
        checks()
    };
    
    bar.onEnterFrame = function() {
        this._xscale = rub;
    };
    
    rub = 0;
    
    stop();
    function checks() {
        if (rub>=100) {
            gotoAndPlay("rubbed");
        }
    }

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