Magic persistent Flash Button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karlectomy
    New Member
    • Sep 2007
    • 64

    Magic persistent Flash Button

    My button won't leave the stage.

    I'm programming in AS2.0 using Flash MX2004

    I attach the button "again" to the stage and its release function is gameOn where I remove the movie clip.

    For some reason, It won't leave the stage...

    I've tried to look at everything but maybe I'm missing something.
    any help would be greatly appreciated.

    Code:
    function gameOn()
    {
            again.removeMovieClip();
    }
    
    function gameOver()
    {
            attachMovie("again", "again", 201);
    	again._xscale = 120;
    	again._yscale = 60;
    	again._x = 280;
    	again._y = 300;
    	again.onRelease = gameOn;
    }
  • xNephilimx
    Recognized Expert New Member
    • Jun 2007
    • 213

    #2
    Hi karlectomy!
    That is no wroking because that's not the correct sintax to the removeMovieClip method.

    The correct sintax is the following:
    [CODE=actionscri pt]
    someMC.removeMo vieClip(targetM C);
    [/CODE]

    What this does is removing the targetMC that's inside someMC.
    If your movieclip "again" is on the root I reccomend to to declare a global variable (that is, outside any function) calld home for example, and making it equal to this (I mean, the "this" pseudo-object), so the variable home, will always be the local root, even inside functions.
    Then you can use this as follows:

    [CODE=actionscri pt]
    var home:MovieClip = this;

    function gameOn():Void {
    home.removeMovi eClip(again);
    }
    [/CODE]

    Best regards,
    The_Nephilim

    Originally posted by karlectomy
    My button won't leave the stage.

    I'm programming in AS2.0 using Flash MX2004

    I attach the button "again" to the stage and its release function is gameOn where I remove the movie clip.

    For some reason, It won't leave the stage...

    I've tried to look at e
    verything but maybe I'm missing something.
    any help would be greatly appreciated.

    Code:
    function gameOn()
    {
            again.removeMovieClip();
    }
    
    function gameOver()
    {
            attachMovie("again", "again", 201);
    	again._xscale = 120;
    	again._yscale = 60;
    	again._x = 280;
    	again._y = 300;
    	again.onRelease = gameOn;
    }

    Comment

    • karlectomy
      New Member
      • Sep 2007
      • 64

      #3
      Thank you very much,

      I see what you're saying.

      can I attach and remove movie clips from the stage?

      Comment

      • xNephilimx
        Recognized Expert New Member
        • Jun 2007
        • 213

        #4
        You're welcome!

        What do you mean? Dynamically attaching a movieclip to the stage?

        Originally posted by karlectomy
        Thank you very much,

        I see what you're saying.

        can I attach and remove movie clips from the stage?

        Comment

        • karlectomy
          New Member
          • Sep 2007
          • 64

          #5
          More specifically is this correct?

          [Code="actionscr ipt"]

          stage.attachMov ie("again","aga in",201);

          again.onRelease = stage.removeMov ieClip(again);

          [/Code]

          Comment

          • xNephilimx
            Recognized Expert New Member
            • Jun 2007
            • 213

            #6
            The sintax is correct, but you can't use Stage to do that, the Stage object only contains information about the movie, it is not a reference to the _root.

            If you want to attach it to the root you can do as follows:
            [CODE=actionscri pt]
            var home:MovieClip = this;

            home.attachMovi e("again","agai n",201);

            again.onRelease = stage.removeMov ieClip(again);

            [/CODE]

            Best regards,
            The_Nephilim

            Originally posted by karlectomy
            More specifically is this correct?

            [Code="actionscr ipt"]

            stage.attachMov ie("again","aga in",201);

            again.onRelease = stage.removeMov ieClip(again);

            [/Code]

            Comment

            • karlectomy
              New Member
              • Sep 2007
              • 64

              #7
              Neph,

              Thanks for your help. finally it's gone!! YAYAYAYA

              Originally posted by xNephilimx
              The sintax is correct, but you can't use Stage to do that, the Stage object only contains information about the movie, it is not a reference to the _root.

              If you want to attach it to the root you can do as follows:
              [CODE=actionscri pt]
              var home:MovieClip = this;

              home.attachMovi e("again","agai n",201);

              again.onRelease = stage.removeMov ieClip(again);

              [/CODE]

              Best regards,
              The_Nephilim

              Comment

              • xNephilimx
                Recognized Expert New Member
                • Jun 2007
                • 213

                #8
                LOL!
                Glad it worked!! You're welcome!

                Best regards!
                The_Nephilim

                Originally posted by karlectomy
                Neph,

                Thanks for your help. finally it's gone!! YAYAYAYA

                Comment

                Working...