Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
bivald

[solution] SecurityError (SandBox violation) using MotionBlur Plugin and (external) youtube player

Recommended Posts

Hi,

 

When using the MotionBlur plugin to animate a MovieClip (that is not the Youtube Player but a local symbol), I get:

 

at flash.display::BitmapData/draw()

at com.greensock.plugins::MotionBlurPlugin/setRatio()

at com.greensock::TweenLite/render()

at com.greensock::TimelineMax/render()

at com.greensock::TimelineMax/render()

at com.greensock.core::SimpleTimeline/render()

at com.greensock.core::Animation$/_updateRoot()

 

The problem is of course that you are not allowed to use BitmapData.draw on any remotely loaded objected (in this case the Youtube Player). The odd thing is that I am not trying to tween the youtube player, I'm trying to tween another completely different (local) element.

 

What I realized is this:

If you are trying to motion blur something that is on the same scope/"level" as the youtube player:

 

(child-)level  MovieClip                   Parent

0              Stage                       -

1              MC to be blurred            Stage

1              Youtube player              Stage

 

What the MotionBlur plugin does is that it takes the element, and in MotionBlurPlugin.as:369 does:

 

_bdCache.draw(_target.parent, _matrix, _ct, "normal", bounds, _smoothing);

 

Which means that it makes a new Bitmap object and tries to take a snapshot of the MovieClips parent, not the MovieClip itself. In my case this is the Stage (level 0). 

 

This - however - means that it tries to take a snapshot of an object (in my case the Stage) which includes the Youtube Player (loaded remotely) and thus gives the error.

 

To reproduce

1. Include the Youtube Player Proxy (or download the example project on from http://goo.gl/NXH5L),

2. Add it to the stage

3. Create a new symbol 

4. Add it to the stage

5. Try to use the MotionBlur Plugin on the newly created object

 

Solution

Put all your objects that you will tween in an empty Symbol and add that symbol to the stage. That way, when the MotionBlur plugin tries to fetch parent it only gets the newly created Symbol.

 

I don't know if this is something that the MotionBlur Plugin can even fix, that said, this would be nice:

 

try{

 _bdCache.draw(_target.parent, _matrix, _ct, "normal", bounds, _smoothing);

}catch(е) {

  trace("The animated object (" + _target + ") can't live on the same level as a remote object (such as a video player). To solve this, put the animated object into it's own empty MovieClip");

}

Link to post
Share on other sites

Thanks for providing such a detailed description AND a solution! The reason I'm hesitant to add the try...catch thing is because those are notoriously SLOW. I try very hard to optimize performance as much as possible in every way since that's critical in an animation engine. If a lot of people report problems like this, it may be worth adding that try...catch block but in all the years MotionBlurFilter has been out there, I think you're maybe the second person to mention anything like this, so I'm more inclined to prioritize performance. And again, I really appreciate the thoughtful solution.

Link to post
Share on other sites

No problem, I guessed there was such a reason. Just wanted to write down everything while I had it in my head, so the next time I can find it on Google again :)

  • Like 1
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×