14 Replies Latest reply on Dec 27, 2007 3:21 AM by Greg Dove

    Actionscript 2 Bug

      Hey everyone,
      I'm just trying to sort out a huge bug I have discovered in Actionscript 2. I'm loading images into a movieclip that is masking the image. My code looks like what is attached.

      The code works fine without the setMask() enabled. There is no reason that flash should be tracing this: "SECURITY SANDBOX VIOLATION: whatever.swf tried to access incompatible context." If I remove the setMask() property, there's no problem, no error, and everything works fine.

      Is setMask() the devil? What gives, Adobe? I've turned on all my bitmap caching in the properties menu.. everything works fine if the image isn't dynamically loaded. I'm developing a RIA so the images obviously need to be dynamically loaded.

      Is there a fix to this?

      - TK
        • 1. Re: Actionscript 2 Bug
          Greg Dove Level 4
          You say your code "looks like" what you have attached. Are you certain?

          Could it be possible that you jpg is not in the same domain as your swf.
          If so that would very likely be a feature - a security feature - of flash and not a bug.

          when I googled "to access incompatible context" I found a number of links related to this, including this one, which seems pertinent:

          Its also worth noting that if you are loading bitmaps (e.g. jpgs) from a different domain then you don't usually have access to the bitmap data.
          There are ways to address this, such as using a helper swf to do the loading from the same domain as the bitmaps. I suspect that masking a loaded bitmap from a remote domain might be treated in the same way as being able to manipulate its bitmap data.

          - Just partially informed speculation here, I didn't try it. Others may know more and either confirm this or rule it out -
          • 2. Re: Actionscript 2 Bug
            kglad Adobe Community Professional & MVP
            i doubt that code would compile. copy and paste the relevant code when you need to display code otherwise you waste our time debugging code that you aren't using.
            • 3. Re: Actionscript 2 Bug
              Greg Dove Level 4
              @kglad: lol, I didn't even look at that part. I was just thinking about the error. You're right of course. You're up early. Or late.
              • 4. Re: Actionscript 2 Bug
                kglad Adobe Community Professional & MVP
                up early here (2 am)...
                • 5. Re: Actionscript 2 Bug
                  Greg Dove Level 4
                  @kglad : lol, if you're up early at that time.. that's insomnia! get some sleep, man. BTW I registered with dzedward's site. I noticed you were registered there as well. There's live chat if you ever want to drop in. I'm there now (no-one else is!)
                  • 6. Re: Actionscript 2 Bug
                    kglad Adobe Community Professional & MVP
                    i'm going back to bed. sometimes this happens where i wake up, can't go back to sleep and just need to do something for an hour or two and then return to bed. i'm going back for sleep, part deux.
                    • 7. Actionscript 2 Bug
                      Greg Dove Level 4
                      know what its like. double check you didn't mix caffeine and wine earlier. That's what does it for me. sedating effect of the alcohol wears off and exposes the residual effect of the caffeine which has a longer half life. At least that's what I learnt somewhere I think.
                      • 8. Re: Actionscript 2 Bug
                        kglad Adobe Community Professional & MVP
                        that's an interesting theory. i'll have to check on that.
                        • 9. Re: Actionscript 2 Bug
                          Greg Dove Level 4
                          SOrry rfkrocktk , we've kinda hijacked your thread.. please post with an update here and we'll continue to help...

                          @kglad good morning (again). re the caffeine thing... yeah. It may be no more than a theory that I read perhaps... but it kind of seemed, well, logical. Doesn't mean its correct though, I guess.
                          • 10. Actionscript 2 Bug
                            rfkrocktk Level 1
                            Here's my code.

                            MySQL>PHP>XML>Flash which lists buttons.
                            On roll over of each button, it SHOULD load the image into a movieclip which is masked to a square (hopefully soon a circle :] ). It's giving me those crazy errors.

                            Thanks guys!

                            - TK
                            • 11. Re: Actionscript 2 Bug
                              kglad Adobe Community Professional & MVP
                              you can't nest anonymous functions. change ultLoad() to be a named function.

                              and you're likely to run into problems if start a load before the previous has completed.
                              • 12. Actionscript 2 Bug
                                Greg Dove Level 4
                                kglad: I think that should be ok - the function part. (Just on the basis that the OP said it was working without the mask).
                                The ultLoad is a regular function declaration, albeit nested - its not how I'd do it as is but if its working then guess that's ok. There is another anon function that follows, its not really nested though- its an argument for the zigo tween ; the end-of-tween callback.

                                @rfkrocktk :
                                The only reference to the clip named masker I see in you code is

                                can you put a
                                trace("I think masker is:"+masker)

                                statement in where you say is the problem code?
                                If what you say is true and everything else is working, then let's see what else it might be.

                                • 13. Re: Actionscript 2 Bug
                                  rfkrocktk Level 1
                                  is the problem code.
                                  If I comment that out, there are no problems, but if I leave it in, then crap starts flying in the output panel.
                                  I tried tracing it, it isn't undefined, the movieclip really is there. What should I do?
                                  • 14. Re: Actionscript 2 Bug
                                    Greg Dove Level 4
                                    Its pretty hard to tell for sure without testing your code first hand. I could look at it some time over the next few days if you post a link to a zip file with your fla and any as files.

                                    Other than that... this is all I can suggest for the moment:

                                    One thing you might want to try...
                                    "Instead of setting a mask on a dynamically loaded MC, you can load the MC into a container which is itself masked".
                                    So try loading the image into a child clip of a clip which is already masked with masker. That way you don't need to set the mask on each load.

                                    Also it seems that someone else described your original problem in the comments on this page below. The answer they gave might help, although it seems unusual/unnecessary under normal circumstances.

                                    http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveD ocs_Parts&file=00002514.html