1 Reply Latest reply on Dec 11, 2007 5:39 AM by Newsgroup_User

    Motion Tween Problem

    cks_cropper
      Hi all, new here. Just looking for help with my code below. The 'Night' rectangle is a black rectangle, then with a blue ('Day') rectangle overlayed ontop of it. I want the 'Day' rectangle to ease out to just leave the black rectangle there. I have been messing around with this code for ages and cannot figure out what is wrong. Any ideas??

      Thanks
      CKS

      quote:

      import mx.transitions.Tween;
      import mx.transitions.easing.*;
      this.createEmptyMovieClip("night", 8);
      Night();
      this.createEmptyMovieClip("dayTween", 9);
      Day(dayTween, 100);
      new Tween(dayTween, "_alpha", Soft.easeOut, 0, 100, 1, true);
      function Night() {
      mainMovie.lineStyle(1, 0x000000, 100);
      mainMovie.beginFill(0x000000, 100);
      mainMovie.moveTo(0, 0);
      //draw the building 
      mainMovie.lineTo(550, 0);
      mainMovie.lineTo(550, 200);
      mainMovie.lineTo(0, 200);
      mainMovie.lineTo(0, 0);
      }
      function Day(target_mc:MovieClip, fillAlpha:Number):Void {
      with (target_mc) {
      mainMovie.lineStyle(1, 0x3399FF, 100);
      mainMovie.beginFill(0x3399FF, fillAlpha);
      mainMovie.moveTo(0, 0);
      //draw the building 
      mainMovie.lineTo(550, 0);
      mainMovie.lineTo(550, 200);
      mainMovie.lineTo(0, 200);
      mainMovie.lineTo(0, 0);
      endFill();
      }
      }

        • 1. Re: Motion Tween Problem
          Level 7
          Two things: you need to define mainMovie as a var, and also not reference it
          in your Day function. Change your code as follows: insert

          var mainMovie = this;

          right before you create your first clip.

          Then remove mainMovie references from Day(), so it is:

          function Day(target_mc:MovieClip, fillAlpha:Number):Void {
          with (target_mc) {
          lineStyle(1, 0x3399FF, 100);
          beginFill(0x3399FF, fillAlpha);
          moveTo(0, 0);
          //draw the building
          lineTo(550, 0);
          lineTo(550, 200);
          lineTo(0, 200);
          lineTo(0, 0);
          endFill();
          }
          }

          It'll work now. As a matter of convention, function names do not begin with
          capital letters - class names do.

          --
          Dave -
          Head Developer
          http://www.blurredistinction.com
          Adobe Community Expert
          http://www.adobe.com/communities/experts/