Friday, May 13, 2011

HTML in AIR: Part 3

Today we will learn how to control cookies, about setting default values for certain properties and we will start learning about scrolling.

Some webpages store some data in local files that are controlled by the web browser. These files are called cookies. Some web pages would even not work correctly without cookies.

By default, AIR saves cookies for web pages that you view in your AIR application. But there are some reasons because of which the user might not want to save the cookies, so we need to give him this ability.

We can turn off cookies by setting the manageCookies property of your HTMLLoader object to false (it is true by default). Then the AIR application will not save and read any cookies.

myHtml.manageCookies = false;

All of the HTMLLoader object properties have default values (for example, the manageCookies property is set to true by default, unless you change it manually). You can set the default values manually too. For that, you need to set the needed values to the properties with the same names to the URLRequestDefaults class (they are all static properties).

You can set default values for authenticate, useCache, cacheResponse, userAgent and manageCookies properties.

URLRequestDefaults.manageCookies = false;

All HTMLLoader objects will later take their default values from the URLRequestDefault class. You can always manually change a property's value from default to whatever you want for a HTMLLoader object.

The next thing we're going to learn about is the scrolling of HTML content in our AIR application.

If you set your HTMLLoader object's height to, say, 500 pixels, and the height of the actual loaded page is more than that, for example 700, the user needs to be able to scroll the content. By default, he can already do that using the up-down arrows on his keyboard or by scrolling their mouse wheel.

There are 2 HTMLLoader properties that you can use to scroll the content, and those are: scrollH and scrollV. The first one is responsible for the horizontal scrolling, and the second - for the vertical one. If the value of a property is 0, that means that the content is in the same position as the container on the axis. If the value is positive - the content is scrolled by that amount of pixels on the axis.

We will make a scrollbar in the next tutorial.

Thanks for reading!


HTML in AIR: Part 1
HTML in AIR: Part 2
HTML in AIR: Part 4
HTML in AIR: Part 5
HTML in AIR: Part 6
HTML in AIR: Part 7
HTML in AIR: Part 8
HTML in AIR: Part 9
HTML in AIR: Part 10
HTML in AIR: Part 11
HTML in AIR: Part 12
HTML in AIR: Part 13
HTML in AIR: Part 14
HTML in AIR: Part 15
HTML in AIR: Part 16
HTML in AIR: Part 17

1 comment:

logiciel turf said...

Hi, is this working in an Air application ?

Post a Comment