10 Replies Latest reply on May 24, 2013 5:28 AM by Chris_1942

    Object interaction problem

    Chris_1942

      Hi there

      I suppose i should introduce myself My name is Chris and i'm currently making a project to do with the Korean conflict. I am a total noob at this and am bumbling along at a slow pace aha.

      Basically at the moment i have a rocket(movieclip) which moves with this code.

       

      onClipEvent (load){

      step=5;

      movieWith=550;

      movieHeight=380;

      }

      onClipEvent ( enterFrame ){

      if ( Key.isDown (Key.RIGHT) and this._x < movieWith ){this._x+=step;}

      if ( Key.isDown (Key.LEFT) and this._x >0){this._x-=step;}

      if ( Key.isDown (Key.UP) and this._y >0){this._y-=step;}

      if ( Key.isDown (Key.DOWN) and this._y <movieHeight){this._y+=step;}

      }

       

      I then want the rocket when it touches buttons to trigger a text box for each button to appear and then when the rocket moves away from the buttons for the text to disappear. I have been searching around but cannot find anything of use and was hoping someone in the community could help maybe.

       

      Thanks for taking your time to read this.

       

      Regards Chris

        • 1. Re: Object interaction problem
          Ned Murphy Adobe Community Professional & MVP

          You will need to incorporate a function that performs a hitTest of the rocket against all of the buttons each time the rocket is moved.  If a hitTest is detected, the elements associated with it are displayed, if not, they are hidden.

          1 person found this helpful
          • 2. Re: Object interaction problem
            Chris_1942 Level 1

            Hi Ned thanks for the reply.

             

            I have put this code but as i am ultra amateur i am getting errors.

            I have put this code on the movieclip where the text is needed to appear.

             

            onClipEvent(enterFrame) {

            if(Rocket1.hitTest(Firstpoint)}

               {

                   this.Firstpoint.text.gotoAndStop("27")

               }

             

            Frame 27 is where i have just randomely put the text to appear but i am receiving errors from the actionscript which i have wrote.

             

            Thanks

            • 3. Re: Object interaction problem
              Ned Murphy Adobe Community Professional & MVP

              If you are receiving errors, what are they?

               

              I do not know what "text" is relative to Firstpoint, but if it is an instance name of something you should probably change it so that it doesn't conflict with the text property

              1 person found this helpful
              • 4. Re: Object interaction problem
                Chris_1942 Level 1

                Yes Firstpoint is the instance name of the movieclip. I thought you had to put .text when reffering to an instance.

                The actual text that i want to pop up is just static text(unsure whether needs to be dynamic to load from AS) at frame 27. I am not sure whether i need to put this text at a particular frame or somehow code it to appear when the rocket interacts with the firstpoint movieclip.  Then when the rocket comes away from the movieclip i want the text to disappear. I hope i have been clear.

                 

                 

                Scene=Korea, layer=Pinpoints, frame=1, Line 2')' expected

                 

                Scene=Korea, layer=Pinpoints, frame=1, Line 1Statement block must be terminated by '}'

                 

                Scene=Korea, layer=Pinpoints, frame=1, Line 5Syntax error.

                 

                Thanks again for your time.

                • 5. Re: Object interaction problem
                  Ned Murphy Adobe Community Professional & MVP

                  You specify the text property when you are trying to manipulate the text within a textfield.  When refering to an instance, you do just that, refer to the instance... text inside a textfield is not an instance.  If Firstpoint is not a textfield, it probably doesn't have a text property.

                   

                  IF you want to control a static textfield's visibility, you cannot do that directly because you cannot target the textfield directly.  You need to place it inside a movieclip and control the movieclip's visibility.

                   

                  All of the errors you list are due to syntax issues.  Often if you solve the first the others are self-correcting (not always, but often).  I cannot say what the errors are since you are not indicating what the code is where the errors are indicated to be.

                  1 person found this helpful
                  • 6. Re: Object interaction problem
                    Chris_1942 Level 1

                    Sorry Ned i have got confused here. Must be frustrating you. I got muddled up as i have been working late. Apologies. So it would be make a movieclip from invisible to visible using hittest interacting with other movieclip (trigger)

                     

                    i Have put this code in the actions inside a movieclip called Firstpoint

                     

                    onClipEvent(enterFrame) {

                     

                    if(Rocket1.hitTest)(Firstpoint1945)}  //instance of movieclip of static text

                      {

                     

                           this.Firstpoint1945.gotoAndStop("27")

                     

                       }

                    Errors are .

                    Scene=Korea, layer=Pinpoints, frame=1, Line 4Statement must appear within on/onClipEvent handler

                    When the rocket approaches this movieclip i want it to show another movieclip(instance Firstpoint1945) which shows text i have written. I am not to sure if the code is right.

                    But now i think this, make a movieclip from invisible to visible using hittest with other movieclip (trigger), i think that code is void now. I suppose i need to look for a tutorial for this!

                    Thanks

                    • 7. Re: Object interaction problem
                      Chris_1942 Level 1

                      I have made the static text into a a movieclip. I messed up on the first post. They are not buttons they are shapes which are now movieclips.

                      I changed the static text into a movieclip and then placed it in inside the shape movieclip and have made it invisible.

                      What is the code for hittest to make the movieclip visible?

                      I know it would be     " firstpoint1945._visible=true; " but i mean the hittest code.

                       

                      Thanks

                      • 8. Re: Object interaction problem
                        Chris_1942 Level 1

                        FIXED

                         

                        Success. Just incase anyone else wants to know the solution. I put the movieclip inside the movieclip on the second name and named the frame. And put stop(); on the first frame.

                        Put this code into layer actionscript.

                         

                        onEnterFrame = function ()

                        {

                            if (_root.Symbol2.hitTest(_root.Rocket1))

                           

                                _root.Symbol2.gotoAndPlay("Firstpointtext");

                          stop;

                          }

                        • 9. Re: Object interaction problem
                          Chris_1942 Level 1

                          Ok I have made a second point. This is the code for it.

                           

                          onEnterFrame = function ()

                          {

                              if (_root.Symbol2.hitTest(_root.Rocket1))

                             

                                  _root.Symbol2.gotoAndPlay("Firstpointtext");

                            };

                           

                          onEnterFrame = function ()

                          {

                              if (_root.Symbol3.hitTest(_root.Rocket1))

                             

                                  _root.Symbol3.gotoAndPlay("Secondpointtext");

                            }

                           

                          This works for symbol3 but now makes  symbol2 not work at all. Any idea why it cancels out the first code?

                          • 10. Re: Object interaction problem
                            Chris_1942 Level 1

                            ok fixed again. Just changed code.

                             

                            onEnterFrame = function ()

                            {

                                if (_root.Symbol2.hitTest(_root.Rocket1))

                               

                                    _root.Symbol2.gotoAndPlay("Firstpointtext");

                                   

                                    if (_root.Symbol3.hitTest(_root.Rocket1))

                               

                                    _root.Symbol3.gotoAndPlay("Secondpointtext");

                              };