Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6321561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:10:16+00:00 2026-05-24T16:10:16+00:00

I am trying to capture a still frame from an (any) external swf file,

  • 0

I am trying to capture a still frame from an (any) external swf file, by using my own flash movie as a proxy to load it and hand information regarding the Stage onto javascript. I want to keep it as wide compatible as possible, so I went with AS2 / Flash 8 for now.

The script works fine in the Flash debugger, i.e. the

trace(flash2canvasScreenshot.getPixel(w, h).toString(16));

returns the correct pixel color, where as:

ExternalInterface.call("sendToJS",flash2canvasScreenshot.getPixel(w, h).toString(16));

in the published movie doesn’t.

This method can obviously be quite slow for large flash (dimension wise) movies, as it iterates every single pixel. If someone has any better methods in mind, feel free to share, but as said, the problem I am facing is that I am getting differentiating results in debugging and publishing, with the pixel information not getting fetched when published.

import flash.display.BitmapData;
import flash.external.*;

var myLoader:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();

mclListener.onLoadInit = function(target_mc:MovieClip)
{

        var stageW = Stage.width;
        var flash2canvasScreenshot:BitmapData = new BitmapData(stageW, Stage.height, false, 0x00000000);
        var pixels:Array = new Array();
        flash2canvasScreenshot.draw(element);

        for (w = 0; w <= stageW; w++)
        {
            trace(flash2canvasScreenshot.getPixel(w, h).toString(16)); // this gives correct color value for the pixels in the debugger
            ExternalInterface.call("sendToJS",flash2canvasScreenshot.getPixel(w, h).toString(16)); // this just returns the bitmap default color, 0 in this case.
            /*
            for (h = 0; h <= Stage.height; h++)
            {
                var pixel = flash2canvasScreenshot.getPixel(w, h).toString(16);
                pixels.push(pixel);
            }
            */
        }

        //ExternalInterface.call("sendToJS",pixels.toString());*/



};


myLoader.addListener(mclListener);

myLoader.loadClip("http://i.cdn.turner.com/cnn/cnnintl_adspaces/2.0/creatives/2010/6/9/21017300x250-03.swf", 0);
//myLoader.loadClip("https://s.ytimg.com/yt/swfbin/watch_as3-vflJjAza6.swf", 0);

//myLoader.loadClip(_level0.flash2canvasurl, _root.mc);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:10:18+00:00Added an answer on May 24, 2026 at 4:10 pm

    There are few problems with the snippet you posted:

    1. like the one Joey mentioned, but the one that stands out from my
      point of view is the element variable which isn’t defined
      anywhere, so that either is a type o, or you’re trying to draw an
      undefined object.
    2. You’re drawing as soon as the load is finished, but the animation you’re loading might start slightly later. Maybe take the snapshot a bit after the load is complete.
    3. Haven’t touched as2 for some time and don’t remember how security issue are handled, but if you’re swf is loading another swf from a different domain, then the domain hosting the swf you’re loading should also have a crossdomain.xml policy file allowing you to access the content of the loaded swf. If you simply load and display a swf from another domain, that’s fine. However, if you’re trying to draw the swf using BitmapData, you’re actually attempting to access pixel data from the content of that swf, therefore you would need permissions. If you have no control over the crossdomain policy file, you might need to use a server side script to copy/proxy the file over to a domain that can grant your loaded swf access.

    Here’s a simplified version of your snippet that works (sans the external interface/pixel values part):

    var myLoader:MovieClipLoader = new MovieClipLoader();
    var mclListener:Object = new Object();
    mclListener.onLoadInit = function(target_mc:MovieClip)
    {
        var pixels:Array = new Array();
        setTimeout(takeSnapshot,2000,target_mc);
    }
    
    myLoader.addListener(mclListener);
    myLoader.loadClip("http://www.bbc.co.uk/science/humanbody/sleep/sheep/reaction_version5.swf",1);
    //myLoader.loadClip("http://i.cdn.turner.com/cnn/cnnintl_adspaces/2.0/creatives/2010/6/9/21017300x250-03.swf", 1);
    //myLoader.loadClip("https://s.ytimg.com/yt/swfbin/watch_as3-vflJjAza6.swf", 0);
    
    function takeSnapshot(target:MovieClip):Void {
        var flash2canvasScreenshot:BitmapData = new BitmapData(150, 150, false, 0x00000000);//tiny sample
        flash2canvasScreenshot.draw(target);
        _level1._alpha = 20;//fade the loaded content
        _level0.attachBitmap(flash2canvasScreenshot,0);//show the snapshop. sorry about using _root
    }
    

    Here’s a quick zoomed preview of the 150×150 snap:
    preview

    Here’s an as3 snippet to illustrate the security sandbox handling issue:

    var swf:Loader = new Loader();
    swf.contentLoaderInfo.addEventListener(Event.COMPLETE,loaderComplete);
    swf.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR,loaderSecurityError);
    swf.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,loaderIOError);
    swf.load(new URLRequest("http://i.cdn.turner.com/cnn/cnnintl_adspaces/2.0/creatives/2010/6/9/21017300x250-03.swf"),new LoaderContext(true));
    
    function loaderComplete(event:Event):void{
        setTimeout(takeSWFSnapshot,2000);
    }
    function loaderSecurityError(event:SecurityErrorEvent):void {
        trace('caught security error',event.errorID,event.text);
    }
    function loaderIOError(event:IOErrorEvent):void{
        trace('caught I/O error',event.errorID,event.text,'\tattempting to load\t',swf.contentLoaderInfo.url);
    }
    function takeSWFSnapshot():void{
        var clone:BitmapData = new BitmapData(swf.content.width,swf.content.height,false,0);
        try{
            clone.draw(swf.content);
        }catch(e:SecurityError){
            trace(e.name,e.message,e.getStackTrace());
        }
        addChild(new Bitmap(clone));
    }
    

    HTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a test list that I am trying to capture data from using
I trying to capture packets using SharpPcap library. I'm able to return the packets
I am trying to capture output from an install script (that uses scp) and
I'm trying to capture packets from two devices on my network. I have tcpdump
I'm new here. I have been trying to create a video capture app using
I am trying to create a control that allows capture of a still image
I recently upgraded my Flash Builder from Burrito to 4.5 Premium. I am trying
I'm trying to capture key down events from the MainWindow, but I have a
I'm trying to capture a UILabel's height in an instance variable. I'm using a
I am trying to capture sub-strings from a string that looks similar to 'some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.