ActionScript® 3.0 Reference for the Adobe® Flash® Platform
Home  |  Hide Packages and Classes List |  Packages  |  Classes  |  What's New  |  Index  |  Appendixes

Language Reference only
Filters: AIR 32.0 and earlier, Flash Player 32.0 and earlier, Flash Lite 4
Flex 4.6 and earlier, Flash Pro CS6 and earlier
Hide Filters
flash.net 

NetGroup  - AS3

Packagesx

Top Level
adobe.utils
air.desktop
air.net
air.update
air.update.events
coldfusion.air
coldfusion.air.errors
coldfusion.air.events
coldfusion.service
coldfusion.service.events
coldfusion.service.mxml
com.adobe.acm.solutions.authoring.domain.extensions
com.adobe.acm.solutions.ccr.domain.extensions
com.adobe.consulting.pst.vo
com.adobe.dct.component
com.adobe.dct.component.datadictionary
com.adobe.dct.component.datadictionaryElement
com.adobe.dct.component.dataElementsPanel
com.adobe.dct.component.toolbars
com.adobe.dct.event
com.adobe.dct.exp
com.adobe.dct.model
com.adobe.dct.service
com.adobe.dct.service.provider
com.adobe.dct.transfer
com.adobe.dct.util
com.adobe.dct.view
com.adobe.ep.taskmanagement.domain
com.adobe.ep.taskmanagement.event
com.adobe.ep.taskmanagement.filter
com.adobe.ep.taskmanagement.services
com.adobe.ep.taskmanagement.util
com.adobe.ep.ux.attachmentlist.component
com.adobe.ep.ux.attachmentlist.domain
com.adobe.ep.ux.attachmentlist.domain.events
com.adobe.ep.ux.attachmentlist.domain.renderers
com.adobe.ep.ux.attachmentlist.skin
com.adobe.ep.ux.attachmentlist.skin.renderers
com.adobe.ep.ux.content.event
com.adobe.ep.ux.content.factory
com.adobe.ep.ux.content.handlers
com.adobe.ep.ux.content.managers
com.adobe.ep.ux.content.model.asset
com.adobe.ep.ux.content.model.preview
com.adobe.ep.ux.content.model.relation
com.adobe.ep.ux.content.model.search
com.adobe.ep.ux.content.model.toolbar
com.adobe.ep.ux.content.search
com.adobe.ep.ux.content.services
com.adobe.ep.ux.content.services.load
com.adobe.ep.ux.content.services.permissions
com.adobe.ep.ux.content.services.preview
com.adobe.ep.ux.content.services.providers
com.adobe.ep.ux.content.services.query
com.adobe.ep.ux.content.services.relationships
com.adobe.ep.ux.content.services.search.lccontent
com.adobe.ep.ux.content.services.version
com.adobe.ep.ux.content.view
com.adobe.ep.ux.content.view.components.activate
com.adobe.ep.ux.content.view.components.grid
com.adobe.ep.ux.content.view.components.grid.hover
com.adobe.ep.ux.content.view.components.grid.hover.component
com.adobe.ep.ux.content.view.components.grid.renderers
com.adobe.ep.ux.content.view.components.relationships
com.adobe.ep.ux.content.view.components.review
com.adobe.ep.ux.content.view.components.search.renderers
com.adobe.ep.ux.content.view.components.searchpod
com.adobe.ep.ux.content.view.components.toolbar
com.adobe.ep.ux.content.view.components.toolbar.controlRenderers
com.adobe.ep.ux.content.view.components.version
com.adobe.ep.ux.documentsubmit.component
com.adobe.ep.ux.documentsubmit.domain
com.adobe.ep.ux.documentsubmit.skin
com.adobe.ep.ux.taskaction.component
com.adobe.ep.ux.taskaction.domain
com.adobe.ep.ux.taskaction.domain.events
com.adobe.ep.ux.taskaction.skin
com.adobe.ep.ux.taskdetails.component
com.adobe.ep.ux.taskdetails.domain
com.adobe.ep.ux.taskdetails.skin
com.adobe.ep.ux.tasklist.component
com.adobe.ep.ux.tasklist.domain
com.adobe.ep.ux.tasklist.skin
com.adobe.ep.ux.webdocumentviewer.domain
com.adobe.exm.expression
com.adobe.exm.expression.error
com.adobe.exm.expression.event
com.adobe.exm.expression.impl
com.adobe.fiber.runtime.lib
com.adobe.fiber.services
com.adobe.fiber.services.wrapper
com.adobe.fiber.styles
com.adobe.fiber.util
com.adobe.fiber.valueobjects
com.adobe.gravity.binding
com.adobe.gravity.context
com.adobe.gravity.flex.bundleloader
com.adobe.gravity.flex.progress
com.adobe.gravity.flex.serviceloader
com.adobe.gravity.framework
com.adobe.gravity.init
com.adobe.gravity.service.bundleloader
com.adobe.gravity.service.logging
com.adobe.gravity.service.manifest
com.adobe.gravity.service.progress
com.adobe.gravity.tracker
com.adobe.gravity.ui
com.adobe.gravity.utility
com.adobe.gravity.utility.async
com.adobe.gravity.utility.error
com.adobe.gravity.utility.events
com.adobe.gravity.utility.factory
com.adobe.gravity.utility.flex.async
com.adobe.gravity.utility.logging
com.adobe.gravity.utility.message
com.adobe.gravity.utility.sequence
com.adobe.gravity.utility.url
com.adobe.guides.control
com.adobe.guides.domain
com.adobe.guides.i18n
com.adobe.guides.spark.components.skins
com.adobe.guides.spark.components.skins.mx
com.adobe.guides.spark.headers.components
com.adobe.guides.spark.headers.skins
com.adobe.guides.spark.layouts.components
com.adobe.guides.spark.layouts.skins
com.adobe.guides.spark.navigators.components
com.adobe.guides.spark.navigators.renderers
com.adobe.guides.spark.navigators.skins
com.adobe.guides.spark.util
com.adobe.guides.spark.wrappers.components
com.adobe.guides.spark.wrappers.skins
com.adobe.guides.submit
com.adobe.icc.dc.domain
com.adobe.icc.dc.domain.factory
com.adobe.icc.editors.events
com.adobe.icc.editors.handlers
com.adobe.icc.editors.managers
com.adobe.icc.editors.model
com.adobe.icc.editors.model.config
com.adobe.icc.editors.model.el
com.adobe.icc.editors.model.el.operands
com.adobe.icc.editors.model.el.operators
com.adobe.icc.enum
com.adobe.icc.external.dc
com.adobe.icc.obj
com.adobe.icc.services
com.adobe.icc.services.category
com.adobe.icc.services.config
com.adobe.icc.services.download
com.adobe.icc.services.export
com.adobe.icc.services.external
com.adobe.icc.services.formbridge
com.adobe.icc.services.fragmentlayout
com.adobe.icc.services.layout
com.adobe.icc.services.letter
com.adobe.icc.services.locator
com.adobe.icc.services.module
com.adobe.icc.services.render
com.adobe.icc.services.submit
com.adobe.icc.services.user
com.adobe.icc.token
com.adobe.icc.vo
com.adobe.icc.vo.render
com.adobe.icomm.assetplacement.controller
com.adobe.icomm.assetplacement.controller.utils
com.adobe.icomm.assetplacement.data
com.adobe.icomm.assetplacement.model
com.adobe.livecycle.assetmanager.client
com.adobe.livecycle.assetmanager.client.event
com.adobe.livecycle.assetmanager.client.handler
com.adobe.livecycle.assetmanager.client.managers
com.adobe.livecycle.assetmanager.client.model
com.adobe.livecycle.assetmanager.client.model.cms
com.adobe.livecycle.assetmanager.client.service
com.adobe.livecycle.assetmanager.client.service.search
com.adobe.livecycle.assetmanager.client.service.search.cms
com.adobe.livecycle.assetmanager.client.utils
com.adobe.livecycle.content
com.adobe.livecycle.rca.model
com.adobe.livecycle.rca.model.constant
com.adobe.livecycle.rca.model.document
com.adobe.livecycle.rca.model.participant
com.adobe.livecycle.rca.model.reminder
com.adobe.livecycle.rca.model.stage
com.adobe.livecycle.rca.service
com.adobe.livecycle.rca.service.core
com.adobe.livecycle.rca.service.core.delegate
com.adobe.livecycle.rca.service.process
com.adobe.livecycle.rca.service.process.delegate
com.adobe.livecycle.rca.token
com.adobe.livecycle.ria.security.api
com.adobe.livecycle.ria.security.service
com.adobe.mosaic.layouts
com.adobe.mosaic.layouts.dragAndDrop
com.adobe.mosaic.layouts.interfaces
com.adobe.mosaic.mxml
com.adobe.mosaic.om.constants
com.adobe.mosaic.om.events
com.adobe.mosaic.om.impl
com.adobe.mosaic.om.interfaces
com.adobe.mosaic.skinning
com.adobe.mosaic.sparklib.editors
com.adobe.mosaic.sparklib.optionMenu
com.adobe.mosaic.sparklib.scrollableMenu
com.adobe.mosaic.sparklib.scrollableMenu.skins
com.adobe.mosaic.sparklib.tabLayout
com.adobe.mosaic.sparklib.tabLayout.events
com.adobe.mosaic.sparklib.tabLayout.layouts
com.adobe.mosaic.sparklib.tabLayout.skins
com.adobe.mosaic.sparklib.text
com.adobe.mosaic.sparklib.util
com.adobe.solutions.acm.authoring.presentation
com.adobe.solutions.acm.authoring.presentation.actionbar
com.adobe.solutions.acm.authoring.presentation.common
com.adobe.solutions.acm.authoring.presentation.events
com.adobe.solutions.acm.authoring.presentation.fragment
com.adobe.solutions.acm.authoring.presentation.letter
com.adobe.solutions.acm.authoring.presentation.letter.data
com.adobe.solutions.acm.authoring.presentation.preview
com.adobe.solutions.acm.authoring.presentation.rte
com.adobe.solutions.acm.ccr.presentation
com.adobe.solutions.acm.ccr.presentation.contentcapture
com.adobe.solutions.acm.ccr.presentation.contentcapture.events
com.adobe.solutions.acm.ccr.presentation.contentcapture.preview
com.adobe.solutions.acm.ccr.presentation.datacapture
com.adobe.solutions.acm.ccr.presentation.datacapture.renderers
com.adobe.solutions.acm.ccr.presentation.pdf
com.adobe.solutions.exm
com.adobe.solutions.exm.authoring
com.adobe.solutions.exm.authoring.components.controls
com.adobe.solutions.exm.authoring.components.toolbars
com.adobe.solutions.exm.authoring.domain
com.adobe.solutions.exm.authoring.domain.expression
com.adobe.solutions.exm.authoring.domain.impl
com.adobe.solutions.exm.authoring.domain.method
com.adobe.solutions.exm.authoring.domain.variable
com.adobe.solutions.exm.authoring.enum
com.adobe.solutions.exm.authoring.events
com.adobe.solutions.exm.authoring.model
com.adobe.solutions.exm.authoring.renderer
com.adobe.solutions.exm.authoring.view
com.adobe.solutions.exm.expression
com.adobe.solutions.exm.impl
com.adobe.solutions.exm.impl.method
com.adobe.solutions.exm.method
com.adobe.solutions.exm.mock
com.adobe.solutions.exm.mock.method
com.adobe.solutions.exm.runtime
com.adobe.solutions.exm.runtime.impl
com.adobe.solutions.exm.variable
com.adobe.solutions.prm.constant
com.adobe.solutions.prm.domain
com.adobe.solutions.prm.domain.factory
com.adobe.solutions.prm.domain.impl
com.adobe.solutions.prm.domain.manager
com.adobe.solutions.prm.presentation.asset
com.adobe.solutions.prm.presentation.constant
com.adobe.solutions.prm.presentation.document
com.adobe.solutions.prm.presentation.event
com.adobe.solutions.prm.presentation.file
com.adobe.solutions.prm.presentation.project
com.adobe.solutions.prm.presentation.team
com.adobe.solutions.prm.presentation.util
com.adobe.solutions.prm.service
com.adobe.solutions.prm.services.impl
com.adobe.solutions.prm.vo
com.adobe.solutions.rca.constant
com.adobe.solutions.rca.domain
com.adobe.solutions.rca.domain.common
com.adobe.solutions.rca.domain.factory
com.adobe.solutions.rca.domain.impl
com.adobe.solutions.rca.domain.impl.manager
com.adobe.solutions.rca.domain.manager
com.adobe.solutions.rca.presentation
com.adobe.solutions.rca.presentation.comment
com.adobe.solutions.rca.presentation.constant
com.adobe.solutions.rca.presentation.event
com.adobe.solutions.rca.presentation.gantt
com.adobe.solutions.rca.presentation.gantt.ruler
com.adobe.solutions.rca.presentation.template
com.adobe.solutions.rca.presentation.template.audit
com.adobe.solutions.rca.presentation.template.definition
com.adobe.solutions.rca.presentation.template.documents
com.adobe.solutions.rca.presentation.template.stages
com.adobe.solutions.rca.presentation.util
com.adobe.solutions.rca.service
com.adobe.solutions.rca.services.impl
com.adobe.solutions.rca.vo
com.adobe.solutions.rca.vo.um
com.adobe.viewsource
fl.accessibility
fl.containers
fl.controls
fl.controls.dataGridClasses
fl.controls.listClasses
fl.controls.progressBarClasses
fl.core
fl.data
fl.display
fl.events
fl.ik
fl.lang
fl.livepreview
fl.managers
fl.motion
fl.motion.easing
fl.rsl
fl.text
fl.transitions
fl.transitions.easing
fl.video
flash.accessibility
flash.concurrent
flash.crypto
flash.data
flash.desktop
flash.display
flash.display3D
flash.display3D.textures
flash.errors
flash.events
flash.external
flash.filesystem
flash.filters
flash.geom
flash.globalization
flash.html
flash.media
flash.net
flash.net.dns
flash.net.drm
flash.notifications
flash.permissions
flash.printing
flash.profiler
flash.sampler
flash.security
flash.sensors
flash.system
flash.text
flash.text.engine
flash.text.ime
flash.ui
flash.utils
flash.xml
flashx.textLayout
flashx.textLayout.compose
flashx.textLayout.container
flashx.textLayout.conversion
flashx.textLayout.edit
flashx.textLayout.elements
flashx.textLayout.events
flashx.textLayout.factory
flashx.textLayout.formats
flashx.textLayout.operations
flashx.textLayout.utils
flashx.undo
ga.controls
ga.layouts
ga.model
ga.uiComponents
ga.util
ga.views
ga.wrappers
lc.foundation
lc.foundation.domain
lc.foundation.events
lc.foundation.ui
lc.foundation.util
lc.preloader
lc.procmgmt
lc.procmgmt.commands
lc.procmgmt.domain
lc.procmgmt.events
lc.procmgmt.formbridge
lc.procmgmt.impl
lc.procmgmt.ui.attachments
lc.procmgmt.ui.controls
lc.procmgmt.ui.controls.card
lc.procmgmt.ui.controls.renderer
lc.procmgmt.ui.help
lc.procmgmt.ui.layout
lc.procmgmt.ui.presentationmodel
lc.procmgmt.ui.process
lc.procmgmt.ui.search
lc.procmgmt.ui.startpoint
lc.procmgmt.ui.task
lc.procmgmt.ui.task.form
lc.procmgmt.ui.task.form.commands
lc.procmgmt.ui.tracking
mx.accessibility
mx.automation
mx.automation.air
mx.automation.delegates
mx.automation.delegates.advancedDataGrid
mx.automation.delegates.charts
mx.automation.delegates.containers
mx.automation.delegates.controls
mx.automation.delegates.controls.dataGridClasses
mx.automation.delegates.controls.fileSystemClasses
mx.automation.delegates.core
mx.automation.delegates.flashflexkit
mx.automation.events
mx.binding
mx.binding.utils
mx.charts
mx.charts.chartClasses
mx.charts.effects
mx.charts.effects.effectClasses
mx.charts.events
mx.charts.renderers
mx.charts.series
mx.charts.series.items
mx.charts.series.renderData
mx.charts.styles
mx.collections
mx.collections.errors
mx.containers
mx.containers.accordionClasses
mx.containers.dividedBoxClasses
mx.containers.errors
mx.containers.utilityClasses
mx.controls
mx.controls.advancedDataGridClasses
mx.controls.dataGridClasses
mx.controls.listClasses
mx.controls.menuClasses
mx.controls.olapDataGridClasses
mx.controls.scrollClasses
mx.controls.sliderClasses
mx.controls.textClasses
mx.controls.treeClasses
mx.controls.videoClasses
mx.core
mx.core.windowClasses
mx.data
mx.data.crypto
mx.data.errors
mx.data.events
mx.data.messages
mx.data.mxml
mx.data.offline.errors
mx.data.utils
mx.effects
mx.effects.easing
mx.effects.effectClasses
mx.events
mx.filters
mx.flash
mx.formatters
mx.geom
mx.graphics
mx.graphics.codec
mx.graphics.shaderClasses
mx.logging
mx.logging.errors
mx.logging.targets
mx.managers
mx.messaging
mx.messaging.channels
mx.messaging.config
mx.messaging.errors
mx.messaging.events
mx.messaging.management
mx.messaging.messages
mx.modules
mx.netmon
mx.olap
mx.olap.aggregators
mx.preloaders
mx.printing
mx.resources
mx.rpc
mx.rpc.events
mx.rpc.http
mx.rpc.http.mxml
mx.rpc.livecycle
mx.rpc.mxml
mx.rpc.remoting
mx.rpc.remoting.mxml
mx.rpc.soap
mx.rpc.soap.mxml
mx.rpc.wsdl
mx.rpc.xml
mx.skins
mx.skins.halo
mx.skins.spark
mx.skins.wireframe
mx.skins.wireframe.windowChrome
mx.states
mx.styles
mx.utils
mx.validators
org.osmf.containers
org.osmf.display
org.osmf.elements
org.osmf.events
org.osmf.layout
org.osmf.logging
org.osmf.media
org.osmf.metadata
org.osmf.net
org.osmf.net.dvr
org.osmf.net.httpstreaming
org.osmf.net.metrics
org.osmf.net.qos
org.osmf.net.rtmpstreaming
org.osmf.net.rules
org.osmf.traits
org.osmf.utils
spark.accessibility
spark.automation.delegates
spark.automation.delegates.components
spark.automation.delegates.components.gridClasses
spark.automation.delegates.components.mediaClasses
spark.automation.delegates.components.supportClasses
spark.automation.delegates.skins.spark
spark.automation.events
spark.collections
spark.components
spark.components.calendarClasses
spark.components.gridClasses
spark.components.mediaClasses
spark.components.supportClasses
spark.components.windowClasses
spark.core
spark.effects
spark.effects.animation
spark.effects.easing
spark.effects.interpolation
spark.effects.supportClasses
spark.events
spark.filters
spark.formatters
spark.formatters.supportClasses
spark.globalization
spark.globalization.supportClasses
spark.layouts
spark.layouts.supportClasses
spark.managers
spark.modules
spark.preloaders
spark.primitives
spark.primitives.supportClasses
spark.skins
spark.skins.mobile
spark.skins.mobile.supportClasses
spark.skins.spark
spark.skins.spark.mediaClasses.fullScreen
spark.skins.spark.mediaClasses.normal
spark.skins.spark.windowChrome
spark.skins.wireframe
spark.skins.wireframe.mediaClasses
spark.skins.wireframe.mediaClasses.fullScreen
spark.transitions
spark.utils
spark.validators
spark.validators.supportClasses
xd.core.axm.enterprise.view.components
xd.core.axm.enterprise.view.skins
xd.core.axm.view.components
xd.core.axm.view.components.support

