5 Replies Latest reply on Nov 19, 2006 12:32 PM by Newsgroup_User

    Actionscript doubt...

    Ricky2k7
      Simple question...

      I have this code on a object that's on the stage:

      on (press)
      {
      this.startDrag();
      obj1 = 0;
      }
      on (release)
      {
      stopDrag();
      if (eval(this._droptarget) == _root.area1)
      {
      this._x = _root.area1._x;
      this._y = _root.area1._y;
      obj1 = 1;
      }
      }

      And this code on the main timeline of the stage:

      if (obj1==1)
      {
      play();
      }

      Why doesn't the movie play?

      i tryed to use _global.obj1 = 1; but it doesn't work either :-S
      pleaaassseee heeeeeeelllllllpppppp!!!!
        • 1. Re: Actionscript doubt...
          Level 7
          if (eval(this._droptarget) == _root.area1) _root.play() ;

          ?

          you have nothing triggering the if statement in your main timeline... (do
          you?)

          JG



          "IndioDoido" <webforumsuser@macromedia.com> wrote in message
          news:ejl27b$qge$1@forums.macromedia.com...
          > Simple question...
          >
          > I have this code on a object that's on the stage:
          >
          > on (press)
          > {
          > this.startDrag();
          > obj1 = 0;
          > }
          > on (release)
          > {
          > stopDrag();
          > if (eval(this._droptarget) == _root.area1)
          > {
          > this._x = _root.area1._x;
          > this._y = _root.area1._y;
          > obj1 = 1;
          > }
          > }
          >
          > And this code on the main timeline of the stage:
          >
          > if (obj1==1)
          > {
          > play();
          > }
          >
          > Why doesn't the movie play?
          >
          > i tryed to use _global.obj1 = 1; but it doesn't work either :-S
          > pleaaassseee heeeeeeelllllllpppppp!!!!
          >


          • 2. Actionscript doubt...
            Ricky2k7 Level 1
            hey Jose...

            No, the onlything i have on the main timeline is this:

            if (obj1==1)
            {
            play();
            }

            What do i need to do, to trigger the if statement in my main timeline?
            • 3. Re: Actionscript doubt...
              Level 7
              Well, lets assume that all you are doing is on frame # 12. Your mc that you
              drag is instanced on frame # 12. When the playhead reaches frame #12 it is
              going to execute your code on the main time line once:

              if (obj1==1)
              {
              play();
              }

              at this point obj1 is not declared yet. Then when the user does the drag and
              drop, you execute your other code where you declare obj1, and that's it.
              finished.


              If you put some trace statement you will see the order of execution, ie:
              main timeline:

              trace("timeline 1: " + obj1) ;
              if (obj1==1)
              {

              trace("timeline 2: " + obj1) ;
              play();
              }
              trace("timeline 3: " + obj1) ;

              your object:
              on (press)
              {
              trace("startDrag: " + this._name) ;
              this.startDrag();
              obj1 = 0;
              }
              on (release)
              {
              trace("stopDrag: " + this._name) ;
              stopDrag();
              if (eval(this._droptarget) == _root.area1)
              {
              this._x = _root.area1._x;
              this._y = _root.area1._y;
              obj1 = 1;
              trace("stopDrag droptarget: " + obj1) ;
              }
              }

              you will get in the output:

              timelime 1: undefined
              timelime 3: undefined
              startDrag: yourobjectname
              stopDrag: yourobjectname
              stopDrag droptarget: 1


              Now lets assume that obj movieclip is on the main stage and not nested in
              another movieclip, what happens also is that you declare obj1 under your
              object so _root.obj.obj1 is different from _root.obj1

              You need to do two things.
              1:
              on your object when you declare obj1, you should declare it like,
              _root.obj1, so that it gets created in the timeline your object is. Then
              call a function like _parent.checkObj()

              code for obj:
              on (press)
              {
              this.startDrag();
              _root.obj1 = 0; //CHANGE
              }
              on (release)
              {
              stopDrag();
              if (eval(this._droptarget) == _root.area1)
              {
              this._x = _root.area1._x;
              this._y = _root.area1._y;
              _root.obj1 = 1; //CHANGE
              _parent.checkObj(); //ADDITION
              }
              }

              and in the timeline your code should look like:

              function checkObj() {
              if (obj1==1)
              {
              _root.play();
              }
              }


              "IndioDoido" <webforumsuser@macromedia.com> wrote in message
              news:ejmsq9$114$1@forums.macromedia.com...
              > hey Jose...
              >
              > No, the onlything i have on the main timeline is this:
              >
              > if (obj1==1)
              > {
              > play();
              > }
              >
              > What do i need to do, trigger the if statement in my main timeline?
              >


              • 4. Re: Actionscript doubt...
                Ricky2k7 Level 1
                Thanks alot Jose...
                The code works perfectly !!!!
                ;-) ;-) ;-) ;-) ;-) ;-)
                • 5. Re: Actionscript doubt...
                  Level 7
                  no problems :-)


                  "IndioDoido" <ricky2k7@gmail.com> wrote in message
                  news:ejo7q2$hkk$1@forums.macromedia.com...
                  > Thanks alot Jose...
                  > The code works perfectly !!!!
                  > ;-) ;-) ;-) ;-) ;-) ;-)