views:

223

answers:

1

is it possible to extract dynamic loaded text from a swf (flash application) programatically ?

A: 

I've got one thing in mind.

If you load the swf, you can access its children in the INIT handler, so you could use a recursive function to loop through all the children automatically and get all children that are TextFields( dynamic text ), as statis text is TextSnapshot.

Here's a simple implementation:

var textFields:Array = [];
function getTextFields(container:DisplayObjectContainer,dumpArray:Array):void{
    for(var i:int = 0 ; i < container.numChildren ; i++){
     if(container.getChildAt(i) is TextField) dumpArray.push(container.getChildAt(i));
     if(container.getChildAt(i) is DisplayObjectContainer) getTextFields(DisplayObjectContainer(container.getChildAt(i)),dumpArray);
    }
}
//getTextFields(this,textFields);

Sounds like some kind of crawler. What do you have in mind ?

George Profenza
Yes, that's what I need to do, I'm indexing text in a lot of swfs (from several websites), but I can't programatically extract the dynamic text, I can find several tools (I think i downloaded them from swftools) to extract static text, but the dynamic... I still don't have a clue...
there is a catch though.you will get the text in those fields as it is set. if the same textield is used for and intro and an about section in a basic swf file, you might only get the intro, since there no one dispatching the events to trigger all the content. You might need to write some sort of robot, to perform virtual click and inputs to anything that can receive that in a swf,and fast. I think that's how google indexes swfs,but they have special version of flash player for that.like a dummy autopilot version of the player. can you share more thoughts on what you want to do with the data?
George Profenza
Well, I've a backend system written (almost entirely) in JRuby, where I'm indexing all sorts of things, from html documents, to the text in images, and I'm trying to index, also, swf objects. The biggest problem I'm facing is my non-existence knowledge of Flash or Actionscript, so I have no clue where to start (not planning to write a flash movie player =) ) isn't there an open source version of a player that can be easily adapted ?
Hmmm. I think you will encounter another issue, among others: security policy files(crossdomain.xml). If you have a swf on siteA and you load and access the contents of one from siteB, siteB will need a security policy file that will allow to do that, otherwise you will get a security error when trying to access the contents of siteB's swf. Adobe and Google worked together to get that player done, so I doubt it is open source out there. Right now I'm wandering if you can use Google's search API and 'borrow' data, including swfs. don't know what's the policy on caching google search results.
George Profenza