user1712570
user1712570

Reputation: 41

Why won't dynamically loaded images in flash as3 display in Google Chrome?

I am working on a flash game where some of the content can vary from web page to web page depending on HTML parameters. Unfortunately, when I try to load the images in Google Chrome and send the bitmap itself to the stage, nothing shows up. I have been able to identify that this undesirable is due to the Pepper Flash plugin that comes with Chrome, as it works with the manually installed flash plugin.

It will be a pain for the user to have the users download a plugin that they think they already have just to use my game. It is necessary for my game to access the bitmaps themselves, because they will change color. How can I work around the undesirable behavior in Chrome's Pepper Flash plugin?

Below is a sample of what I am doing.

        private function init(e:Event = null):void 
    {
        removeEventListener(Event.ADDED_TO_STAGE, init);
        // entry point

        //could be any image, as long as image1.jpg is in the images directory relative to the HTML page
        //eventually will be taken from a parameter.
        var url:String = "images/image1.jpg";
        var request:URLRequest = new URLRequest(url);
        loader = new Loader();
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
        loader.load(request);

    }

    private function loaded(e:Event):void
    {
        image = Bitmap(loader.content);
        image.bitmapData.colorTransform(new Rectangle(0, 0, image.bitmapData.width, image.bitmapData.height), new ColorTransform(2, 1, 0.5, 0.25, 10, 10, -10, -10));
        graphics.beginBitmapFill(image.bitmapData);
        graphics.drawCircle(stage.stageWidth/2, stage.stageHeight/2, (image.width + image.height) / 4);
        graphics.endFill();

    }

There will be transformations other than this sample, but unless there is a way around this glitch/undesired feature/bug, the game can not be played properly on the average Google Chrome browser without work for the user.

Upvotes: 4

Views: 544

Answers (1)

dtudury
dtudury

Reputation: 639

push it onto a server. chrome has some extra security when you're running from localhost.

Upvotes: 1

Related Questions