3 Replies Latest reply on Feb 17, 2011 3:45 AM by deshggg

    createEmptyMovieClip creates it on all frames (AS2)?

    deshggg

      Hey everyone,

       

      I have a question regarding createEmptyMovieClip in AS2. I have a flash file separated out into sections with labels and menu buttons which allow you to move you to the relevant frame/section (which contains the information/contents relevant to that section). This works fine. What I can't work out is that if I manually put a movieclip on the stage in my 'about section' and then add contents to it via AS2 then it only exists within the about us section. If I do it using createEmptyMovieClip within the actions for the about frame this works fine but it then always exists on every other frame of the project. I assume this is because it isn't actually creating it within this frame but I can't work out how to make it do this, even when i use this.createEmptyMovieClip it has exactly the same effect. I can obviously remove the movieclip completely each time a user moves to another frame that doesn't contain it but I don't want to do this as it contains a youtube video and leaving it means it doesn't have to be reloaded each time they come back.

       

      I would be massively grateful if anyone could shed any light on this for me as I know i'm not getting how to place it correctly but i'm not sure how I should be doing it?

       

      Thanks so much in advance,

       

      Dave

        • 1. Re: createEmptyMovieClip creates it on all frames (AS2)?
          Ned Murphy Adobe Community Professional & MVP

          Content you load dynamically does not have a home on the timeline unless you designate it to be loaded into one.  Such a home would be a movieclip that you manually add to the timeline.  So if you made such a home, named it mc, then you could use...

           

          mc.createEmptyMovieclip(...etc

           

          and load whatever into that.  It should not remain after you leave the frame that mc is in.  Once you have loaded the video, it should be readily available via the user's cache.  But if you want to retain it to avoid the chance that it was removed from the cache between frame changes (not likely), then your only option is to make things invisible (set the _visible property of the created movieclip to false)... though you may need to manage the video as well to shut it down and whatnot.

          1 person found this helpful
          • 2. Re: createEmptyMovieClip creates it on all frames (AS2)?
            deshggg Level 1

            Hi Ned,

             

            Thank you so much for your response, which was extremely clear as ever, that makes perfect sense and i understand the logic now so thank you! One follow up question, i have created an empty mc manually on the stage as you suggested and have created my mc via as2 within it. This works fine and now it only shows up when within the about us section. I am using the YouTube AS2 API to embed a youtube video within this movieclip, the start of this code (to create the mc) is:

            var ytplayer:MovieClip = createEmptyMovieClip("ytplayer", 1);

            As a result I have just changed it to the following (where video_mc is the instance name of the movieclip i manually put on the stage):

            var ytplayer:MovieClip = video_mc.createEmptyMovieClip("ytplayer", 1);

             

            This is great and works fine however prior to this I need to check for the existence of the movieclip so I could see whether to recreate it or not. I was using:

            if (!ytplayer){

            to check for it's existence which worked fine, however with the new code I thought the following code should be used but it does not seem to work:

            if (!video_mc.ytplayer){

             

            Similarly, I suspect it's the same problem with the following code (i'm using it when navigating to another section to stop it from playing as the audio continues to play even though the player disappears):

            ytplayer.pauseVideo(); // This works fine when using the original code
            video_mc.ytplayer.pauseVideo(); // This doesnt work
            

             

            I think these are probably both the same issue and that I should be referencing it in a different way (and not video_mc.ytplayer), but I can't work out what and nothing i try seems to work. If you could shed any light on these remaining issues in then that would be massively appreciated as i'm rather confused!

             

            Thank you so much for your help as ever,

             

            Dave

            • 3. Re: createEmptyMovieClip creates it on all frames (AS2)?
              deshggg Level 1

              For some reason I could not get the bits to work that i described in the previous thread so I ended up creating it via AS2 and then making it's _visible property false whenever you visit any other page which prevents it from displaying. This works fine but I would be most grateful if anyone could explain why what I was trying to do didn't work so I can better understand it all for the future.

               

              Thanks so much for your help,

               

              Dave