Language Elements

Global Constants
Global Functions
Operators
Statements, Keywords & Directives
Special Types

Appendixes

What's New
Compiler Errors
Compiler Warnings
Run-Time Errors
Migrating to ActionScript 3
Supported Character Sets
MXML Only Tags
Motion XML Elements
Timed Text Tags
List of deprecated elements
Accessibility Implementation Constants
How to Use ActionScript Examples
Legal notices
Packageflash.net
Classpublic class NetGroup
InheritanceNetGroup Inheritance EventDispatcher Inheritance Object

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Instances of the NetGroup class represent membership in an RTMFP group. Use this class to do the following:
  • Monitor Quality of Service. The info property contains a NetGroupInfo object whose properties provide QoS statistics for this group.
  • Posting. Call post() to broadcast ActionScript messages to all members of a group.
  • Direct routing. Call sendToNearest(), sendToNeighbor(), and sendToAllNeighbors() to send a short data message to a specific member of a peer-to-peer group. The source and the destination do not need to have a direct connection.
  • Object replication. Call addHaveObjects(), removeHaveObjects(), addWantObjects(), removeWantObjects(), writeRequestedObject(), and denyRequestedObject() to break up large data into pieces and replicate it to all nodes in a peer-to-peer group.

In the client-side NetGroup class, the NetConnection dispatches the following events:

  • NetGroup.Connect.Success
  • NetGroup.Connect.Failed
  • NetGroup.Connect.Rejected

