views:

257

answers:

4

Hi,

I'm looking for a way to "inject" some events into a flash movie running on a browser. I know about ActionScript's ExternalInterface.addCallback function, however I'm trying to achieve this with any "random" flash from the web. Eg. send a "SPACE" keyboard event to a youtube video.

A: 

Unless Flash is configured to listen for the events you're trying to send it, my guess is that what you want to do isn't possible. But, as my wife will surely tell you, I'm wrong a lot.

inkedmn
A: 

I'm pretty sure that this isn't possible, unless the developer of the .swf actually includes ExternalInterface to get your input =P

In other words, I don't think you can do this, though I might be wrong.

ItzWarty
+1  A: 

You can't do this to any random swf on any website because of security limitations. You need to have access to the DOM, which can only be done by Javascript Injections, unless you are the one with the swf embedded in the site, with allowScriptAccess="always" in the html template. MySpace, for example, allows you to add any random swf to the html page, but you can't do that javascript stuff because they force allowScriptAccess to always be false (among other things) to prevent any javascript/dom access.

If this is just for you to make your own life easier while browsing, you can use Firebug for Firefox. Check out this JQuerify Bookmarklet and Video, Hacking Digg with Firebug and JQuery. It shows you how to dynamically modify the webpage your on using javascript, and save those commands as shortcuts! Super cool.

So you could save a JQuerify command like:

$("#youtube_player").play();

...or whatever the api is for starting a youtube video in their html page, if that's even possible.

Hope that helps, Lance

viatropos
I'm pretty familiar with firebug and even the injection of js on pages. In fact I'm kinda looking for an injection of js that would in turn inject the keystrokes into the flash.Anyway, the allowScriptAccess bit I didn't knew about. Do you think its possible to achieve this by other means, e.g. a FF addon?
Alexandre Gomes
I'm pretty sure you could do that with a Firefox addon, I don't know anything about the details though. Injecting keystrokes, that would be cool, I'm going to see if that's possible right now! Other than that, I don't see how you could know what to click inside the youtube swf.
viatropos
Ya it would be very cool. I'm not looking for a God algorithm that will figure everything out like where are the buttons and stuff. My real requirement is to be able to send keystrokes and mouse events to the flash movie everything else I can handle nicely.
Alexandre Gomes
A: 

Any new ideas??

Milkywayfarer