1 Reply Latest reply on Jul 30, 2007 7:40 AM by kglad

    Actionscript Help Needed

      Hello-To start off im making a game banner in which there is a crying baby and in order to make him happy you need to feed him (excited yet?). Above his head there are randomly rotating food items which you can ciick on to feed the baby and depending on what you feed him the "happiness meter" will go up or down. Now i currently have the right script which generates random food items from an array via the attachMovie function and when you click on the food item it performs the "feeding" animation. My dillema comes in getting the script to distinguish between foods that add to the happines meter and foods that detract from it. Just cant seem to figure out a way to get the script to tag a food "bad" or "good". I have pasted my script below. Any help would be much appreciated, I really need this, its for my job!


      import mx.transitions.Tween;
      import mx.transitions.easing.*;

      var happiness:Number = 0;
      //var foodCount:Number=0;
      //var maxHappy:Number = 5;

      var getNextFood:Number;

      function randomRange(min, max) {
      var multiplier:Number = max-min+1;
      return Math.floor(Math.random()*multiplier+min);

      food_arr = new Array("pizza", "cauli", "shroom", "burger", "eggplant", "cookie", "radish");

      function getFood() {
      var foodMC:MovieClip = _root.attachMovie(food_arr[randomRange(0, 6)], "food", this.getNextHighestDepth);
      scalex = new Tween(foodMC, "_xscale", Bounce.easeOut, 0, 100, .5, true);
      scaley = new Tween(foodMC, "_yscale", Bounce.easeOut, 0, 100, .5, true);
      alphaChange = new Tween(foodMC, "_alpha", Strong.easeOut, 30, 100, .5, true);
      foodMC._x = 200;
      foodMC._y = 200;
      //getFoodINT=setInterval(getFood, 5000);
      foodMC.onPress = function() {
      ChangeY = new Tween(foodMC, "_y", Regular.easeOut, 200, 350, .5, true);
      alphaChangeReverse = new Tween(foodMC, "_alpha", Strong.easeOut, 100, 0, 1, true);
      scalex2 = new Tween(foodMC, "_xscale", Bounce.easeOut, 100, 30, .5, true);
      scaley2 = new Tween(foodMC, "_yscale", Bounce.easeOut, 100, 30, .5, true);

      happiness = happiness+20;
      happiness_txt.text = happiness+"%";
      getNextFood = 20;


      this.onEnterFrame = function() {

      if (getNextFood<=0) {
      getNextFood = 6;// Or however many frames you want to wait
      } else {
      if (happiness>=100) {