9 Replies Latest reply on Aug 29, 2006 9:22 PM by Newsgroup_User

    attachMovie questions

    Level 7
      I have a couple of questions about attachMovie method.

      I am attaching a button like this:

      this.attachMovie("block_btn", "block_btn", this.getNextHighestDepth(),
      {_x:0, _y:0});
      this.block_btn._alpha = 50;

      My first question is why does this not work?

      this.attachMovie("block_btn", "block_btn", this.getNextHighestDepth(),
      {_x:0, _y:0, _alpha:50});




      Secondly, I can't seem to able to detach the button later on.
      I am trying to do it like this and it does not work:

      _parent.block_btn.removeMovieClip();

      On the other hand this does work, so I know I have the path right:

      _parent.block_btn._x = -50;

      So why is removeMovieClip() not happening?



      Thank you for any help with this!

      Thanks,
      Brian
        • 1. Re: attachMovie questions
          jonnybennett Level 1
          I have found that sometimes when attaching movies using
          getNextHighestDepth()
          that it then does not remove that movieclip using removeMovieClip(),
          Instead give it a depth of
          p=1;
          this.attachMovie("block_btn", "block_btn", p++);
          On the assumtion the path you specified is correct then it should then remove using...
          removeMovieClip('_parent.block_btn');

          Hope this helps and works! Jonnie.
          • 2. Re: attachMovie questions
            Craig Grummitt Level 3
            if you've confirmed that the path is right, then that removeMovieClip should work, as should the _alpha on the attachMovie. i suspect that the attachMovie line may have ran more than once... try temporarily replacing this.getNextHighestDepth() with a static integer eg. 10 to test this theory out...
            • 3. Re: attachMovie questions
              Level 7
              I replaced the this.getNextHighestDepth() with 1 and am still having the
              same problem.

              After exporting I looked at the "List Objects" and got a long list that
              I did a search on for the block_btn_01, which only came up once like the
              following.

              Button: Target="_level0.block_btn_01"

              I don't understand why it still show at _level0?

              Any ideas?

              Thanks for the help!
              Brian
              • 4. Re: attachMovie questions
                Craig Grummitt Level 3
                why wouldn't you expect it to be at _level0? it should appear whereever your this of your this.attachMovie statement is.
                i don't understand why it is block_btn_01 when your attachMovie statement named it block_btn...
                i think there's something going wrong in the code you haven't showed us. to illustrate, if you opened a new flash file, added a symbol in the library with linkage identifier block_btn and then added the line of code you quoted:
                this.attachMovie("block_btn", "block_btn", this.getNextHighestDepth(),
                {_x:0, _y:0, _alpha:50});
                you should notice that the alpha works okay. then if you were to add the line:
                block_btn.removeMovieClip();
                you would notice that the movie clip disappears...
                can you strip your code back to a section that still causes problems and post this? alternatively post a link to your fla.
                • 5. Re: attachMovie questions
                  Level 7
                  Craig,
                  sorry, I modified my code a bit to make it more clear and maybe rule out
                  some things that I thought might cause some issues.
                  Here is what I have at this point, that is causing issues...


                  this.attachMovie("block_btn", "block_btn_01", 5, {_x:0, _y:0, _alpha:50});
                  //alpha still does not work


                  After I do this, I want to detach it later and that is causing some
                  issues. I am trying to do it like this and it does not work:

                  _parent.block_btn_01.removeMovieClip();


                  On the other hand this does work, so I know I have the path right:

                  _parent.block_btn_01._x = -50;


                  I listed the objects after exporting the movie and it tells me this:

                  Button: Target="_level0.block_btn_01"



                  Thank you for your help with this. What could I do to isolate the issue
                  further and see what might be causing some problems?

                  Thanks a lot,
                  Brian
                  • 6. Re: attachMovie questions
                    Level 7
                    Could it be because this is a button and not a MovieClip?
                    • 7. Re: attachMovie questions
                      Level 7
                      OK, I tried that and it now is working without a problem. I guess you
                      can't do that with buttons.

                      The problem now is that I was using that button to block other buttons
                      from triggering for a certain amount of time. Any ideas about what to do
                      about that?

                      Thanks,
                      Brian

                      • 8. Re: attachMovie questions
                        Craig Grummitt Level 3
                        oh good work i hadn't considered that possibility. (i was using a movieclip)

                        removeMovieClip wouldn't work as it isn't a method of the button class. you couldn't set _alpha (or _x or _y by the way) coz as it says in help - The initobject "parameter allows dynamically created movie clips to receive clip parameters. "

                        >>Any ideas about what to do about that?
                        you could always put a button in a movieclip if necessary. or you could use .enabled on the buttons you want to disable...
                        • 9. Re: attachMovie questions
                          Level 7
                          Craig, thank you so much. That did it. I put the button into a MC and
                          now it is working!!!

                          Thanks a lot!
                          Brian