A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: "For, Else" Statement help

  1. #1
    Senior Member
    Join Date
    May 2006
    Posts
    119

    "For, Else" Statement help

    I have a faily simple question. I want to know how to write an "If Else" for a mouse click. I can write an hittest, but im not to sure of the mouse clicks. this is what I want to make shorter
    ---------------------------------------------
    _root.q1_immark.onRelease = function (){
    _root.gotoAndPlay("Q2_Good");

    }
    _root.q1_nicetomeetyou.onRelease = function (){
    _root.gotoAndPlay("Q2_Bad");
    }

    _root.q1_wherearewe.onRelease = function (){
    _root.gotoAndPlay("Q2_Bad");
    }

    since two actions have the same outcome, I figure I can consolodate some code.
    also can I declare MCs as clickable buttons in a single line?


    thanks in advance

    Mark

  2. #2
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    Code:
    _root.q1_nicetomeetyou.onRelease = _root.q1_wherearewe.onRelease = function ()
    { 
    	_root.gotoAndPlay("Q2_Bad");
    };
    I've seen this technique used more often when combining two mouse events to the same button. Never tried it for two different buttons, but it seems to work fine. It's most commonly used to define onRelease and onReleaseOutside in one function like so..

    Code:
    myButton.onRelease = myButton.onReleaseOutside = function ()
    {
    	//do something;
    };
    Last edited by DallasNYC; 06-10-2006 at 08:55 PM.

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