27 Replies Latest reply on May 14, 2008 2:38 PM by Bart Cross

    Problem with sub-mask

    Bart Cross Level 4
      I created an animation to use as a mask, it works as expected but the problem is that the mask within the mask animation does not appear when used as a mask on the other object.

      I need everything hidden when the mask starts, that is what I need the sub-mask for. Hope this can be understood.

      Ok, I exported the animation mask as swf and imported it into another file and that didn't work either, the mask within the mask still does not work (eg: the object hidden by the mask still shows.)
        • 1. Re: Problem with sub-mask
          clbeech Level 3
          you cannot mask the same object twice or with two masks existing in the same timeline - however you can change the 'size' or 'shape' of a mask on the fly - simple by changing it with a keyframe on the same mask layer.

          however - just wondering why not use the _visible property of the object to 'hide' it until you wish it to be viewed.

          additionally i seem to have no problems with constructing a mask within a mask - as long as the 'second' level mask is within the timeline of the object and not on the main timeline.
          • 2. Problem with sub-mask
            Bart Cross Level 4
            Thank you for your reply. I think that is what I have done, this is a link to the .fla if you have time to look at it.
            Link to File

            If you scrub the circlemask library item it works as expected, but when you view the flash file, well it is apparent. I've looked at this in many different ways, but I just can't seem to make it work.
            • 3. Re: Problem with sub-mask
              clbeech Level 3
              sorry your link doesn't work - throws an error.
              • 4. Re: Problem with sub-mask
                Bart Cross Level 4
                Link should work now. Really rank cold going on, wasn't fully paying attention. Which might explain.........
                • 5. Re: Problem with sub-mask
                  clbeech Level 3
                  sure does thanks. ok the problem here is that you need to remove the 'blank keyframe' in the mask layer on the main timeline - when you do the mask covers all the frames of the clip and it runs just fine.

                  however there is an easier way to do this - I'm assuming your building a preloader. here is a way to do it entirely with a little code and no mask or animation - to run this code make a new doc and place it in the actions panel on the first keyframe - nothing else is needed. you can adjust the 'size' and 'spd' vars to change it as well as the 'color' of the sweep in the lineStyle code there. One could also incorporate this with a percentage value returned durring a load using the onLoadProgress handler of the MovieClipLoader class.
                  • 6. Problem with sub-mask
                    Bart Cross Level 4
                    Actually, it is not for a preloader. I just want to reveal certain objects using this sweep. It still does not work like I would want and, stupid me, couldn't figure it out. What is happening is that the mask in the animation is showing the object underneath where the animation mask is. Well duh on me.

                    Going to work with your code to see if I can get it to work as a mask. That code was what I was looking for. Haven't had the chance recently to upgrade my math chops.

                    I appreciate the time you took reviewing this for me.
                    • 7. Re: Problem with sub-mask
                      clbeech Level 3
                      np - you're welcome :)

                      you can use this as a mask if you do a few things. first set the 'image' in an MC - then set the cacheAsBitmap property for both the imageMC and the sweepMC to true with code as in:

                      image.cacheAsBitmap=true;
                      sweep.cacheAsBitmap=true;

                      then use setMask() to mask the clip as in:

                      image.setMask(sweep);
                      • 8. Problem with sub-mask
                        Bart Cross Level 4
                        Thank you for the additional info. I will work with that today to see if I can get it running. Prefer using a code-based solution, rather than my 'old way' of doing it.

                        Got it running as expected. Absolutely brilliant. Thank you again for the time.
                        • 9. Re: Problem with sub-mask
                          Bart Cross Level 4
                          So, I have a problem where I cannot get more than one to work at a time. I have renamed each of the sweeps differently, and named each of the masked MCs differently, but only one will work.

                          Any suggestions?
                          • 10. Re: Problem with sub-mask
                            clbeech Level 3
                            ok - in that case your going to want to put this code together a little differently - either within a MC that is the 'sweep' or within a prototype - in either case I would also suggest that it be constructed within a method that can be controlled.

                            are you currently 'reusing' the same code multiply within that first frame? how did you construct this.
                            • 11. Re: Problem with sub-mask
                              Bart Cross Level 4
                              I have each on a separate layer, with the appropriate code. The code works for each if I delete the other codes.

                              I will try the sweep code as an MC, I am not competent with 'prototype' constructions.
                              • 12. Re: Problem with sub-mask
                                clbeech Level 3
                                yeah this is most likely because the instances of the 'sweep' clip are conflicting - as well as the onEnterFrames terminating each other improperly without a greater degree of control in place. so I've converted this into a class file which will operate even better than a prototype - as it keeps track of the instances used, and keeps them from getting 'confused' - and with very little code in the timeline needed to call the effect. you can download the fla, swf and class file HERE and the fla contains some comments on how to use the class. enjoy :)
                                • 13. Re: Problem with sub-mask
                                  Bart Cross Level 4
                                  Thank you. Nothing like having a FlashGod at your side.
                                  • 14. Re: Problem with sub-mask
                                    clbeech Level 3
                                    LOL!!! you're welcome :) you're welcome to join our community there as well - we do offer a 'Live Support chat' where we are able converse quickly about problems of this nature and others, as well as have a little fun.
                                    • 15. Re: Problem with sub-mask
                                      CHAOS'|nc. Level 1
                                      Thanks for the info beech! I myself might join up tomorrow. :)
                                      • 16. Re: Problem with sub-mask
                                        Bart Cross Level 4
                                        cl:

                                        I have Flash 8, so the file won't open. Poop!
                                        • 17. Re: Problem with sub-mask
                                          CHAOS'|nc. Level 1
                                          Lmao! @poop!
                                          • 18. Re: Problem with sub-mask
                                            clbeech Level 3
                                            lmao!! I've posted a Flash8 version to the thread listed above for you.
                                            • 19. Problem with sub-mask
                                              Bart Cross Level 4
                                              beech, solid as an oak. Thank you.

                                              Finally had a chance to work with the file, sweet. Thank you very much.

                                              Sometimes my design concepts get ahead of my actual ability to execute them.
                                              • 20. Re: Problem with sub-mask
                                                clbeech Level 3
                                                lol - np you're welcome :)

                                                don't worry about it - i like to go by the philosophy of 'learn something new every day' and you'll get there.
                                                • 21. Re: Problem with sub-mask
                                                  Bart Cross Level 4
                                                  cl: One last question, what code would I add to the as file, so that when the sweep mask is finished, it would go to the next frame?

                                                  I tried several things, but it only got progressively worse.
                                                  • 22. Re: Problem with sub-mask
                                                    clbeech Level 3
                                                    sure - change this line in the as file:

                                                    (spd<360) ? spd+=speed : delete sweep.onEnterFrame;

                                                    which is really a 'shorthand' conditional statement, to:

                                                    if(spd<360) {
                                                    spd+=speed;
                                                    }else{
                                                    delete sweep.onEnterFrame;
                                                    //do you action here - probably
                                                    _root.nextFrame();
                                                    }
                                                    • 23. Problem with sub-mask
                                                      Bart Cross Level 4
                                                      Chris: Perfectomundo!

                                                      I didn't think of if/else, so I was shorthanding the longhand.

                                                      I noticed that you change the last value in: new sweepMask(LetterC, 0, 0, 60, 12); you can change if/when the sweep will finish before entering the next frame.

                                                      That I will play with myself (hmmmmm, that doesn't sound exactly right!).
                                                      • 24. Re: Problem with sub-mask
                                                        clbeech Level 3
                                                        well in this case, as soon as the condition is satisfied it will advance. If you would like a delay before it does so - you could initiate a setInterval to hold for a duration previous to the advance. one could build this into the constructor so that you could pass a value for this purpose. in the above, the last parameter passed is for the 'speed' - however this relates to the speed of the 'sweep' itself in degrees.

                                                        I've constructed a new example of this and will post it to the board as soon as our server is back up (currently down - power out)
                                                        • 25. Re: Problem with sub-mask
                                                          Bart Cross Level 4
                                                          Chris: I moved each FLA statement to a different frame with a number marker, it works as expected. Hmmmmmmm, seems a good nights sleep makes you see things differently.

                                                          My initial thought was that the position of 360° defined in the sweep was different from that in the root, but hey, I know that was wrong too. I had to take a 1½ years off, so my Flash skills are a little decrepit. Need to get a new AS book to understand better how to use it and import it. Things have changed since the beginning.
                                                          • 26. Re: Problem with sub-mask
                                                            clbeech Level 3
                                                            lol - yeah that can do wonders! lol

                                                            I've got the new AS file and example posted to the thread - I included another parameter to call to a user defined method on the main timeline - I thought that would be a handy feature, in case one wished to evoke a different action on the completion of any sweep.

                                                            There's still plenty of improvements that could be made to the script as well - but it's an interesting little class :)
                                                            • 27. Re: Problem with sub-mask
                                                              Bart Cross Level 4
                                                              ....but it's an interesting little class :) and I'm an eager student. I think the concept has a lot of applications.