The info.group property of the event object contains a reference to the event source (the NetGroup). The NetGroup dispatches all other events. In the server-side NetGroup class, the NetGroup dispatches all events.

For information about using groups with peer-assisted networking, see Social Media Experiences with Flash Media and RTMFP, also by Tom Krcha.

For information about the technical details behind peer-assisted networking, see P2P on the Flash Platform with RTMFP by Adobe Computer Scientist Matthew Kaufman.

View the examples

Related API Elements



Public Properties
 PropertyDefined By
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  estimatedMemberCount : Number
[read-only] Specifies the estimated number of members of the group, based on local neighbor density and assuming an even distribution of group addresses.
NetGroup
  info : NetGroupInfo
[read-only] Returns a NetGroupInfo object whose properties provide Quality of Service statistics about this NetGroup's RTMFP peer-to-peer data transport.
NetGroup
  localCoverageFrom : String
[read-only] Specifies the start of the range of group addresses for which this node is the "nearest" and responsible.
NetGroup
  localCoverageTo : String
[read-only] Specifies the end of the range of group addresses for which this node is the "nearest" and responsible.
NetGroup
  neighborCount : Number
[read-only] Specifies the number of group members to which this node is directly connected.
NetGroup
  receiveMode : String
Specifies this node's routing receive mode as one of values in the NetGroupReceiveMode enum class.
NetGroup
  replicationStrategy : String
