本文介绍了我如何使用 BINDABLE 和具有 urlencoded 值的 JSON 节点值让这个图像 url 显示在 flashbuilder 4.5 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我正在开发的 flashbuilder 4.5 移动应用程序中加载 JSON,到目前为止所有变量都呈现良好,我使用左右滑动手势允许用户在项目数组中移动 - 使用 actionscript3.

Im loading JSON in a flashbuilder 4.5 mobile app Im working on, so far all the variables render fine and I am using left and right swipe gestures to allow the user to move through the array of items - using actionscript3.

现在我开始将图像添加到舞台的部分,该舞台的 SOURCE 参数绑定到一个变量 (thisimg2),该变量的值是图像 url 的 json 值...... URL 的一个例子是:

Now I get to the part where Im working on adding an image to the stage that has its SOURCE parameter bound to a variable (thisimg2) whose value is the json value for the image url... an example of the URL is:

http://i.ebayimg.com/00/s/MTA2MlgxNjAw/%24T2eC16JHJG%21E9nm3pkoZBQDVSKHsow%7E%7E60_1.JPG?set_id=880000500F

http://i.ebayimg.com/00/s/MTIwMFgxNjAw/%24%28KGrHqV,%21pcE9eMM4r4ZBPmiD+Ft%21%21%7E%7E60_1.JPG?set_id=880000500F

一小部分 json URL 值作为没有十六进制值的非常简单的图像 URL 返回,并且显示得很好,但大多数看起来像上面的 2 个示例,根本不渲染,只是结果在 flex 中损坏的图像/问号符号中(使用桌面调试/模拟器).我尝试对 url 字符串进行解码,但没有奏效.

a small percentage of the json URL values come back as really simple image URLs with no hex values and those show up just fine, but the majority of the, that appear like the 2 examples above, dont render at all and just result in the broken image/question mark symbol in flex (using desktop debug / emulator). I tried decode on the url string but that didnt work.

当我将网址放入浏览器时,它们可以正常工作并在浏览器中呈现.

when I put the urls in my browsers they work fine and render in browser.

我可以对 URL 做些什么来让它们工作吗?

is there anything I can do to the URL's to get them work?

推荐答案

您能否提供一个适用于您的 URL 示例?

Can you provide an example of a URL that is working for you?

我相信 Ebay 是专门阻止来自其他域的 Flash 应用程序使用它们的图像.

I believe Ebay is specifically preventing Flash apps from other domains from using their images.

URL 编码不是问题...Flash 只是依赖浏览器来下载它们.然而,看看这个深埋在 BitmapImage 组件中的代码(这是 Spark Image 组件使用的底层内容):

The URL encoding is not the problem ... Flash just relies on the browser to download them. However, take a look at this code buried deep inside the BitmapImage component (which is the underlying thing that the Spark Image component uses):

BitmapImage::loadExternal()(第 1513 行)

BitmapImage::loadExternal() (line 1513)

    try
    {
        loaderContext.checkPolicyFile = true;
        var urlRequest:URLRequest = source is URLRequest ?
            source as URLRequest : new URLRequest(source as String);
        loader.load(urlRequest, loaderContext);
    }

这里告诉 Loader 它将用来获取图像以检查源域的 crossdomain.xml 文件.这是指向该 crossdomain.xml 文件的链接.

Here it is telling the Loader that it will use to fetch the image to check the source domain's crossdomain.xml file. Here is a link to that crossdomain.xml file.

他们的 crossdomain.xml 文件专门允许来自不同 ebay 域的 Flash 应用程序访问 i.ebayimage.com 上的内容.我刚刚扫描了它,但我没有看到任何允许通配符 (allow-access-from domain="*") 以便允许非 ebay 域的内容.因此,除非 ebay 允许,否则您将永远无法在 Flash 应用中使用这些图片.

Their crossdomain.xml file is specifically allowing Flash apps from various ebay domains to access the content on i.ebayimage.com. I just scanned it, but I don't see anything there allowing a wildcard (allow-access-from domain="*") so that non-ebay domains are permitted. So you will never be able to use those images in a Flash app, unless ebay allows you to.

在您执行以下任一操作之前,您可能应该确定你正在做的事情的合法性.

实际上,我收回那句话.您将永远无法使用 Flex ImageBitmapImage 组件来加载这些图像,因为这些组件会检查策略文件.但是,您有几个选择:

Actually, I take that back. You will never be able to use the Flex Image or BitmapImage components to load these images because those components check the policy file. However, you have a few options:

  • 扩展 BitmapImage 类并覆盖 loadExternal() 方法,这样它就不会检查策略文件
  • 使用您自己的Loader 来显示图像.这是 Flex 应用程序内部的更多工作,但它确实有效(我刚刚使用一个简单的 AS3 应用程序对其进行了测试).
  • extend the BitmapImage class and override the loadExternal() method so it doesn't check the policy file
  • Use your own Loader to show the images. This is a bit more work inside of a Flex app, but it works (I just tested it w/a simple AS3 app).

这是我测试的非常基本的 AS3 应用程序(不使用 Flex):

Here's the very rudimentary AS3 application I tested with (not using Flex):

package
{
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.net.URLRequest;

    public class As3Project extends Sprite
    {

        private var loader:Loader;

        function As3Project()
        {
            loader=new Loader();
            var url:URLRequest = new URLRequest("http://i.ebayimg.com/00/s/MTA2MlgxNjAw/%24T2eC16JHJG%21E9nm3pkoZBQDVSKHsow%7E%7E60_1.JPG?set_id=880000500F");
            loader.load(url);
            addChild(loader);
        }
    }
}

这篇关于我如何使用 BINDABLE 和具有 urlencoded 值的 JSON 节点值让这个图像 url 显示在 flashbuilder 4.5 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 00:46