Custom images for HTMLLoader
There is powerful HTMLLoader
component for AIR wrapped in mx:HTML
for Flex.
I want to supply images manually (ideally from bytes) for mx:HTML,
which will display my generated content. The point is to pack all resources in the application without external files. I can pack different html pages in the app and switch them when mx:HTML
dispatches Event.LOCATION_CHANGE.
Now I want the same for images. What do you开发者_StackOverflow中文版 suggest?
Solved! Went through several stages:
- Make HTMLLoader's background transparent with
paintsDefaultBackground="false"
andbackgroundAlpha="0"
. Get notified of pictures location with javascript and draw them on HTMLLoader's graphics. This is complex and has problems with resizing (pictures get shifted), but was almost done... - Next idea - use <canvas> to draw images on them, sending data to javascript.
- While reading canvas tutorials, stumbled upon data URI scheme, which does exactly what I needed in simplest possible way. Images are embedded in html page in base64 encoding.
精彩评论