Specifies the object replication fetch strategy.
NetGroup
Public Methods
 MethodDefined By
  
NetGroup(connection:NetConnection, groupspec:String)
Constructs a NetGroup on the specified NetConnection object and joins it to the group specified by groupspec.
NetGroup
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
EventDispatcher
  
addHaveObjects(startIndex:Number, endIndex:Number):void
Adds objects from startIndex through endIndex, to the set of objects this node advertises to neighbors as objects for which it fulfills requests.
NetGroup
  
Manually adds a record specifying that peerID is a member of the group.
NetGroup
  
Manually adds a neighbor by immediately connecting directly to the specified peerID, which must already be in this group.
NetGroup
  
addWantObjects(startIndex:Number, endIndex:Number):void
Adds objects from startIndex through endIndex, to the set of objects to retrieve.
NetGroup
  
Disconnect from the group and close this NetGroup.
NetGroup
  
Converts a peerID to a group address suitable for use with the sendToNearest() method.
NetGroup
  
Denies a request received in a NetStatusEvent NetGroup.Replication.Request for an object previously advertised with addHaveObjects().
NetGroup
 Inherited
Dispatches an event into the event flow.
EventDispatcher
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
  
post(message:Object):String
Sends a message to all members of a group.
NetGroup
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
  
removeHaveObjects(startIndex:Number, endIndex:Number):void
Removes objects from startIndex through endIndex, from the set of objects this node advertises to neighbors as objects for which it fulfills requests.
NetGroup
  
removeWantObjects(startIndex:Number, endIndex:Number):void
Removes objects from startIndex through endIndex, from the set of objects to retrieve.
NetGroup
  
Sends a message to all neighbors.
NetGroup
  
sendToNearest(message:Object, groupAddress:String):String
Sends a message to the neighbor (or local node) nearest to the specified group address.
NetGroup
  
sendToNeighbor(message:Object, sendMode:String):String
Sends a message to the neighbor specified by the sendMode parameter.
NetGroup
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
  
writeRequestedObject(requestID:int, object:Object):void
Satisfies the request as received by NetStatusEvent NetGroup.Replication.Request for an object previously advertised with the addHaveObjects() method.
NetGroup
Events
 Event Summary Defined By
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active.EventDispatcher
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.EventDispatcher
  Dispatched when a NetGroup object is reporting its status or error condition.NetGroup
Property Detail

estimatedMemberCount

property
estimatedMemberCount:Number  [read-only]

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Specifies the estimated number of members of the group, based on local neighbor density and assuming an even distribution of group addresses.



Implementation
    public function get estimatedMemberCount():Number

Related API Elements

info

property 
info:NetGroupInfo  [read-only]

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Returns a NetGroupInfo object whose properties provide Quality of Service statistics about this NetGroup's RTMFP peer-to-peer data transport.



Implementation
    public function get info():NetGroupInfo

Related API Elements

localCoverageFrom

property 
localCoverageFrom:String  [read-only]

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Specifies the start of the range of group addresses for which this node is the "nearest" and responsible. The range is specified in the increasing direction along the group address ring mod 2256.



Implementation
    public function get localCoverageFrom():String

Related API Elements

localCoverageTo

property 
localCoverageTo:String  [read-only]

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Specifies the end of the range of group addresses for which this node is the "nearest" and responsible. The range is specified in the increasing direction along the group address ring mod 2256.



Implementation
    public function get localCoverageTo():String

Related API Elements

neighborCount

property 
neighborCount:Number  [read-only]

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Specifies the number of group members to which this node is directly connected.



Implementation
    public function get neighborCount():Number

Related API Elements

receiveMode

property 
receiveMode:String

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Specifies this node's routing receive mode as one of values in the NetGroupReceiveMode enum class.



Implementation
    public function get receiveMode():String
    public function set receiveMode(value:String):void

Related API Elements

replicationStrategy

property 
replicationStrategy:String

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Specifies the object replication fetch strategy. The value is one of the enumerated values in the NetGroupReplicationStrategy class.



Implementation
    public function get replicationStrategy():String
    public function set replicationStrategy(value:String):void

Related API Elements

Constructor Detail

NetGroup

()Constructor
public function NetGroup(connection:NetConnection, groupspec:String)

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Constructs a NetGroup on the specified NetConnection object and joins it to the group specified by groupspec.

In most cases, a groupspec has the potential for using the network uplink on the local system. When a NetStream or NetGroup object is constructed with a groupspec, Flash Player displays a Privacy Dialog. The dialog asks whether Flash Player can use the connection to share data with a user's peers. If the user clicks "Allow for this domain", the dialog is not displayed the next time the user connects to this application. If a user does not allow peer-assisted networking, all peer features within the group (posting, directed routing, and object replication, and multicast) are disabled. If permission is allowed, a NetStatusEvent is sent to the NetConnection's event listener with NetGroup.Connect.Success in the code property of the info object. If permission is denied, the code property is NetGroup.Connect.Rejected. Until a NetGroup.Connect.Success event is received, an exception is thrown if you try to call any method of the NetGroup object.

