18 Replies Latest reply on Feb 4, 2010 8:01 AM by beno12345

    What Argument?

    beno12345 Level 1

      Hi;

      I have the following code that is called from another class:

       

      package

      {

      import flash.events.Event;

      import flash.events.ProgressEvent;

      import flash.events.Event;

      import flash.events.MouseEvent;

      import flash.display.MovieClip;

      import com.greensock.*;

      import com.greensock.easing.*;

       

      public class CloseThumb extends MovieClip

      {

      public var myThumb:CloseThumb;

       

       

      public function CloseThumb()

      {

      init();

      }

       

       

      public function init():void

      {

      theThumb();

      trace('init CloseThumb');

      }

       

      public function doTween():void

      {

      trace('doTween');

      TweenMax.to(myThumb, .4, {shortRotation:{rotation:60}, ease:Back.easeOut,onComplete:onFinishTween});

      }

       

      public function onFinishTween():void

      {

      removeChild(myThumb);

      }

       

      public function theThumb():void

      {

      myThumb.x = 365;

      myThumb.y = 355;

      addChild(myThumb);

      doTween();

      trace('theThumb');

      }

      }

      }

       

      Calling this code from the other class throws this error:

       

      1136: Incorrect number of arguments. Expected 1.

       

      What argument is it expecting from the above code?

      TIA,

      beno   

        • 1. Re: What Argument?
          kglad Adobe Community Professional & MVP

          click file/publish settings/flash and tick "permit debugging".  retest and paste the output.

          • 2. Re: What Argument?
            beno12345 Level 1

            I did just that and it didn't give me anything else. I even double-checked to see that "Permit debugging" was checked. Please advise.

            TIA,

            beno   

            • 3. Re: What Argument?
              kglad Adobe Community Professional & MVP

              how do you know the error is coming from that class?  do you see any trace() output?

              • 4. Re: What Argument?
                beno12345 Level 1

                The source of the error states it's coming from CloseThumb.as, which is the class in question.    

                • 5. Re: What Argument?
                  kglad Adobe Community Professional & MVP

                  again, copy and paste the complete error message including trace output after inserting a trace() function just before call theThumb().

                   

                  in addition, how does this class obtain a reference to myThumb?

                  • 6. Re: What Argument?
                    beno12345 Level 1

                    Just to be really clear, I changed the CloseThumb.as thus:

                     

                    public function init():void

                    {

                    trace('theThumb');

                    theThumb();

                    trace('init CloseThumb');

                    }

                    It didn't trace at all. I believe the reason is because, as the error states, Flash is expecting me to put an argument into my call to CloseThumb() and I'm not doing that:
                    Main2.as, Line 28          1136: Incorrect number of arguments. Expected 1.          CloseThumb()
                    For good measure (and to answer your other question), here's the code from which it is called:
                    package
                    {
                    import flash.events.Event;
                    import flash.events.ProgressEvent;
                    import flash.events.Event;
                    import flash.events.MouseEvent;
                    import flash.display.MovieClip;
                    import com.greensock.*;
                    import com.greensock.easing.*;
                    import CloseThumb;
                    public class Main2 extends MovieClip
                    {
                    trace('hi');     
                    private var myThumb:CloseThumb = new CloseThumb();
                    public function Main2()
                    {
                    trace('Main2');
                    init();
                    }
                    public function init():void
                    {
                    trace('init');
                                            CloseThumb();
                    }
                    }
                    }
                    I'd forgotten this until just now, but it's not tracing *anything at all*.
                    TIA,
                    beno    

                    • 7. Re: What Argument?
                      kglad Adobe Community Professional & MVP

                      what's myThumb?  (CloseThumb has no way to reference a displayobject.)

                       

                      and:

                       


                      package
                      {
                      import flash.events.Event;
                      import flash.events.ProgressEvent;
                      import flash.events.Event;
                      import flash.events.MouseEvent;
                      import flash.display.MovieClip;
                      import com.greensock.*;
                      import com.greensock.easing.*;
                      import CloseThumb;
                      public class Main2 extends MovieClip
                      {
                      trace('hi');     
                      private var myThumb:CloseThumb = new CloseThumb();
                      public function Main2()
                      {
                      trace('Main2');
                      init();
                      }
                      public function init():void
                      {
                      trace('init');
                                              CloseThumb();  // this is wrong.
                      }
                      }
                      }

                      • 8. Re: What Argument?
                        beno12345 Level 1

                        I *think* I see the problem, but I probably have not understood you correctly. CloseThumb is also the name of a library asset in the IDE, so I changed the name of the class and the *.as file to CloseTheThumb, giving me the following revised code:

                         

                        public class CloseTheThumb extends MovieClip

                        {

                        public var myThumb:CloseThumb = new CloseThumb();

                        public function CloseTheThumb()

                        but that didn't make one bit of difference. To answer your question, myThumb is an instantiation of the CloseThumb in the library.
                        TIA,
                        beno    

                        • 9. Re: What Argument?
                          beno12345 Level 1

                          Oops. Ok, changed to:

                           

                          CloseTheThumb();

                           

                          package

                          {

                          import flash.events.Event;

                          import flash.events.ProgressEvent;

                          import flash.events.Event;

                          import flash.events.MouseEvent;

                          import flash.display.MovieClip;

                          import com.greensock.*;

                          import com.greensock.easing.*;

                          import CloseTheThumb;

                           

                          public class Main2 extends MovieClip

                          {

                          trace('hi');     

                          private var myThumb:CloseThumb = new CloseThumb();

                           

                           

                          public function Main2()

                          {

                          trace('Main2');

                          init();

                          }

                           

                           

                          public function init():void

                          {

                          trace('init');

                                                  CloseTheThumb();

                          }

                           

                          }

                          }

                           

                          but it *still* throws the same error:

                           

                          1136: Incorrect number of arguments. Expected 1      Source: CloseTheThumb

                          Please advise.

                          TIA,

                          beno    

                          • 10. Re: What Argument?
                            kglad Adobe Community Professional & MVP

                            what's CloseTheThumb()?

                            • 11. Re: What Argument?
                              beno12345 Level 1

                              CloseTheThumb() is what used to be CloseThumb(). It's a separate class. The reason I renamed it is because of a name conflict with a library asset by the same name.

                              beno

                              • 12. Re: What Argument?
                                kglad Adobe Community Professional & MVP

                                then what's CloseThumb?

                                • 13. Re: What Argument?
                                  beno12345 Level 1

                                  CloseThumb is the library asset.

                                  CloseTheThumb is the class.

                                  Hope that clears up the confusion.

                                  beno

                                  • 14. Re: What Argument?
                                    kglad Adobe Community Professional & MVP

                                    this isn't correct:

                                     

                                    public function init():void

                                    {

                                    trace('init');

                                                            CloseTheThumb();

                                    }

                                     

                                     

                                    what do you expect to happen when you "call" a class?  that's not a function/method.

                                     

                                     

                                     

                                    look, you're entire setup is screwy.  if CloseThumb is your library asset, create a CloseThumb class that includes a public method to "close" or tween your asset.  you can then apply that method to all your CloseThumb instances whenever you like.

                                    • 15. Re: What Argument?
                                      beno12345 Level 1

                                      Well, that's what CloseTheThumb is supposed to be! So I tried sticking

                                      doTween();

                                      in the Main2.as class, but it errors out, naturally, as a call to a possibly undefined method since it's not a method at all, it's a function. Sorry...I'm obviously new at this :-}

                                      TIA,

                                      beno   

                                      • 16. Re: What Argument?
                                        beno12345 Level 1

                                        Never mind. I believe I've figured this out. Thanks for your help!

                                        beno

                                        • 17. Re: What Argument?
                                          kglad Adobe Community Professional & MVP

                                          assign the Thumb class to your library asset and create the following Thumb class:

                                           

                                          package

                                          {

                                          import flash.events.Event;

                                          import flash.events.ProgressEvent;

                                          import flash.events.Event;

                                          import flash.events.MouseEvent;

                                          import flash.display.MovieClip;

                                          import com.greensock.*;

                                          import com.greensock.easing.*;

                                           

                                          public class Thumb extends MovieClip

                                          {

                                           

                                           

                                          public function Thumb(x:int,y:int)

                                          {

                                          setPos(x,y);

                                          }

                                           

                                           

                                          public function doTween():void

                                          {

                                          trace('doTween');

                                          TweenMax.to(this, .4, {shortRotation:{rotation:60}, ease:Back.easeOut,onComplete:onFinishTween});

                                          }

                                           

                                          public function onFinishTween():void

                                          {

                                          this.parent.removeChild(this);

                                          // consider nulling for gc

                                          }

                                           

                                          public function setPos(x:int,y:int):void

                                          {

                                          this.x = x;

                                          this.y = y;

                                          }

                                          }

                                          }

                                           

                                           

                                          ////////////////////////////////////////////////

                                           

                                          now, in your document class, when you want to create a new Thumb instance use:

                                           

                                          var thumb:Thumb=new Thumb(100,200);  // or use whatever intial x,y

                                          addChild(thumb);

                                           

                                          ////////////////////////////

                                           

                                          when you want to tween and remove your thumb use:

                                           

                                          thumb.doTween();

                                          • 18. Re: What Argument?
                                            beno12345 Level 1

                                            Yes, that's basically what I did. You must have been working on this while I posted I'd solved the problem. Thanks again!

                                            beno