【问题标题】:actionscript3 (flash) don't load images form user file in chromeactionscript 3 (flash) 不会从 chrome 中的用户文件加载图像
【发布时间】:2012-12-12 00:19:34
【问题描述】:

我正在尝试编写 Flash 小程序,用户可以在其中从硬盘上传图像。
所以 actionscript 将编辑图像并将其发送到服务器。
加载图像在 flash player、firefox 和 opera 中工作,但在选择图像后在 chrome 中停止。
我正在使用 flashdevelop。
这是我的代码:

public class Main extends Sprite 
{

    [Embed(source = "../lib/lena.png")]
    private var layer0Class : Class;
    private var layer0:Bitmap = new layer0Class();

    private var fileReferenceSelect:FileReference = new FileReference();

    public function Main():void 
    {
        if (stage) init();
        else addEventListener(Event.ADDED_TO_STAGE, init);
    }

    private function init(e:Event = null):void 
    {
        removeEventListener(Event.ADDED_TO_STAGE, init);
        /// add image to flash scene
        addChild(layer0);

        /// add button
        var my_button:SimpleButton;
        my_button = new SimpleButton();
        my_button.x = 150;
        my_button.y = 50;
        var cerchio:Shape=new Shape();
        cerchio.graphics.beginFill(0x000000,1);
        cerchio.graphics.drawCircle(my_button.x,my_button.y,20);
        cerchio.graphics.endFill();
        my_button.upState = cerchio;
        my_button.overState = cerchio;;
        my_button.downState=cerchio;
        my_button.hitTestState = my_button.upState;
        addChild(my_button);
        /// button clicked
        my_button.addEventListener(MouseEvent.CLICK,function(m:MouseEvent):void
        {
            fileReferenceSelect.browse([new FileFilter("PNG Files (*.png)","*.png; *.jpg; *.jpeg")]);
        });
        /// file selected
        fileReferenceSelect.addEventListener(Event.SELECT, function(event:Event):void
        {
            fileReferenceSelect.load();
        });
        /// file ready to load
        fileReferenceSelect.addEventListener(Event.COMPLETE, function(event:Event):void
        {
            var ldr:Loader = new Loader();             
            /// file loaded
            ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void {
                var bm:Bitmap = Bitmap(e.target.content as Bitmap); /// here chrome is messing up
                layer0.bitmapData = bm.bitmapData;
            });
            ldr.loadBytes(fileReferenceSelect.data);
        });
    }

}


是不是因为 chrome 的某些限制(我读到 chrome 中的 flash 在沙箱中)?
有更好的方法吗?

【问题讨论】:

  • 您是在服务器上测试还是在本地测试?如果在本地,请尝试使用 chrome 从服务器运行应用程序
  • 我正在测试本地文件。
  • 我没想到它会有所不同。但是现在当我把它放到服务器上时它就可以工作了。感谢您的帮助。你知道它是 chrome 的正常行为,还是我做错了什么,所以它只在服务器上工作?
  • @LovelyHanibal 您可能会遇到安全错误,这可能是由于 Chrome 中没有出现的跨域问题,因为它管理自己的 Flash 播放器插件,并且 Google 在后台推送更新。您可以禁用内置的 Flash 播放器并让它回退到与 Netscape 插件兼容的调试播放器上。搜索详细信息。
  • 罗尼,你基本上回答了我的问题。如果你把它作为答案,我会批准它。
    但我仍然很高兴知道该代码是否会在未来 5 年内在任何流行的浏览器中以这种方式工作。

标签: actionscript-3 flash google-chrome sandbox loader


【解决方案1】:

我在 chrome 中本地加载 Flash 内容时遇到问题。它的 Flash 全局播放器设置。问题是,chrome 内置了自己的 flash 版本..我忘记它叫什么..我认为是胡椒粉?无论如何,它不会一直遵守这个网站的设置:http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html

只要你在网络服务器上测试应该没问题..哎呀,即使是本地网络服务器也可以工作

【讨论】:

  • 添加到这个,另外你可以通过在地址栏中输入chrome://plugins/来禁用胡椒闪光。接下来,单击+详细信息并找到胡椒闪光并将其禁用。只要您安装了插件版本,它就可以工作
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-06
  • 1970-01-01
  • 2013-06-15
相关资源
最近更新 更多