Note: When a client subscribes to a native-IP multicast stream, the security dialog is not displayed.

Parameters
connection:NetConnection — A NetConnection object.
 
groupspec:String — A string specifying the RTMFP peer-to-peer group to join, including its name, capabilities, restrictions, and the authorizations of this member.
     new NetGroup(myConnection, myGroupSpecifier.groupspecWithAuthorizations());
     

Throws
ArgumentError — The NetConnection instance is not connected.
 
Error — The groupspec is invalid.

Related API Elements

Method Detail

addHaveObjects

()method
public function addHaveObjects(startIndex:Number, endIndex:Number):void

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Adds objects from startIndex through endIndex, to the set of objects this node advertises to neighbors as objects for which it fulfills requests. By default, the Have set is empty. Indices must be whole numbers from 0 through 9007199254740992.

For more information about object replication, see "Replicate an object within a group" in Flash Media Server Developer’s Guide.

This method sends a NetStatusEvent to the NetGroup's event listener with "NetGroup.Replication.Request" in the code property of the info object.

NOTE: Test for the NetGroup.Neighbor.Connect event before calling this method.

Parameters

startIndex:Number — The beginning of the range of object indices to add to the Have set.
 
endIndex:Number — The end of the range of object indices to add to the Have set.


Throws
RangeError — A number passed to this method is less than 0 or greater than 9007199254740992.

Related API Elements

addMemberHint

()method 
public function addMemberHint(peerID:String):Boolean

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Manually adds a record specifying that peerID is a member of the group. An immediate connection to it is attempted only if it is needed for the topology.

Parameters

peerID:String — The peerID to add to the set of potential neighbors.

Returns
Boolean — TRUE for success, FALSE for failure.

Related API Elements

addNeighbor

()method 
public function addNeighbor(peerID:String):Boolean

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Manually adds a neighbor by immediately connecting directly to the specified peerID, which must already be in this group. This direct connection may later be dropped if it is not needed for the topology.

Parameters

peerID:String — The peerID to which to immediately connect.

Returns
Boolean — TRUE for success, FALSE for failure.

Related API Elements

addWantObjects

()method 
public function addWantObjects(startIndex:Number, endIndex:Number):void

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Adds objects from startIndex through endIndex, to the set of objects to retrieve. Indices must be whole numbers from 0 through 9007199254740992. By default, the Want set is empty.

For more information about object replication, see "Replicate an object within a group" in Flash Media Server Developer’s Guide.

This method sends a NetStatusEvent to the NetGroup's event listener with NetGroup.Replication.Fetch.SendNotify in the info.code property. This event is followed by an NetGroup.Replication.Fetch.Failed or NetGroup.Replication.Fetch.Result event.

NOTE: Test for the NetGroup.Neighbor.Connect event before calling this method.

Parameters

startIndex:Number — The beginning of the range of object indices to add to the Want set.
 
endIndex:Number — The end of the range of object indices to add to the Want set.


Throws
RangeError — A number passed to this method is less than 0 or greater than 9007199254740992.

Related API Elements

close

()method 
public function close():void

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Disconnect from the group and close this NetGroup. This NetGroup is not usable after calling this method.

convertPeerIDToGroupAddress

()method 
public function convertPeerIDToGroupAddress(peerID:String):String

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Converts a peerID to a group address suitable for use with the sendToNearest() method.

Parameters

peerID:String — The peerID to convert.

Returns
String — The group address for the peerID.

Related API Elements

denyRequestedObject

()method 
public function denyRequestedObject(requestID:int):void

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Denies a request received in a NetStatusEvent NetGroup.Replication.Request for an object previously advertised with addHaveObjects(). The requestor can request this object again unless or until it is withdrawn from the Have set.

For more information about object replication, see "Replicate an object within a group" in Flash Media Server Developer’s Guide.

NOTE: Test for the NetGroup.Neighbor.Connect event before calling this method.

Parameters

requestID:int — The request identifier as given in the NetGroup.Replication.Request event.

Related API Elements

post

()method 
public function post(message:Object):String

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Sends a message to all members of a group. To call this method, the GroupSpecifier.postingEnabled property must be true in the groupspec passed to the NetGroup constructor. For more information, see "Post messages to a group" in Flash Media Server Developer’s Guide.

All messages must be unique. A message that is identical to one posted earlier might not be propagated. Use a sequence number to make messages unique.

Message delivery is not ordered. Message delivery is not guaranteed.

Messages are serialized in AMF. The message can be one of the following types: an Object, an int, a Number, or a String. The message cannot be a MovieClip.

This method sends a NetStatusEvent to the NetGroup's event listener with "NetGroup.Posting.Notify" in the info.code property. The "NetGroup.Posting.Notify" event is dispatched to the NetGroup on both the client and the server.

NOTE: Test for the NetGroup.Neighbor.Connect event before calling this method.

Parameters

message:Object — The message to send to all other members of the group.

Returns
String — The messageID of the message if posted, or null on error. The messageID is the hexadecmial of the SHA256 of the raw bytes of the serialization of the message.

Related API Elements


Example  ( How to use this example )

This is a simple text chat application that uses peer-to-peer networking. The application connects over RTMFP to Flash Media Server. The server keeps the client applications' fingerprints and manages the peer group as clients connect. However, all data is sent between clients (peers) -- data is not sent back to the server.

