Packagecom.google.code.flexiframe
Classpublic class IFrame
InheritanceIFrame Inheritance mx.core.Container

An IFrame which you can embed into Flex applications to show an HTML page.

Usage:
You must instantiate the IFrame with a unique identifier (such as <IFrame id="myIFrame"> or var myIFrame:IFrame = new IFrame();). You can assign a source (myIFrame.source = "http://www.google.com";) or HTML content (myIFrame.content = "some html content...";).

Advanced features:


Example
A simple application with Google embedded
     <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                     xmlns:flexiframe="http://code.google.com/p/flex-iframe/">
              <flexiframe:IFrame id="googleIFrame"
                            label="Google"
                            source="http://www.google.com"
                            width="80%"
                            height="80%"/>
          <mx:Application>
     
For more advanced examples, check out the project home page.

See also

http://code.google.com/p/flex-iframe


Public Properties
 PropertyDefined by
  applicationId : String = "null"
[static] The SWF embed object id.
IFrame
  content : String
Return content string of div contents
IFrame
  debug : Boolean
Get the state of the debug mode.
IFrame
  idList : Object
[static] Track IDs in use throughout the app for iframe instances in order to detect and prevent collisions.
IFrame
  loadIndicatorClass : Class
A UIComponent class to display centered over the iframe container while the browser is loading its content.
IFrame
  overlayDetection : Boolean = false
The state of the overlay detection system (experimental).
IFrame
  scrollPolicy : String = "auto"
The scrolling policy applied to the iframe.
IFrame
  source : String
Return url of frame contents
IFrame
  visibilityNotificationFunction : String
If you provide the name of JavaScript function here, that function will be called as a notification whenever the frame is hidden or shown due to tab index changes, overlay detection (if enabled), etc.
IFrame
  visible : Boolean
[write-only] Manually sets visibility of html iframe.
IFrame
Protected Properties
 PropertyDefined by
  _appHost : String
[static] Application host.
IFrame
  _browserScaling : Number = 1
The browser zoom ratio
IFrame
  containerDict : Object = null
The dictionnary of the hierarchy of the parent containers.
IFrame
  _content : String
The content of the IFrame.
IFrame
  _debug : Boolean = false
The state of the debug mode.
IFrame
  explicitVisibleValue : Boolean = true
Manually-set visibility value
IFrame
  _frameId : String
The frame ID.
IFrame
  _frameLoaded : Boolean = false
Wether the frame is loaded or not.
IFrame
  _functionQueue : Array
The queued functions waiting for the frame to be loaded.
IFrame
  _iframeContentHost : String
IFrame content host.
IFrame
  _iframeId : String
The IFrame ID.
IFrame
  _loadIndicator : UIComponent
The instance of the load indicator class.
IFrame
  logger : ILogger
The class logger.
IFrame
  logTarget : TraceTarget
The target for the logger.
IFrame
  overlapCount : int = 0
The count of the objects overlapping the IFrame.
IFrame
  overlappingDict : Dictionary
A dictionnary holding the objects overlapping the IFrame.
IFrame
  randomIdentificationString : Number
The random string used to identify the right object.
IFrame
  rootIndex : int = -1
The z-index of this component off the system root
IFrame
  settingDict : Object = null
The dictionnary of the child indexes in the hierarchy of the parent containers.
IFrame
  _source : String
The source of the IFrame.
IFrame
  _validForDisplay : Boolean = true
The validity of the frame for the display.
IFrame
Public Methods
 MethodDefined by
  
IFrame(id:String = null)
Build a new IFrame.
IFrame
  
Bring the IFrame to the front.
IFrame
  
callIFrameFunction(functionName:String, args:Array = null, callback:Function = null):String
Calls a function of the specified name defined on the IFrame document (like document.functionName = function () {...} ), passing it an array of arguments.
IFrame
  
historyBack():void
Load the IFrame's last page in the navigation history.
IFrame
  
Load the IFrame's next page in the navigation history.
IFrame
  
lookupIndex(target:Container):Number
Return index of child item on path down to this object.
IFrame
  
lookupSetting(target:Container):Number
Return index of child item on path down to this object.
IFrame
  
