问题
Can I create a flash file which will be used as web-browser. So basically, Flash will behave like Internet Explorer or Firefox, perhaps like loading a page inside iframe.
Is this possible?
回答1:
No this is not really possible¹. Flash is displayed within the Flash Player which is already run inside a browser. So even if it was possible, you would need to run a Browser to run the Flash Player to then run your “webbrowser”. In addition to that, Flash is not able to render HTML, so it cannot be used to display web content directly.
The only alternative would be using Adobe AIR, the desktop runtime environment for Flash content which ships with the Webkit browser. That browser framework is also used for Browsers like Chrome and Safari. But doing that will give you no benefit if all your application is supposed to do is mimic a browser. The Webkit browser included in AIR only contains the most basic modules, and a lot things people usually expect from browsers won't be able available.
¹ As mentioned in the comments, it probably would be possible to implement a full HTML rendering engine in ActionScript. It would however require a lot of effort, especially if you want to get just nearly a similar good coverage of what current browsers are able to do. Given that Flash is run inside of the Flash Player, technically a virtual machine, that itself runs embedded in browsers², performance would be rather bad however. So apart from the fact that it’s theoretically possible, I don’t think there will be any benefit from working in that direction (again: especially not if you just want to mimic a normal browser for the same reasons as above).
² Before another comment comes up on this; Flash can be compiled to an executable, so it does not need to run inside a browser. There are various ways to do that, but overall the situation does not get better that way. You would be better off using AIR then (which then already features Webkit for rendering).
回答2:
I mean you could do it (kinda), but the time it would take it get working properly would be insanity and non-worthwhile.
You'd have to cover these things for starters:
- Create a small system that loads (via PHP) the content of a sought web-document. (the easy part).
- Develop your own rendering engine with AS3 that reads the document (achievable with the inbuilt XML class) and then works out what needs to happen with each node. For example, it could pick out the
<img>tags and load the appropriate images into position and strip out + render any text. - (This is when it gets not-worthwhile) create a system that will load and read the appropriate CSS documents and apply them to your to-be-rendered content - this would take a lot of dedication to get working properly I imagine.
As for JavaScript or similar - unless you're going to create an additional system that somehow translates JavaScript manipulation of HTML into AS3 manipulation of your Flash objects you'll probably have to scrap this.
Basically - it's achievable (partially) but not viable. You won't be able to cover about ~75% of what a browser itself can do, and more importantly: that's what browsers are there for.
来源:https://stackoverflow.com/questions/8057294/is-there-a-webbrowser-that-can-run-inside-flash-player