When you run the application, you can enter any group name into the text input field. The GroupSpecifier class uses the name (along with any GroupSpecifier properties you've set) to create a string which is the perpetually unique name of the group. To connect another client to the group, that client must use the same group name. For example, if client A uses the group name "firstmesh", other clients that want to communicate with client A must also use the group name "firstmesh". If client B uses the group name "kite", it will connect successfully, but it will create a new group and won't be able to communicate with client A or anyone in the "firstmesh" group.

To run this example, add a Button, a Label, a TextInput, and a TextArea component to the Library in Flash Pro.



package  {

    import flash.display.Sprite;
    import flash.events.TextEvent;
    import flash.events.MouseEvent;
    import flash.events.NetStatusEvent;
    import fl.events.ComponentEvent;
    import fl.controls.Label;
    import fl.controls.Button;
    import fl.controls.TextInput;
    import fl.controls.TextArea;
    import flash.text.TextFieldAutoSize;
    import flash.net.*;

    public class NetGroupPostExample extends Sprite{

        private var connectButton:Button;
        private var disconnectButton:Button;
        private var groupNameText:TextInput;
        private var userNameText:TextInput;
        private var chatText:TextInput;
        private var statusLog:TextArea;
        private var groupLabel:Label;
        private var userLabel:Label;

        private var netConnection:NetConnection = null;
        private var netGroup:NetGroup = null;
        private var sequenceNumber:uint = 0;
        private var connected:Boolean = false;
        private var joinedGroup:Boolean = false;

        private const SERVER:String = "rtmfp://fms.example.com/someapp";

        public function NetGroupPostExample() {
            DoUI();
        }

        // Writes messages to the TextArea.
        private function StatusMessage(msg:Object):void{
            statusLog.text += msg;
            statusLog.verticalScrollPosition = statusLog.textHeight;
            statusLog.validateNow();
        }

        // Handles all NetStatusEvents for the NetConnection and the NetGroup.
        // This code includes cases it doesn't handle so you can see the cases
        // and their info objects for learning purposes.
        private function NetStatusHandler(e:NetStatusEvent):void{
            StatusMessage(e.info.code + "\n");
            switch(e.info.code){
                case "NetConnection.Connect.Success":
                    connectButton.enabled = false;
                    disconnectButton.enabled = true;
                    OnConnect();
                    break;

                case "NetConnection.Connect.Closed":
                    OnDisconnect();
                    break;

                case "NetGroup.Connect.Success": // e.info.group
                    OnNetGroupConnect();
                    break;

                case "NetGroup.Connect.Rejected": // e.info.group
                case "NetGroup.Connect.Failed": // e.info.group
                    break;

                case "NetGroup.Posting.Notify": // e.info.message, e.info.messageID
                    OnPosting(e.info.message);
                    break;

                case "NetStream.MulticastStream.Reset":
                case "NetStream.Buffer.Full":
                    break;

                case "NetGroup.SendTo.Notify": // e.info.message, e.info.from, e.info.fromLocal
                case "NetGroup.LocalCoverage.Notify": //
                case "NetGroup.Neighbor.Connect": // e.info.neighbor
                case "NetGroup.Neighbor.Disconnect": // e.info.neighbor
                case "NetGroup.MulticastStream.PublishNotify": // e.info.name
                case "NetGroup.MulticastStream.UnpublishNotify": // e.info.name
                case "NetGroup.Replication.Fetch.SendNotify": // e.info.index
                case "NetGroup.Replication.Fetch.Failed": // e.info.index
                case "NetGroup.Replication.Fetch.Result": // e.info.index, e.info.object
                case "NetGroup.Replication.Request": // e.info.index, e.info.requestID
                default:
                    break;
                }
            }
        // Creates a NetConnection to Flash Media Server if the app isn't already connected
        // and if there's a group name in the TextInput field.
        private function DoConnect(e:MouseEvent):void{
            if(!connected && (groupNameText.length > 0)){
                StatusMessage("Connecting to \"" + SERVER + "\" ...\n");
                netConnection = new NetConnection();
                netConnection.addEventListener(NetStatusEvent.NET_STATUS, NetStatusHandler);
                // To connect to Flash Media Server, pass the server name.
                netConnection.connect(SERVER);
            }
            else
            {
                StatusMessage("Enter a group name");
            }
        }

        // Called in the "NetConnection.Connect.Success" case in the NetStatusEvent handler.
        private function OnConnect():void{

            StatusMessage("Connected\n");
            connected = true;

            // Create a GroupSpecifier object to pass to the NetGroup constructor.
            // The GroupSpecifier determines the properties of the group
            var groupSpecifier:GroupSpecifier;
            groupSpecifier = new GroupSpecifier("aslrexample/" + groupNameText.text);
            groupSpecifier.postingEnabled = true;
            groupSpecifier.serverChannelEnabled = true;

            netGroup = new NetGroup(netConnection, groupSpecifier.groupspecWithAuthorizations());
            netGroup.addEventListener(NetStatusEvent.NET_STATUS, NetStatusHandler);

            StatusMessage("Join \"" + groupSpecifier.groupspecWithAuthorizations() + "\"\n");

        }

        private function OnNetGroupConnect():void{
            joinedGroup = true;
        }

        private function DoDisconnect(e:MouseEvent):void{
            if(netConnection){
                netConnection.close();
            }
        }

        private function OnDisconnect():void{
            StatusMessage("Disconnected\n");
            netConnection = null;
            netGroup = null;
            connected = false;
            joinedGroup = false;
            connectButton.enabled = true;
            disconnectButton.enabled = false;
        }

        private function ClearChatText():void{
            chatText.text = "";
        }

        // Called when you the chatText field has focus and you press Enter.
        private function DoPost(e:ComponentEvent):void{
            if(joinedGroup){
                var message:Object = new Object;
                message.user = userNameText.text;
                message.text = chatText.text;
                message.sequence = sequenceNumber++;
                message.sender = netConnection.nearID;

                netGroup.post(message);
                StatusMessage("==> " + chatText.text + "\n");
            } else {
                StatusMessage("Click Connect before sending a chat message");
            }
            ClearChatText();
        }

        private function OnPosting(message:Object):void{
            StatusMessage("<" + message.user + "> " + message.text + "\n");
        }

        private function DoUI():void {

            groupLabel = new Label();
            groupLabel.move(20, 10);
            groupLabel.autoSize = TextFieldAutoSize.LEFT
            groupLabel.text = "Group name:"
            addChild(groupLabel);

            groupNameText = new TextInput();
            groupNameText.move(90, 10);
            groupNameText.text = "channel" + (int(Math.random() * 899) + 101);
            addChild(groupNameText);

            connectButton = new Button();
            connectButton.addEventListener(MouseEvent.CLICK, DoConnect);
            connectButton.move(205, 10);
            connectButton.label = "Connect";
            addChild(connectButton);

            disconnectButton = new Button();
            disconnectButton.addEventListener(MouseEvent.CLICK, DoDisconnect);
            disconnectButton.move(310, 10);
            disconnectButton.label = "Disconnect";
            disconnectButton.enabled = false;
            addChild(disconnectButton);

            statusLog = new TextArea();
            statusLog.move(30, 38);
            statusLog.width = 360;
            statusLog.height = 215;
            statusLog.editable = false;
            addChild(statusLog);

            userLabel = new Label();
            userLabel.move(20, 270);
            userLabel.autoSize = TextFieldAutoSize.LEFT
            userLabel.text = "User name:"
            addChild(userLabel);

            userNameText = new TextInput();
            userNameText.move(80, 270);
            userNameText.text = "user " + int(Math.random() * 65536);
            addChild(userNameText);

            chatText = new TextInput();
            chatText.addEventListener(ComponentEvent.ENTER, DoPost);
            chatText.move(185, 270);
            chatText.maxChars = 255;
            chatText.width = 215;
            addChild(chatText);

        }

        public function onPlayStatus(info:Object):void {}
        public function onMetaData(info:Object):void {}
        public function onCuePoint(info:Object):void {}
        public function onTextData(info:Object):void {}

    }

}




removeHaveObjects

()method 
public function removeHaveObjects(startIndex:Number, endIndex:Number):void

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Removes objects from startIndex through endIndex, from the set of objects this node advertises to neighbors as objects for which it fulfills requests. Indices must be whole numbers from 0 through 9007199254740992.

For more information about object replication, see "Replicate an object within a group" in Flash Media Server Developer’s Guide.

NOTE: Test for the NetGroup.Neighbor.Connect event before calling this method.

Parameters

startIndex:Number — The beginning of the range of object indices to remove from the Have set.
 
endIndex:Number — The end of the range of object indices to remove from the Have set.


Throws
RangeError — A number passed to this method is less than 0 or greater than 9007199254740992.

Related API Elements

removeWantObjects

()method 
public function removeWantObjects(startIndex:Number, endIndex:Number):void

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Removes objects from startIndex through endIndex, from the set of objects to retrieve. Indices must be whole numbers from 0 through 9007199254740992.

For more information about object replication, see "Replicate an object within a group" in Flash Media Server Developer’s Guide.

NOTE: Test for the NetGroup.Neighbor.Connect event before calling this method.

Parameters

startIndex:Number — The beginning of the range of object indices to remove from the Want set.
 
endIndex:Number — The end of the range of object indices to remove from the Want set.


Throws
RangeError — A number passed to this method is less than 0 or greater than 9007199254740992.

Related API Elements

sendToAllNeighbors

()method 
public function sendToAllNeighbors(message:Object):String

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Sends a message to all neighbors. Returns NetGroupSendResult.SENT if at least one neighbor was selected.

For more information about routing messages, see "Route messages directly to a peer" in Flash Media Server Developer’s Guide.

When a node receives a message, a NetStatusEvent is sent to the NetGroup's event listener with NetGroup.SendTo.Notify in the code property of the info object.

NOTE: Test for the NetGroup.Neighbor.Connect event before calling this method.

Parameters

message:Object — The message to send.

Returns
String — A property of enumeration class NetGroupSendResult indicating the success or failure of the send.

Related API Elements

sendToNearest

()method 
public function sendToNearest(message:Object, groupAddress:String):String

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Sends a message to the neighbor (or local node) nearest to the specified group address. Considers neighbors from the entire ring. Returns NetGroupSendResult.SENT if the message was successfully sent toward its destination.

For more information about routing messages, see "Route messages directly to a peer" in Flash Media Server Developer’s Guide.

When a node receives a message, a NetStatusEvent is sent to the NetGroup's event listener with NetGroup.SendTo.Notify in the code property of the info object.

NOTE: Test for the NetGroup.Neighbor.Connect event before calling this method.

Parameters

message:Object — The message to send.
 
groupAddress:String — The group address toward which to route the message.

Returns
String — A property of enumeration class NetGroupSendResult indicating the success or failure of the send.

Related API Elements

sendToNeighbor

()method 
public function sendToNeighbor(message:Object, sendMode:String):String

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Sends a message to the neighbor specified by the sendMode parameter. Returns NetGroupSendResult.SENT if the message was successfully sent to the requested destination.

For more information about routing messages, see "Route messages directly to a peer" in Flash Media Server Developer’s Guide.

When a node receives a message, a NetStatusEvent is sent to the NetGroup's event listener with NetGroup.SendTo.Notify in the code property of the info object.

NOTE: Test for the NetGroup.Neighbor.Connect event before calling this method.

Parameters

message:Object — The message to send.
 
sendMode:String — A property of enumeration class NetGroupSendMode specifying the neighbor to which to send the message.

Returns
String — A property of enumeration class NetGroupSendResult indicating the success or failure of the send.

Related API Elements

writeRequestedObject

()method 
public function writeRequestedObject(requestID:int, object:Object):void

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

Satisfies the request as received by NetStatusEvent NetGroup.Replication.Request for an object previously advertised with the addHaveObjects() method. The object can be any of the following: An Object, an int, a Number, and a String. The object cannot be a MovieClip.

For more information about object replication, see "Replicate an object within a group" in Flash Media Server Developer’s Guide.

NOTE: Test for the NetGroup.Neighbor.Connect event before calling this method.

Parameters

requestID:int — The request identifier as given in the NetGroup.Replication.Request event.
 
object:Object — The object corresponding to the index given in the NetGroup.Replication.Request event.

Related API Elements

Event Detail

netStatus

Event
Event Object Type: flash.events.NetStatusEvent
property NetStatusEvent.type = flash.events.NetStatusEvent.NET_STATUS

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 10.1

Dispatched when a NetGroup object is reporting its status or error condition. The netStatus event contains an info property. The info property is an object that contains information about the event, such as whether a connection attempt succeeded or failed.

Defines the value of the type property of a netStatus event object.

This event has the following properties:

PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
infoAn object with properties that describe the object's status or error condition.
targetThe NetConnection or NetStream object reporting its status.

Related API Elements

NetGroupExample.as

This is a simple video chat application that uses peer-to-peer networking. The application connects over RTMFP to Flash Media Server. The server keeps the client applications' fingerprints and manages the peer group as clients connect. However, all data is sent between clients (peers) -- data is not sent back to the server.

When you run the application, you can enter any group name into the text input field. The GroupSpecifier class uses the name (along with any GroupSpecifier properties you've set) to create a string which is the perpetually unique name of the group. To connect another client to the group, that client must use the same group name. For example, if client A uses the group name "firstmesh", other clients that want to communicate with client A must also use the group name "firstmesh". If client B uses the group name "kite", it will connect successfully, but it will create a new group and won't be able to communicate with client A or anyone in the "firstmesh" group.


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" height="100%" applicationComplete="OnApplicationComplete()">
    <mx:Script>
        <![CDATA[
            private var netConnection:NetConnection = null;
            private var netStream:NetStream = null;
            private var netGroup:NetGroup = null;
            private var video:Video = null;
            private var sequenceNumber:uint = 0;
            private var resizeTimer:Timer = null;

            private const SERVER:String = "rtmfp://fms.example.com/someapp";

            [Bindable] private var connected:Boolean = false;
            [Bindable] private var joinedGroup:Boolean = false;

            private function OnApplicationComplete():void
            {
                userName.text = "user " + int(Math.random() * 65536);

                groupName.text = "channel" + (int(Math.random() * 899) + 101);

                resizeTimer = new Timer(2000.0);
                resizeTimer.addEventListener(TimerEvent.TIMER, DoResizeVideo);
                resizeTimer.start();
            }

            private function StatusMessage(msg:Object):void
            {
                statusLog.text += msg;
                statusLog.verticalScrollPosition = statusLog.textHeight;
                statusLog.validateNow();
            }

            private function NetStatusHandler(e:NetStatusEvent):void
            {
                StatusMessage(e.info.code);
                switch(e.info.code)
                {
                case "NetConnection.Connect.Success":
                    OnConnect();
                    break;

                case "NetConnection.Connect.Closed":
                case "NetConnection.Connect.Failed":
                case "NetConnection.Connect.Rejected":
                case "NetConnection.Connect.AppShutdown":
                case "NetConnection.Connect.InvalidApp":
                    OnDisconnect();
                    break;

                case "NetStream.Connect.Success": // e.info.stream
                    OnNetStreamConnect();
                    break;

                case "NetStream.Connect.Rejected": // e.info.stream
                case "NetStream.Connect.Failed": // e.info.stream
                    DoDisconnect();
                    break;

                case "NetGroup.Connect.Success": // e.info.group
                    OnNetGroupConnect();
                    break;

                case "NetGroup.Connect.Rejected": // e.info.group
                case "NetGroup.Connect.Failed": // e.info.group
                    DoDisconnect();
                    break;

                case "NetGroup.Posting.Notify": // e.info.message, e.info.messageID
                    OnPosting(e.info.message);
                    break;


                case "NetStream.MulticastStream.Reset":
                case "NetStream.Buffer.Full":
                    DoResizeVideo();
                    break;

                case "NetGroup.SendTo.Notify": // e.info.message, e.info.from, e.info.fromLocal
                case "NetGroup.LocalCoverage.Notify": //
                case "NetGroup.Neighbor.Connect": // e.info.neighbor
                case "NetGroup.Neighbor.Disconnect": // e.info.neighbor
                case "NetGroup.MulticastStream.PublishNotify": // e.info.name
                case "NetGroup.MulticastStream.UnpublishNotify": // e.info.name
                case "NetGroup.Replication.Fetch.SendNotify": // e.info.index
                case "NetGroup.Replication.Fetch.Failed": // e.info.index
                case "NetGroup.Replication.Fetch.Result": // e.info.index, e.info.object
                case "NetGroup.Replication.Request": // e.info.index, e.info.requestID
                default:
                    break;
                }
            }

            private function DoConnect():void
            {
                StatusMessage("Connecting to \"" + SERVER + "\" ...\n");
                netConnection = new NetConnection();
                netConnection.addEventListener(NetStatusEvent.NET_STATUS, NetStatusHandler);
                netConnection.connect(SERVER);
            }

            private function OnConnect():void
            {
                var groupSpecifier:GroupSpecifier;

                StatusMessage("Connected\n");
                connected = true;

                groupSpecifier = new GroupSpecifier("max2009lab/" + groupName.text);
                groupSpecifier.multicastEnabled = true;
                groupSpecifier.postingEnabled = true;
                groupSpecifier.serverChannelEnabled = true;

                netStream = new NetStream(netConnection, groupSpecifier.groupspecWithAuthorizations());
                netStream.addEventListener(NetStatusEvent.NET_STATUS, NetStatusHandler);

                netGroup = new NetGroup(netConnection, groupSpecifier.groupspecWithAuthorizations());
                netGroup.addEventListener(NetStatusEvent.NET_STATUS, NetStatusHandler);

                StatusMessage("Join \"" + groupSpecifier.groupspecWithAuthorizations() + "\"\n");
            }

            private function OnNetStreamConnect():void
            {
                netStream.client = this;

                var mic:Microphone = Microphone.getMicrophone();
                if(mic)
                {
                    mic.codec = SoundCodec.SPEEX;
                    mic.setSilenceLevel(0);

                    netStream.attachAudio(mic);

                    StatusMessage("got microphone\n");
                }

                var camera:Camera = Camera.getCamera();
                if(camera)
                {
                    camera.setMode(320, 240, 10);
                    camera.setQuality(30000, 0);
                    camera.setKeyFrameInterval(15);

                    videoDisplay.attachCamera(camera);
                    videoDisplay.maintainAspectRatio = true;

                    netStream.attachCamera(camera);

                    StatusMessage("got camera\n");
                }

                netStream.publish("stream");
            }

            private function OnNetGroupConnect():void
            {
                joinedGroup = true;
            }

            private function DoDisconnect():void
            {
                if(netConnection)
                    netConnection.close();
                videoDisplay.attachCamera(null);
            }

            private function OnDisconnect():void
            {
                StatusMessage("Disconnected\n");
                netConnection = null;
                netStream = null;
                netGroup = null;
                connected = false;
                joinedGroup = false;
            }

            private function ClearChatText():void
            {
                chatText.text = "";
            }

            private function DoPost():void
            {
                var message:Object = new Object;

                message.user = userName.text;
                message.text = chatText.text;
                message.sequence = sequenceNumber++;
                message.sender = netConnection.nearID;

                netGroup.post(message);

                StatusMessage("==> " + chatText.text + "\n");

                chatText.callLater(ClearChatText);
            }

            private function OnPosting(message:Object):void
            {
                StatusMessage("<" + message.user + "> " + message.text + "\n");
            }

            private function DoResizeVideo(ignored:* = null):void
            {
                if(video)
                {
                    if( (0 == video.videoHeight)
                     || (0 == video.videoWidth)
                    )
                    {
                        video.height = videoDisplay.height;
                        video.width = videoDisplay.width;
                        video.x = 0;
                        video.y = 0;
                    }
                    else
                    {
                        var videoAspect:Number = Number(video.videoWidth) / Number(video.videoHeight);
                        var displayAspect:Number = Number(videoDisplay.width) / Number(videoDisplay.height);
                        var adjustFactor:Number;

                        if(videoAspect >= displayAspect) // video is wider than display
                        {
                            adjustFactor = Number(video.videoWidth) / Number(videoDisplay.width);
                            video.width = videoDisplay.width;
                            video.height = int(Number(video.videoHeight) / adjustFactor);
                            video.x = 0;
                            video.y = int((videoDisplay.height - video.height) / 2);
                        }
                        else
                        {
                            adjustFactor = Number(video.videoHeight) / Number(videoDisplay.height);
                            video.height = videoDisplay.height;
                            video.width = int(Number(video.videoWidth) / adjustFactor);
                            video.x = int((videoDisplay.width - video.width) / 2);
                            video.y = 0;
                        }
                    }
                }
            }

            public function onPlayStatus(info:Object):void {}
            public function onMetaData(info:Object):void {}
            public function onCuePoint(info:Object):void {}
            public function onTextData(info:Object):void {}

            public function ValidateConnectAllowed(isConnected:Boolean, groupNameText:String):Boolean
            {
                return (!isConnected) && (groupNameText.length > 0);
            }
        ]]>
    </mx:Script>

    <mx:VBox top="10" right="10" left="10" bottom="10" verticalGap="6">
        <mx:HBox width="100%">
            <mx:Text text="Group:"/>
            <mx:TextInput id="groupName" width="100%" text="default" enabled="{!connected}"/>
            <mx:Button label="Connect" click="DoConnect()" enabled="{ValidateConnectAllowed(connected, groupName.text)}" />
            <mx:Button label="Disconnect" click="DoDisconnect()" enabled="{connected}" />
        </mx:HBox>
        <mx:VideoDisplay id="videoDisplay" width="320" height="240" resize="DoResizeVideo()"/>
        <mx:TextArea id="statusLog" width="100%" height="100%"/>
        <mx:HBox width="100%">
            <mx:TextInput id="userName" width="160" />
            <mx:TextInput id="chatText" width="100%" enabled="{joinedGroup}" enter="DoPost()"/>
        </mx:HBox>
    </mx:VBox>

</mx:Application>