API: swfstore YAHOO.util.SWFStore (YUI Library)

# Yahoo! UI Library

### swfstore 2.8.1

Yahoo! UI Library > swfstore > YAHOO.util.SWFStore
Search:
Filters Show Private Show Protected Show Deprecated

## Class YAHOO.util.SWFStore - uses YAHOO.util.AttributeProvider

Class for the YUI SWFStore util.

### Constructor

YAHOO.util.SWFStore `( containerId , shareData , useCompression )`

Parameters:
  `containerId <HTMLElement>` Container element for the Flash Player instance.
  `shareData <Boolean>` Whether or not data should be shared across browsers
  `useCompression <Boolean>` Container element for the Flash Player instance.

#### Properties inherited from YAHOO.util.AttributeProvider:

`_configs`

#### Properties inherited from YAHOO.util.EventProvider:

`__yui_events, __yui_subscribers`

### Methods

#### addListener

`void addListener ( type , listener )`
Method to attach listeners to events

Parameters:
  `type <String>` The tyep of event to listen for
  `listener <String>` The function to call

#### calculateCurrentSize

`Number calculateCurrentSize ( )`
Gets the current size, in KB, of the amount of space taken by the current store. Note that this is calculated, and may take time depending on the number of items stored

Returns: `Number`
  The size of the store in KB

#### clear

`void clear ( )`
Removes all data in local storage for this domain.

Be careful when using this method, as it may remove stored information that is used by other applications in this domain

#### displaySettings

`void displaySettings ( )`
Displays the settings dialog to allow the user to configure storage settings manually. If the SWF height and width are smaller than what is allowable to display the local settings panel, an openExternalDialog message will be sent to JavaScript.

#### getItems

`Object getItems ( )`
Returns the items in storage as an array.

Returns: `Object`
  The data.

#### getLength

`Number getLength ( )`
Returns the number of items in storage, if any.

Returns: `Number`
  The number of items

#### getModificationDate

`Date getModificationDate ( )`
Gets the timestamp of the last store. This value is automatically set when data is stored.

Returns: `Date`
  A Date object

#### getShareData

`Boolean getShareData ( )`
Public accessor to the unique name of the SWFStore instance.

Returns: `Boolean`
  Whether or not data is being shared among browsers

#### getTypeAt

`String getTypeAt ( location )`
Returns the data type of of the storage.

May be one of the following types:

- boolean
- function
- number
- object
- string
- number
- xml

Parameters:
  `location <Number>` The index of the "cookie" or store

Returns: `String`
  The type

#### getTypeOf

`String getTypeOf ( location )`
Returns the data type of of the storage.

May be one of the following types:

- boolean
- function
- number
- object
- string
- number
- xml

Parameters:
  `location <String>` The name of the "cookie" or store

Returns: `String`
  The type

#### getUseCompression

`Boolean getUseCompression ( )`
Public accessor to the unique name of the SWFStore instance.

Returns: `Boolean`
  Whether or compression is being used

#### getValueAt

`Object getValueAt ( index )`
Returns the value of the store at the specified index, if any.

Parameters:
  `index <Number>` The index of the stored item

Returns: `Object`
  The value of the store at that index

#### getValueOf

`Object getValueOf ( location )`
Returns the value of the item in storage, if any.

Parameters:
  `location <String>` The name of the "cookie" or store

Returns: `Object`
  The data

#### hasAdequateDimensions

`Boolean hasAdequateDimensions ( )`
Determines if SWF's visible area is large enough to fit the settings panel

Returns: `Boolean`
  Whether or not to share among browsers

#### on

`void on ( type , listener )`
Method to attach listeners to events

Parameters:
  `type <String>` The tyep of event to listen for
  `listener <String>` The function to call

#### removeItem

`void removeItem ( location )`
Removes the item in storage, if any.

Parameters:
  `location <String>` The name of the "cookie" or store

#### setItem

`Boolean setItem ( data , location )`
Saves data to local storage. It returns a String that can be one of three values: "true" if the storage succeeded; "false" if the user has denied storage on their machine or storage space allotted is not sufficient.

The size limit for the passed parameters is ~40Kb.

Parameters:
  `data <Object>` The data to store
  `location <String>` The name of the "cookie" or store

Returns: `Boolean`
  Whether or not the save was successful

#### setShareData

`void setShareData ( Whether )`
Public accessor to the unique name of the SWFStore instance.

Parameters:
  `Whether <Boolean>` or not to share among browsers

#### setSize

`String setSize ( value )`
This method requests more storage (if the amount is above 100KB or the current setting). The request dialog has to be displayed within the Flash player itself so the SWF it is called from must be visible and at least 215px x 138px (w x h) in size.

Parameters:
  `value <Number>` The size, in KB

#### setUseCompression

`void setUseCompression ( Whether )`
Public accessor to the unique name of the SWFStore instance.

Parameters:
  `Whether <Boolean>` or to compress stored data

#### toString

`String toString ( )`
Public accessor to the unique name of the SWFStore instance.

Returns: `String`
  Unique name of the SWFStore instance.

#### Methods inherited from YAHOO.util.AttributeProvider:

`configureAttribute, fireBeforeChangeEvent, fireChangeEvent, get, getAttributeConfig, getAttributeKeys, refresh, register, resetAttributeConfig, resetValue, set, setAttributeConfig, setAttributes`

#### Methods inherited from YAHOO.util.EventProvider:

`createEvent, fireEvent, hasEvent, subscribe, unsubscribe, unsubscribeAll`

### Events

#### clear

`clear ( event.type )`
Fires when a store is successfully cleared

Parameters:
  `event.type <String>` The event type

#### error

`error ( event.type , event.message )`
Fires when an error occurs

Parameters:
  `event.type <String>` The event type
  `event.message <String>` The data

#### inadequateDimensions

`inadequateDimensions ( event.type )`
Fires when a settings dialog is not able to be displayed due to the SWF not being large enough to show it. In this case, the developer needs to resize the SWF to width of 215px and height of 138px or above, or display an external settings page.

Parameters:
  `event.type <String>` The event type

#### openingDialog

`openingDialog ( event.type )`
Fires as the settings dialog displays

Parameters:
  `event.type <String>` The event type

#### quotaExceededError

`quotaExceededError ( event.type , event.message )`
Fires when there is not enough space available to store the data

Parameters:
  `event.type <String>` The event type
  `event.message <String>` The data

#### save

`save ( event.type )`
Fires when a store is saved successfully

Parameters:
  `event.type <String>` The event type

#### securityError

`securityError ( event.type , event.message )`
Fires when the url matching for the security whitelist is invalid. If no whitelist is used, fires when page's url does not match the embedded swf's url

Parameters:
  `event.type <String>` The event type
  `event.message <String>` The data

Copyright © 2010 Yahoo! Inc. All rights reserved.