本文介绍了我怎么得到这个图片的URL中显示flashbuilder 4.5使用可绑定的,并已urlen一个JSON节点值codeD值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在flashbuilder 4.5移动应用即时通讯即时通讯装载JSON工作,到目前为止,所有的变量呈现细,我用左,右轻扫手势,让用户能够通过移动项目的阵列 - 使用ActionScript3的。

现在我得到的地方,进出口工作在添加图片到具有其绑定到一个变量(thisimg2),其值source参数的阶段,部分是图像URL的JSON值... URL的一个例子是

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

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

的JSON URL值很小的比例回来的非常简单的图片网址,没有十六进制值以及显示就好了,但大多数的,出现像2例以上,不渲染在所有和公正的结果在弯曲的破图像/问号(使用台式机的调试/仿真器)。我试着在URL字符串,但没有工作去code。

当我把网址在我的浏览器,他们做工精细,并呈现在浏览器中。

有什么我可以做的到的URL,让他们的工作?

解决方案

可以提供为你工作的URL的例子吗?

我相信,易趣是专门$使用他们的形象来自其他域p $ pventing的Flash应用程序。

的URL编码是没有问题的...... Flash只依赖于浏览器下载它们。然而,看看这个code中的的BitmapImage 组件内部深埋(这是基本的东西,星火图片组件使用):

的BitmapImage :: loadExternal()(行1513)

 尝试
    {
        loaderContext.checkPolicyFile = TRUE;
        VAR的URLRequest:的URLRequest =源的URLRequest?
            源作为的URLRequest:新的URLRequest(来源为String);
        loader.load(的URLRequest,的LoaderContext);
    }
 

这是告诉装载机,它会用它来获取图像检查源域的crossdomain.xml文件。下面是到crossdomain.xml文件一个链接。

他们的crossdomain.xml文件是专门让来自不同易趣领域的Flash应用程序来访问i.ebayimage.com内容。我只是扫描,但我没有看到任何允许有一个通配符(允许存取来自域=*),以便非易趣域是允许的。所以,你将永远无法在Flash应用程序中使用这些图像,除非易趣允许你。

在你做下面的事情之一,你应该的确定你在做什么的合法性。

其实,我收回那句话。你将永远无法使用Flex 图片的BitmapImage 组件来加载这些图像,因为这些组件检查策略文件。但是,你有几种选择:

  • 延长的BitmapImage 类和重写 loadExternal()方法,因此它不会检查策略文件
  • 使用自己的装载机来显示图像。这是一个Flex应用程序内多做一些工作,但它的工作原理(我只是测试它瓦特/一个简单的AS3的应用程序)。

这里是非常基本的AS3应用我有(没有使用Flex)测试:

 包
{
    进口flash.display.Loader;
    进口flash.display.Sprite;
    进口flash.net.URLRequest;

    公共类As3Project扩展Sprite
    {

        私人VAR装载机:装载机;

        功能As3Project()
        {
            装载机=新的Loader();
            VAR URL:的URLRequest =新URLRequest("http://i.ebayimg.com/00/s/MTA2MlgxNjAw/%24T2eC16JHJG%21E9nm3pkoZBQDVSKHsow%7E%7E60_1.JPG?set_id=880000500F");
            loader.load(URL);
            的addChild(装载机);
        }
    }
}
 

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.

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

and

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

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.

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

解决方案

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

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

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() (line 1513)

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

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.

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.

[Edit]

Before you do one of the things below, you should probably determine the legality of what you're doing.

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:

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

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);
        }
    }
}

这篇关于我怎么得到这个图片的URL中显示flashbuilder 4.5使用可绑定的,并已urlen一个JSON节点值codeD值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 00:45