I always thought of myself as being quite good at learning the most basic things with the help of Google and a cup of coffee, but when trying to get my head around basic Adobe AIR development, I have totally failed.
Apparently there's plenty of tutorials about loading data from local storage as well as remote places (Ajax), but I have yet not seen a clear i开发者_JS百科nstruction on how to navigate between the .html pages in the Applications directory.
Obviously <a href="" />
isn't going to cut it, so my guess is that I need some DOM javascript magic to do it, which I yet not have seen.
How can I navigate between .html
pages in my applications directory properly?
Thanks
Ok, I understand what you are doing. I hand't realized that an Air app can be an embedded HTML document with javascript hooks to the Air framework. Pretty cool! More information can be found here: http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7ecc.html
Anyways, since it is just HTML, all of the HTML rules apply. I have a little "Hello World" app that uses both anchor navigation as well as javascript navigation:
<html>
<head>
<title>Hello World</title>
<script type="text/javascript" src="AIRAliases.js"></script>
<script type="text/javascript">
function appLoad(){
air.trace("Hello World");
}
</script>
</head>
<body onLoad="appLoad()">
<h1>Hello World</h1>
<a href="AirHTML2.html">Go Next</a>
<button onClick="location.href = './AirHTML2.html'">Go Next</button>
</body>
</html>
In either case (clicking the link or clicking the button which calls location.href
, I successfully navigate from one page to the next.
It didn't work for me at first, but that was because I wasn't packaging the second page with the application. In my case, I just had to add the AirHTML2.html
page to the adt
packager, but I don't know how you are building your app... what environment are you using?
Anyways, it all seems pretty straight forward, actually. :)
Use the HTMLLoader class.
It has methods to go back and forward like you do with a regular browser.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/html/HTMLLoader.html
精彩评论