4 Replies Latest reply on Jun 21, 2006 6:24 PM by jtouhey

    Dynamically Masking a Dynamically Placed Image

      Ok, Here is what's going on. I have one container movie with two other movies loading into it via empty movie clips- let's call them movA and movB. I want to click a button from movB that loads an image (dynamically) into movB and masks the image once it is loaded...

      on movA, I have the following frame action:

      // movie clip for mask
      this.attachMovie("swatch1", "thumbHolder", 40,{_x:985, _y:885.9});
      this.attachMovie("swatch1", "thumbMask", 50,{_x:985, _y:885.9});

      on movB, I have the following code on a button:

      // load logo .gif into holder with masking
      on(release) {

      Right now, the image is being loaded into the correct place, but the movie clip ("thumbMask") is only showing up on top of the image without doing any masking... I heard that maybe the image needs to be "fully" loaded before the mask can be called, but i'm not exactly sure how to do this unless I add a preloader- which am trying to avoid.

      Any help would be much appreciated!!!
        • 1. Re: Dynamically Masking a Dynamically Placed Image
          Rothrock Level 5
          Why would you want to avoid using a preloader? You are correct you need to wait until the image is fully loaded before you can setMask(); And a preloader is the way to go.

          If you are using Flash 7 or higher, you could look into using the MovieClipLoader class instead of loadMovie(); In that case you would use the onLoadInit event to do your setMask(); Simple as pie, really!
          • 2. Re: Dynamically Masking a Dynamically Placed Image
            jtouhey Level 1
            Thanks Rothrock... I'll try that. I've gotta' get up on the listener action. The reason i'm trying to avoid a preloader is because this is going to be a kiosk-like application and being the designer I am, I just want the image to 'pop' in place- my preference really on this one.
            • 3. Re: Dynamically Masking a Dynamically Placed Image
              Rothrock Level 5
              I think you are sort of misunderstanding the nature of what a preloader is. It is just some code that makes sure the external asset is loaded before you try and use it. Often they have little animations or other such things, but that is incidental.

              I imagine this kiosk is going to be run off of a local harddrive or CD? In that case a preloader with "now loading/progress" won't work anyways. When playing from a local source, the Flash player loads all external assets in "one chunk." This can cause a little pause in your code. Especially if it needs to spin up the drive. So if you use the onLoadProgress event of the MovieClipLoader it won't execute either. But onLoadInit will fire when the loaded asset is "ready for my closeup Mr. deMille!" so to speak.
              • 4. Re: Dynamically Masking a Dynamically Placed Image
                jtouhey Level 1
                Too funny. Yeah, I suppose I was associating preloader with an animation clip which I *wouldn't have to use/show. This app will actually be executed by a projector file but will access a database online (hence 'kiosk-like') so... I *could use a preloader or look into using LoadInit...

                What do you think of placing my image files into a seperate movie or movie clip and preloading this clip when the movie initially runs... I can just place it outside of the stage. Then when I need to place an image, I can use the button to load the movieclip at a specific frame to show the image I want... but it will already be loaded so the dynamic mask *should work?