printIFrame():void
Print the content of the IFrame.
IFrame
  
removeIFrame():void
Remove the IFrame.
IFrame
  
setActualSize(w:Number, h:Number):void
Sets actual size When component is sized by its parent, and overlay detection is enabled, checks for existing pop-ups
IFrame
Protected Methods
 MethodDefined by
  
adjustPosition(recalculateBrowserScaling:Boolean = false):void
Adjust frame position to match the exposed area in the application.
IFrame
  
Build list of container objects on the display list path all the way down to this object.
IFrame
  
checkDisplay(target:Object, newIndex:Number):Boolean
This function updates the selected view child of the signalling container and then compares the path from our IFrame up the displaylist to see if the index settings match.
IFrame
  
Called to check for existing pop-ups when the component appears or changes size
IFrame
  
checkObjectId(id:String, randomCode:Number):Boolean
Receive information about a DOM object and test if this is this SWF object.
IFrame
  
checkOverlay(displayObj:DisplayObject):void
Check to see if the given DisplayObject overlaps this object.
IFrame
  
Triggered by change to component properties.
IFrame
  
Generate DOM elements and build display path.
IFrame
  
createIFrame():void
Create the IFrame.
IFrame
  
Get the browser measured width.
IFrame
  
handleAdd(event:Event = null):void
Triggered by addition of this object to the stage.
IFrame
  
handleChange(event:Event):void
Triggered by one of our listeners seeded all the way up the display list to catch a 'changed' event which might hide or display this object.
IFrame
  
Trigered when the IFrame is loaded.
IFrame
  
handleMove(event:Event):void
Triggered by one of our listeners seeded all the way up the display list to catch a 'move' event which might reposition this object.
IFrame
  
handleRemove(event:Event = null):void
Triggered by removal of this object from the stage.
IFrame
  
hideDiv():void
Hide the div.
IFrame
  
hideIFrame():void
Hide the IFrame.
IFrame
  
hitTestStageObject(o:DisplayObject):Boolean
The native hitTestObject method seems to have some issues depending on the situation.
IFrame
  
isAncestor(obj:DisplayObject):Boolean
Use display object ancestry table already built to check whether an object is a container of this component or one of its ancestors
IFrame
  
