Jump to content
Search Community

ImageLoader smoothing not working

Esseti test
Moderator Tag

Recommended Posts

Hello.

Simple example: I want to load an external image (one that is in the same place as the swf that is running) with ImageLoader, and I want the loaded image to be smoothed, because I want to animate it smoothly, and not skip by 1px.

 

Problem: When I run the code below, it doesn't work.

 

 

import com.greensock.TweenLite;
import com.greensock.loading.ImageLoader;
import com.greensock.events.LoaderEvent;

var il:ImageLoader = new ImageLoader("image.jpg", {smoothing: true, onComplete: ilComplete, container:this});
il.load();
function ilComplete(e:LoaderEvent):void {
trace("loaded");
TweenLite.to(e.target.content, 10, {x:10});
TweenLite.to(img, 10, {x:10});
// img is an instance of the same image added on stage, and set Smoothing: on in the library
}

http://yz.pl/bohner/misc/imgloader-smoothing.html

 

I've read the docs, smoothings should be set by default to true, but it doesn't work. I've read that it might be a crossdomain issue, but I don't load it from another domain. I've made the xml anyway, but still, doesn't work.

I've also read the forums, but didn't find a solution for this problem.

 

Any ideas?

Link to comment
Share on other sites

Hmm still sounds like a security related problem preventing script access to the image data (essentially without the security clearing, you are only allowed to display the unaltered content and can't affect the pixels i.e. no image smoothing). If smoothing is disabled by default and you can't enable it after the fact, it is definitely security related. If you try to draw or copy the bitmapdata of the image you would be hit with a security exception.

 

From the docs:

By default, the ImageLoader will attempt to load the image in a way that allows full script access. However, if a security error is thrown because the image is being loaded from another domain and the appropriate crossdomain.xml file isn't in place to grant access, the ImageLoader will automatically adjust the default LoaderContext so that it falls back to the more restricted mode which will have the following effect:
  • A LoaderEvent.SCRIPT_ACCESS_DENIED event will be dispatched and the scriptAccessDenied property of the ImageLoader will be set to true. You can check this value before performing any restricted operations on the content like BitmapData.draw().
  • The ImageLoader's rawContent property will be a Loader instance instead of a Bitmap.
  • The smoothing property will not be set to true.
  • BitmapData operations like draw() will not be able to be performed on the image.

To maximize the likelihood of your image loading without any security problems, consider taking the following steps:

  • Use a crossdomain.xml file - See Adobe's docs for details, but here is an example that grants full access (put this in a crossdomain.xml file that is at the root of the remote domain):
    <?xml version="1.0" encoding="utf-8"?>
    <cross-domain-policy>
    <allow-access-from domain="*" />
    </cross-domain-policy>
  • In the embed code of any HTML wrapper, set AllowScriptAccess to "always"

 

If you've tried all this and are still getting script access denied then I guess someone more knowledgeable will have to help you set this up.

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...