A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: function problem

  1. #1

    function problem

    I need a little help with a function i'm trying to create, i'm almost there but need that extra bit of expertise that i know you guys have got to help me out here!

    I have a few bits of code like the following which should really be placed in a function to streamline it:

    Code:
    if (targ == targetLots) {
    				setProperty(feedback.correctleft, _visible, true);
    				feedback.correctleft.alphaTo(100, 0.5, "linear");
    				feedback.correctleft.scaleTo(100, 2, "easeoutelastic");
    				feedback.correctleft.alphaTo(0, 0.5, "linear", 2);
    				feedback.correctleft.scaleTo(10, 0.5, "linear", 2);
    				whichone.alphaTo(100, 0.5, "linear", 2);
    			} else {
    				setProperty(feedback.correctright, _visible, true);
    				feedback.correctright.alphaTo(100, 0.5, "linear");
    				feedback.correctright.scaleTo(100, 2, "easeoutelastic");
    				feedback.correctright.alphaTo(0, 0.5, "linear", 2);
    				feedback.correctright.scaleTo(10, 0.5, "linear", 2);
    				whichone.alphaTo(100, 0.5, "linear", 2);
    			}
    i've tried to turn this into:

    Code:
    function giveAnswer(YesNo) {
    	setProperty(feedback[YesNo], _visible, true);
    	feedback[YesNo].alphaTo(100, 0.5, "linear");
    	feedback[YesNo].scaleTo(100, 2, "easeoutelastic");
    	feedback[YesNo].alphaTo(0, 0.5, "linear", 2);
    	feedback[YesNo].scaleTo(10, 0.5, "linear", 2);
    	whichone.alphaTo(100, 0.5, "linear", 2);
    }
    called by:

    Code:
    giveAnswer(correctleft);
    but i can't get it to work, i'm sure i'm pretty close to the answer, it's got something to do with square brackets or eval (i think). any ideas out there (he asked them knowingly!)

    thanks,
    dave.

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    you were close
    Code:
    feedback.correctleft._visible = false; 
    
    function giveAnswer(YesNo){
    path = feedback[YesNo]; 
    trace(path);
    // output - _level0.feedback.correctleft
    path._visible = true;
    };
    
    
    giveAnswer("correctleft");

  3. #3
    Marvellous! I was almost there!

    Cheers Dog!

    d.

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