Steve
Steve

Reputation: 4213

Can a Flash application alter the HTML of the page it's on?

Suppose I have a flash application; let's say a chess game. The user is playing against a computer opponent. After every move, I want the flash application to add the move's "description" into the HTML of the page.

Does flash have this ability?

Are there any common round-about ways of doing this? Maybe the flash app updates a database, and some AJAX on the page frequently checks the database and adds content when appropriate.

Are there any examples on the web of this type of functionality?

Upvotes: 1

Views: 160

Answers (3)

grateful.dev
grateful.dev

Reputation: 1437

Your ActionScript code can access javascript methods that update the page's DOM.

You can access Javascript methods using the ExternalInterface class. more details at: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html

Upvotes: 1

gdelfino
gdelfino

Reputation: 11181

I see in my ActionScript 3.0 Bible, chapter 36 "Interfacing with JavaScript" that you can use flash.external.ExternalInterface to "both call JavaScript functions from Flash and to call ActionScript functions from JavaScript".

Therefore, you can change any DOM element from a JavaScript that you activate from Flash.

Upvotes: 1

Paul Dixon
Paul Dixon

Reputation: 300835

From ActionScript, you can use ExternalInterface to call Javascript functions in the client browser, so yes, this is possible.

Upvotes: 3

Related Questions