开发者

Flash Action Script 3 issue: image resize doesn't work

Check this link: http://inno_ebay.s3.amazonaws.com/xml-product-slide/index-2.html

This swf object load an external xml file (generated by php script which doesn't locate on the same machine) and then display the product list (thumbnail and title). The script was tested working fine on my local machine, but when updating to the hosting, the images don't resize. At the first i thought that it's hosting performance issue, so i migrated it to amazon s3, but it still doesn't work. Any suggestions are welcome, thanks开发者_Python百科!


Your application throws a security access violation, which suggests that you are trying to load the image from a different domain to the one that the Flash resides on. While that is possible using a crossdomain.xml file, you will run into trouble when you try to manipulate the remotely loaded images.

The workaround I generally use in these situations is to employ a proxy loader that exists in the same domain as the Flash movie. This is a server script (PHP, ASP, whatever) that fetches the remote image for you. Because Flash only talks to the proxy script, it believes that the image it is loading is from the local domain. You will need to check with your hosting provider though, as many hosting companies prohibit the use of proxy scripts, even for benign purposes such as this.

Here's a simple example, although you would probably want to add a bit more security to a real world deployment:

proxyloader.php

<?php
    if(!isset($_GET['path'])) {
        echo 'Error';
        exit;
    }
    $path = $_GET['path'];

    $fileContent = file_get_contents($path);
    if(substr($fileContent,0,6) == 'GIF89a' || substr($fileContent,0,6) == 'GIF87a') {
        $contentType = 'image/gif';
    } else if(substr($fileContent,1,3) == 'PNG') {
        $contentType = 'image/png';
    } else {
        $hexContents = bin2hex($fileContent);
        if(strtolower(substr($hexContents,0,4)) == 'ffd8') {
            $contentType = 'image/jpeg';
        } else {
            echo "Error";
            exit;
        }
    }

    header("Content-Description: Proxied Image File");
    header("Content-Type: $contentType");
    header("Content-Disposition: attachment; filename=".$path);
    echo $fileContent;  
?>

and you would use this in a normal loader like this:

var loader:Loader = new Loader()
var req:URLRequest = new URLRequest("proxyloader.php?path="+remoteFilePath);
loader.load(req);


This is the XML:

http://ebay.doufin.com/ebay_query/getItems.php?seller_id=lightupfoto&site_id=0&item_id=270738606484

This is an item:

<item link="http://cgi.ebay.com/2400w-Studio-Video-Red-Head-Continuous-Lighting-Kit-/270658608211" thumb="http://i.ebayimg.com/00/$(KGrHqZ,!lwE3JVj5IKsBODEto4sP!~~0_1.JPG?set_id=8800005007">
    <a href="http://cgi.ebay.com/2400w-Studio-Video-Red-Head-Continuous-Lighting-Kit-/270658608211" target='_blank'>2400w Studio Video Red Head Continuous Lighting Kit</a>
</item>

This is the thumbnail:

Flash Action Script 3 issue: image resize doesn't work

It's 400 x 400 px.

So please, what is your question?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