Use a hybrid of Javascript AND Flash. So Flash triggers the function for the Javascript to do the DOM/HTML manipulation.
In flash you will call the External library to pass some essential parameters to the JS.
it goes like this in AS3:
import flash.external.*;
...
ExternalInterface.call("JavascriptFunctionName", escape(param1), escape(param2));
In JavaScript:
JavascriptFunctionName = function(_param1, _param2){
CreateHTMLElement(unescape(_param1));
CreateMenuItem(unescape(_param2));
}
If you are passing a lot of data, I'd suggest using a php proxy/webservice.