Last active
September 29, 2016 19:25
-
-
Save marchbold/8cce8b5804b520f23aba to your computer and use it in GitHub Desktop.
Load a packaged file from a 'www' directory into a WebView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Here we assume you have previously initialised the extension | |
| var webView:WebView = NativeWebView.service.createWebView( new Rectangle( 0, 0, 400, 600 ) ) ; | |
| var file:File; | |
| var fileUrl:String; | |
| if (NativeWebView.service.version.indexOf("Android") > 0) | |
| { | |
| // Android: Copy the application packaged files to an accessible location | |
| var packagedWWWRoot:File = File.applicationDirectory.resolvePath( "www" ); | |
| var destination:File = File.applicationStorageDirectory.resolvePath( "www" ); | |
| packagedWWWRoot.copyTo( destination, true ); | |
| // Grab the file url | |
| file = File.applicationStorageDirectory.resolvePath( "www/example.html" ); | |
| fileUrl = "file://"+file.nativePath; | |
| } | |
| else | |
| { | |
| // iOS: | |
| file = File.applicationDirectory.resolvePath( "www/example.html" ); | |
| fileUrl = "file://"+file.nativePath; | |
| } | |
| webView.loadURL( fileUrl ); | |
| // com.distriqt.NativeWebView |
Author
Line 7 has an error.
It should be NativeWebView.service.implementation instead of NativeWebView.service.version
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://airnativeextensions.com/extension/com.distriqt.NativeWebView