Linking to local files in StageWebView
I have been working with StageWebView in a Flex Mobile AIR project recently. StageWebView uses the native web view on whatever device the AIR app is running. This means the text scrolling is very responsive and you inherit a bunch of functionality that an AS3 based component does not offer. For example, on Android you get pinch zoom and auto text-reflow. I need the text to have simple formatting which includes hyperlinks that link to other “pages”. It just so happens that storing the files in individual html files and loading them into a StageWebView instance solves this use case nicely.
It’s not so simple though. A hyperlink touch fails to load the local page since the StageWebView tries to go out to the web to load the URL supplied by the anchor tag. I found the solution was to hijack the page load on the LocationChangeEvent.LOCATION_CHANGING event and replace it with content loaded from the local html file using an URLLoader. You can see my code example here: http://github.com/randytroppmann/StageWebView—linking-local-files/blob/master/src/GreyRectangleStageWebViewBug.as.

Hi,
I have make a little library to do this… And more… See it at http://code.google.com/p/stagewebviewbridge/
That’s sweet. Thanks for sharing.
very cool! Any chance this method could be updated to support a .css file along side the html file?
I had the same thought but have not gotten around to tackling it. The problem is that you don’t know the URL to the css. You could load the CSS separately and inject it into the HTML text before applying it the the Stage Web View. Hmmmm … gotta try that.