isInFrontOfMe(obj:DisplayObject):Boolean
Checks whether a top-level object has a higher Z-index off the root than the Iframe container (in other words, whether it's on a layer above this object)
IFrame
  
Load content into a div.
IFrame
  
loadIFrame():void
Show the IFrame.
IFrame
  
moveIFrame(x:int, y:int, width:int, height:int):void
Move the IFrame.
IFrame
  
overlay_hideShowHandler(event:FlexEvent):void
Triggered when an overlapping object is shown or hidden.
IFrame
  
Get the embed object id.
IFrame
  
Setup the Browser resize event listener.
IFrame
  
Inserts the Javascript functions in the DOM, setups the callback and javascripts event listeners.
IFrame
  
showDiv():void
Show the div.
IFrame
  
showIFrame():void
Show the IFrame.
IFrame
  
systemManager_addedHandler(event:Event):void
Triggered when the object is added to the stage.
IFrame
  
systemManager_removedHandler(event:Event):void
Triggered when the object is removed from the stage.
IFrame
  
updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
Triggered when display contents change.
IFrame
  
updateFrameVisibility(value:Boolean):Boolean
Request visibility update of html frame.
IFrame
Events
 EventSummaryDefined by
   The event dispatched when the IFrame is loaded.IFrame
Public Constants
 ConstantDefined by
  SCROLL_POLICY_AUTO : String = "auto"
[static] Value for the 'auto' scroll policy.
IFrame
  SCROLL_POLICY_OFF : String = "no"
[static] Value for the 'off' scroll policy.
IFrame
  SCROLL_POLICY_ON : String = "yes"
[static] Value for the 'on' scroll policy.
IFrame
Property detail
_appHostproperty
protected static var _appHost:String

Application host. Used to check potential cross-domain issues.

applicationIdproperty 
public static var applicationId:String = "null"

The SWF embed object id.

_browserScalingproperty 
protected var _browserScaling:Number = 1

The browser zoom ratio

containerDictproperty 
protected var containerDict:Object = null

The dictionnary of the hierarchy of the parent containers.

_contentproperty 
protected var _content:String

The content of the IFrame.

contentproperty 
content:String  [read-write]

Return content string of div contents

Implementation
    public function get content():String
    public function set content(value:String):void
_debugproperty 
protected var _debug:Boolean = false

The state of the debug mode.

debugproperty 
debug:Boolean  [read-write]

Get the state of the debug mode.

Implementation
    public function get debug():Boolean
    public function set debug(value:Boolean):void
explicitVisibleValueproperty 
protected var explicitVisibleValue:Boolean = true

Manually-set visibility value

The default value is true.

_frameIdproperty 
protected var _frameId:String

The frame ID.

_frameLoadedproperty 
protected var _frameLoaded:Boolean = false

Wether the frame is loaded or not.

The default value is false.

_functionQueueproperty 
protected var _functionQueue:Array

The queued functions waiting for the frame to be loaded.

idListproperty 
public static var idList:Object

Track IDs in use throughout the app for iframe instances in order to detect and prevent collisions.

_iframeContentHostproperty 
protected var _iframeContentHost:String

IFrame content host. Used to check potential cross-domain issues.

_iframeIdproperty 
protected var _iframeId:String

The IFrame ID.

_loadIndicatorproperty 
protected var _loadIndicator:UIComponent

The instance of the load indicator class.

loadIndicatorClassproperty 
public var loadIndicatorClass:Class

A UIComponent class to display centered over the iframe container while the browser is loading its content. Should implement measuredHeight and measuredWidth in order to be properly sized.

loggerproperty 
protected var logger:ILogger

The class logger.

logTargetproperty 
protected var logTarget:TraceTarget

The target for the logger.

overlapCountproperty 
protected var overlapCount:int = 0

The count of the objects overlapping the IFrame.

overlappingDictproperty 
protected var overlappingDict:Dictionary

A dictionnary holding the objects overlapping the IFrame.

overlayDetectionproperty 
public var overlayDetection:Boolean = false

The state of the overlay detection system (experimental).

The default value is false.

randomIdentificationStringproperty 
protected var randomIdentificationString:Number

The random string used to identify the right object.

rootIndexproperty 
protected var rootIndex:int = -1

The z-index of this component off the system root

scrollPolicyproperty 
public var scrollPolicy:String = "auto"

The scrolling policy applied to the iframe.

settingDictproperty 
protected var settingDict:Object = null

The dictionnary of the child indexes in the hierarchy of the parent containers.

_sourceproperty 
protected var _source:String

The source of the IFrame.

sourceproperty 
source:String  [read-write]

Return url of frame contents

Implementation
    public function get source():String
    public function set source(value:String):void
_validForDisplayproperty 
protected var _validForDisplay:Boolean = true

The validity of the frame for the display.

The default value is true.

visibilityNotificationFunctionproperty 
public var visibilityNotificationFunction:String

If you provide the name of JavaScript function here, that function will be called as a notification whenever the frame is hidden or shown due to tab index changes, overlay detection (if enabled), etc. It will be passed an array containing 1 item, the value true (if being shown) or false (if being hidden). This uses the same mechanism as callIFrameFunction, so the function should be defined the same way as others you want to call through this method

visibleproperty 
visible:Boolean  [write-only]

Manually sets visibility of html iframe.

Implementation
    public function set visible(value:Boolean):void
Constructor detail
IFrame()constructor
public function IFrame(id:String = null)

Build a new IFrame.

Parameters
id:String (default = null) — a String identifying the IFrame. Must be unique for every instance of the IFrame class.

Example
Declare an IFrame in MXML.
         <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                         xmlns:flexiframe="http://code.google.com/p/flex-iframe/">
                      <flexiframe:IFrame id="googleIFrame"
                                label="Google"
                                source="http://www.google.com"
                                width="80%"
                                height="80%"/>
                  <mx:Application>
         

Declare an IFrame in ActionScript.
         import com.google.code.flexiframe.IFrame;
                  ...
                  var frame : IFrame = new IFrame("aUniqueIdForThisIFrameInstance");
         

Method detail
adjustPosition()method
protected function adjustPosition(recalculateBrowserScaling:Boolean = false):void

Adjust frame position to match the exposed area in the application.

Parameters
recalculateBrowserScaling:Boolean (default = false)
bringIFrameToFront()method 
public function bringIFrameToFront():void

Bring the IFrame to the front.

buildContainerList()method 
protected function buildContainerList():void

Build list of container objects on the display list path all the way down to this object. We will seed the container classes we find with an event listener which will be used to test if this object is to be displayed or not. When the component is created the display list is traversed from the component down to the root element. At each traversal a test is made to see if current component is a container. If it is a container then the child of the element which leads back to the component is determined and a note madeof the appropriate 'index' on the path. The index is stored against a reference to the Container in a Dictionary. Also the container is 'seeded' with an event handler so that if the container triggers an IndexChangedEvent.CHANGE (i.e. when you click on a tab in a tab navigator) the path of 'index' values down to the component can be checked. If the path indicates that the indexes 'line up' to expose the component then the view is made visible.

callIFrameFunction()method 
public function callIFrameFunction(functionName:String, args:Array = null, callback:Function = null):String

Calls a function of the specified name defined on the IFrame document (like document.functionName = function () {...} ), passing it an array of arguments. May not work if the iframe contents are in a different domain due to security. If the frame contents are loaded when this method is called, it will return any results from the function immediately to the caller (as well as to the callback function, if defined). Otherwise, the call will be queued, this method will return null, and results will be passed to the callback function after the frame loads and the queued function call executes.

Parameters
functionName:String — String Name of function to call
 
args:Array (default = null) — Array List of arguments to pass as an array
 
callback:Function (default = null) — Function to call (if any) with results of IFrame function execution

Returns
String
checkDisplay()method 
protected function checkDisplay(target:Object, newIndex:Number):Boolean

This function updates the selected view child of the signalling container and then compares the path from our IFrame up the displaylist to see if the index settings match. Only an exact match all the way down to our IFrame will satisfy the condition to display the IFrame contents.

Parameters
target:Object — Object event source
 
newIndex:Number — Number index from target object.

Returns
Boolean
checkExistingPopUps()method 
protected function checkExistingPopUps():void

Called to check for existing pop-ups when the component appears or changes size

checkObjectId()method 
protected function checkObjectId(id:String, randomCode:Number):Boolean

Receive information about a DOM object and test if this is this SWF object.

Parameters
id:String
 
randomCode:Number

Returns
Boolean
checkOverlay()method 
protected function checkOverlay(displayObj:DisplayObject):void

Check to see if the given DisplayObject overlaps this object. If so, add it to a dictionary of overlapping objects and update this object's visibility.

Parameters
displayObj:DisplayObject
commitProperties()method 
protected override function commitProperties():void

Triggered by change to component properties.

createChildren()method 
protected override function createChildren():void

Generate DOM elements and build display path.

createIFrame()method 
protected function createIFrame():void

Create the IFrame.

getBrowserMeasuredWidth()method 
protected function getBrowserMeasuredWidth():Number

Get the browser measured width.

Returns
Number
handleAdd()method 
protected function handleAdd(event:Event = null):void

Triggered by addition of this object to the stage.

Parameters
event:Event (default = null) — Event trigger
handleChange()method 
protected function handleChange(event:Event):void

Triggered by one of our listeners seeded all the way up the display list to catch a 'changed' event which might hide or display this object.

Parameters
event:Event — Event trigger
handleFrameLoad()method 
protected function handleFrameLoad():void

Trigered when the IFrame is loaded.

handleMove()method 
protected function handleMove(event:Event):void

Triggered by one of our listeners seeded all the way up the display list to catch a 'move' event which might reposition this object.

Parameters
event:Event — Event trigger
handleRemove()method 
protected function handleRemove(event:Event = null):void

Triggered by removal of this object from the stage.

Parameters
event:Event (default = null) — Event trigger
hideDiv()method 
protected function hideDiv():void

Hide the div.

hideIFrame()method 
protected function hideIFrame():void

Hide the IFrame.

historyBack()method 
public function historyBack():void

Load the IFrame's last page in the navigation history.

historyForward()method 
public function historyForward():void

Load the IFrame's next page in the navigation history.

hitTestStageObject()method 
protected function hitTestStageObject(o:DisplayObject):Boolean

The native hitTestObject method seems to have some issues depending on the situation. This is a custom implementation to work around that. This method assumes that the passed DisplayObject is a direct child of the stage and therefore has x and y coordinates that are already global

Parameters
o:DisplayObject

Returns
Boolean
isAncestor()method 
protected function isAncestor(obj:DisplayObject):Boolean

Use display object ancestry table already built to check whether an object is a container of this component or one of its ancestors

Parameters
obj:DisplayObject

Returns
Boolean
isInFrontOfMe()method 
protected function isInFrontOfMe(obj:DisplayObject):Boolean

Checks whether a top-level object has a higher Z-index off the root than the Iframe container (in other words, whether it's on a layer above this object)

Parameters
obj:DisplayObject

Returns
Boolean
loadDivContent()method 
protected function loadDivContent():void

Load content into a div.

loadIFrame()method 
protected function loadIFrame():void

Show the IFrame.

lookupIndex()method 
public function lookupIndex(target:Container):Number

Return index of child item on path down to this object. If not found then return -1;

Parameters
target:Container — Container object

Returns
Number
lookupSetting()method 
public function lookupSetting(target:Container):Number

Return index of child item on path down to this object. If not found then return -1;

Parameters
target:Container — Container object

Returns
Number
moveIFrame()method 
protected function moveIFrame(x:int, y:int, width:int, height:int):void

Move the IFrame.

Parameters
x:int
 
y:int
 
width:int
 
height:int
overlay_hideShowHandler()method 
protected function overlay_hideShowHandler(event:FlexEvent):void

Triggered when an overlapping object is shown or hidden.

Parameters
event:FlexEvent
printIFrame()method 
public function printIFrame():void

Print the content of the IFrame.

removeIFrame()method 
public function removeIFrame():void

Remove the IFrame.

resolveEmbedObjectId()method 
protected function resolveEmbedObjectId():void

Get the embed object id.

setActualSize()method 
public override function setActualSize(w:Number, h:Number):void

Sets actual size When component is sized by its parent, and overlay detection is enabled, checks for existing pop-ups

Parameters
w:Number
 
h:Number
setupBrowserResizeEventListener()method 
protected function setupBrowserResizeEventListener():void

Setup the Browser resize event listener.

setupExternalInterface()method 
protected function setupExternalInterface():void

Inserts the Javascript functions in the DOM, setups the callback and javascripts event listeners.

showDiv()method 
protected function showDiv():void

Show the div.

showIFrame()method 
protected function showIFrame():void

Show the IFrame.

systemManager_addedHandler()method 
protected function systemManager_addedHandler(event:Event):void

Triggered when the object is added to the stage.

Parameters
event:Event
systemManager_removedHandler()method 
protected function systemManager_removedHandler(event:Event):void

Triggered when the object is removed from the stage.

Parameters
event:Event
updateDisplayList()method 
protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void

Triggered when display contents change. Adjusts frame layout.

Parameters
unscaledWidth:Number
 
unscaledHeight:Number
updateFrameVisibility()method 
protected function updateFrameVisibility(value:Boolean):Boolean

Request visibility update of html frame.

Parameters
value:Boolean — Boolean desired visibility state

Returns
Boolean — The actual resulting visibility after applying rules
Event detail
frameLoadevent 
Event object type: flash.events.Event

The event dispatched when the IFrame is loaded.

Constant detail
SCROLL_POLICY_AUTOconstant
public static const SCROLL_POLICY_AUTO:String = "auto"

Value for the 'auto' scroll policy.

SCROLL_POLICY_OFFconstant 
public static const SCROLL_POLICY_OFF:String = "no"

Value for the 'off' scroll policy.

SCROLL_POLICY_ONconstant 
public static const SCROLL_POLICY_ON:String = "yes"

Value for the 'on' scroll policy.