Jump to content
Search Community

TransformMatrixProxy + External Image + Security.. [SOLVED]

gas512 test
Moderator Tag

Recommended Posts

I ran into a problem with the TransformMatrixProxy, it's the weirdest thing.


I am loading an external image (foreign URL) using the MovieClipLoader, and then want to rotate that using the proxy script. See code below.

Before calling the " newMC = new TransformMatrixProxy(target_mc); " the image loads fine and I can tween it using the free TweenMax class.


However as soon as I call the TransformMatrixProxy and try to use TweenMax with it I get that nasty error and the tween is not executed:

*** Security Sandbox Violation ***

SecurityDomain 'http://www.helpexamples.com/flash/images/image1.jpg' tried to access incompatible context 'file:///C|/Gregory/federated%5Fmedia/flashapp/imagetest.swf'


Here is my code, I am wondering if I am doing something wrong, maybe shouldn't put the tween into an onLoadInit event? That seems to be the only one giving my image width and height after its loaded.



import gs.TweenMax;
import gs.utils.TransformMatrixProxy;
import mx.transitions.easing.*;

this.createEmptyMovieClip("img_mc", 999);
var my_mcl:MovieClipLoader = new MovieClipLoader();

// Create listener object:
var mclListener:Object = new Object();
mclListener.onLoadError = function(target_mc:MovieClip, errorCode:String, status:Number) {
   trace("Error loading image: " + errorCode + " [" + status + "]");
mclListener.onLoadStart = function(target_mc:MovieClip):Void {
   trace("onLoadStart: " + target_mc);
mclListener.onLoadProgress = function(target_mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number):Void {
   var numPercentLoaded:Number = numBytesLoaded / numBytesTotal * 100;
   trace("onLoadProgress: " + target_mc + " is " + numPercentLoaded + "% loaded");
mclListener.onLoadComplete = function(target_mc:MovieClip, status:Number):Void {
   trace("onLoadComplete: " + target_mc);
mclListener.onLoadInit = function(target_mc:MovieClip):Void {
   newMC = new TransformMatrixProxy(target_mc);
   newMC.registrationX = target_mc._x + (target_mc._width/2);
   newMC.registrationY = target_mc._y + (target_mc._height/2);
   TweenMax.to(newMC, 5, {rotation:1080, ease:None.easeOut});

my_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", img_mc);

Link to comment
Share on other sites

Yeah, Flash will allow you (in some cases) to load external images from another domain, but it will refuse to allow for any kind of BitmapData manipulation or filters or...I think...rotation of those images. And smoothing is always turned off. So the solution would be to make sure you've got a crossdomain.xml file installed on that server that's hosting your external images. And you may also need to set the checkPolicyFile property of your MovieClipLoader to true because of a security "enhancement" [cough] in Flash Player 9 (even if you're not targeting Flash Player 9 in your publish settings).


Let us know if that helps.

Link to comment
Share on other sites

I added the crossdomain.xml file and it works now when the swf is being opened from the webserver, not locally which is fine and probably normal. ehh


It seems to work without the checkPolicyFile property specifically set to TRUE but I will do some more testing other machines.


Thanks a ton!



Link to comment
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.
  • Create New...