用于 Adobe® Flash® Platform 的 ActionScript® 3.0 参考
主页  |  隐藏包列表和类列表 |   |   |  新增内容  |  索引  |  附录  |  为什么显示为英语?
过滤条件: AIR 30.0 和更早版本, Flash Player 30.0 和更早版本, Flash Lite 4
Flex 4.6 和更早版本, Flash Pro CS6 和更早版本
隐藏过滤条件
flash.net 

NetGroup  - AS3

x

顶级
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

语言元素

全局常量
全局函数
运算符
语句、关键字和指令
特殊类型

附录

新增内容
编译器错误
编译器警告
运行时错误
迁移到 ActionScript 3
支持的字符集
仅适用于 MXML 的标签
Motion XML 元素
Timed Text 标记
不推荐使用的元素的列表
AccessibilityImplementation 常量
如何使用 ActionScript 示例
法律声明
flash.net
public class NetGroup
继承NetGroup Inheritance EventDispatcher Inheritance Object

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

NetGroup 类的实例表示 RTMFP 组中的成员资格。使用此类执行以下操作:
  • 监视服务质量 info 属性包含一个 NetGroupInfo 对象,该对象的属性为此组提供 QOS 统计数据。
  • 发布。调用 post() 以为组中的所有成员广播 ActionScript 消息。
  • 直接路由。调用 sendToNearest()sendToNeighbor()sendToAllNeighbors() 以将短数据消息发送给对等组中的特定成员。源和目标不需要进行直接连接。
  • 对象复制。调用 addHaveObjects()removeHaveObjects()addWantObjects()removeWantObjects()writeRequestedObject()denyRequestedObject() 以将大型数据分解成数据片段,然后将其复制到对等组中的所有节点。

在客户端 NetGroup 类中,NetConnection 会调度以下事件:

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

该事件对象的 info.group 属性包含对事件源 (NetGroup) 的引用。NetGroup 会调度所有其他事件。在服务器端 NetGroup 类中,NetGroup 会调度所有事件。

有关使用组合对等协助网络的信息,请参阅同样由 Tom Krcha 编写的使用 Flash Media 和 RTMFP 的社交媒体体验

有关对等协助网络技术细节的信息,请参阅 Adobe 计算机科学家 Matthew Kaufman 编写的采用 RTMFP 的 Flash 平台上的 P2P

查看示例

相关 API 元素



公共属性
 属性由以下参数定义
 Inheritedconstructor : Object
对类对象或给定对象实例的构造函数的引用。
Object
  estimatedMemberCount : Number
[只读] 根据本地邻点的密度并假设组地址均匀分布来指定估计的组成员数。
NetGroup
  info : NetGroupInfo
[只读] 返回一个 NetGroupInfo 对象,其属性提供有关此 NetGroup 的 RTMFP 对等数据传输的服务质量统计信息。
NetGroup
  localCoverageFrom : String
[只读] 指定此节点距离“最近”并对其负责的组地址的开始范围。
NetGroup
  localCoverageTo : String
[只读] 指定此节点距离“最近”并对其负责的组地址的结尾范围。
NetGroup
  neighborCount : Number
[只读] 指定与此节点直接连接的组成员数。
NetGroup
  receiveMode : String
指定此节点的路由接收模式作为 NetGroupReceiveMode enum 类中的一个值。
NetGroup
  replicationStrategy : String
指定对象复制获取策略。
NetGroup
公共方法
 方法由以下参数定义
  
NetGroup(connection:NetConnection, groupspec:String)
在指定的 NetConnection 对象上构造一个 NetGroup 并将其加入到 groupspec 指定的组。
NetGroup
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
使用 EventDispatcher 对象注册事件侦听器对象,以使侦听器能够接收事件通知。
EventDispatcher
  
addHaveObjects(startIndex:Number, endIndex:Number):void
将从 startIndex 到 endIndex 的对象添加到对象集,此节点将对象集作为要完成其请求的对象向邻居播发。
NetGroup
  
手动添加一个记录以指定 peerID 为组成员。
NetGroup
  
通过立即直接连接到指定的 peerID 手动添加邻居,该 peerID 必须位于此组中。
NetGroup
  
addWantObjects(startIndex:Number, endIndex:Number):void
将从 startIndex 到 endIndex 的对象添加到要检索的对象集。
NetGroup
  
断开与组的连接,然后关闭此 NetGroup。
NetGroup
  
将 peerID 转换为适合与 sendToNearest() 方法一起使用的组地址。
NetGroup
  
拒绝 NetStatusEvent NetGroup.Replication.Request 中收到的针对先前使用 addHaveObjects() 播发的对象的请求。
NetGroup
 Inherited
将事件调度到事件流中。
EventDispatcher
 Inherited
检查 EventDispatcher 对象是否为特定事件类型注册了任何侦听器。
EventDispatcher
 Inherited
表示对象是否已经定义了指定的属性。
Object
 Inherited
表示 Object 类的实例是否在指定为参数的对象的原型链中。
Object
  
post(message:Object):String
将消息发送给组中的所有成员。
NetGroup
 Inherited
表示指定的属性是否存在、是否可枚举。
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
从 EventDispatcher 对象中删除侦听器。
EventDispatcher
  
removeHaveObjects(startIndex:Number, endIndex:Number):void
将从 startIndex 到 endIndex 的对象从对象集中删除,此节点将对象集作为其完成请求的对象播发到邻居。
NetGroup
  
removeWantObjects(startIndex:Number, endIndex:Number):void
从要检索的对象集中删除从 startIndex 到 endIndex 的对象。
NetGroup
  
将消息发送给所有邻居。
NetGroup
  
sendToNearest(message:Object, groupAddress:String):String
将消息发送给最接近指定的组地址的邻居(或本地节点)。
NetGroup
  
sendToNeighbor(message:Object, sendMode:String):String
将消息发送到由 sendMode 参数指定的邻居。
NetGroup
 Inherited
设置循环操作动态属性的可用性。
Object
 Inherited
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。
Object
 Inherited
返回指定对象的字符串表示形式。
Object
 Inherited
返回指定对象的原始值。
Object
 Inherited
检查是否用此 EventDispatcher 对象或其任何祖代为指定事件类型注册了事件侦听器。
EventDispatcher
  
writeRequestedObject(requestID:int, object:Object):void
当 NetStatusEvent NetGroup.Replication.Request 收到针对先前使用 addHaveObjects() 方法播发的对象的请求时,满足请求。
NetGroup
事件
 事件 摘要 由以下参数定义
 Inherited[广播事件] Flash Player 或 AIR 应用程序获得操作系统焦点并变为活动状态时将调度此事件。EventDispatcher
 Inherited[广播事件] Flash Player 或 AIR 应用程序失去操作系统焦点并变为非活动状态时将调度此事件。EventDispatcher
  在 NetGroup 对象报告其状态或错误条件时调度。NetGroup
属性详细信息

estimatedMemberCount

属性
estimatedMemberCount:Number  [只读]

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

根据本地邻点的密度并假设组地址均匀分布来指定估计的组成员数。



实现
    public function get estimatedMemberCount():Number

相关 API 元素

info

属性 
info:NetGroupInfo  [只读]

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

返回一个 NetGroupInfo 对象,其属性提供有关此 NetGroup 的 RTMFP 对等数据传输的服务质量统计信息。



实现
    public function get info():NetGroupInfo

相关 API 元素

localCoverageFrom

属性 
localCoverageFrom:String  [只读]

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

指定此节点距离“最近”并对其负责的组地址的开始范围。在沿组地址的环路报文 2256 增长的方向上指定范围。



实现
    public function get localCoverageFrom():String

相关 API 元素

localCoverageTo

属性 
localCoverageTo:String  [只读]

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

指定此节点距离“最近”并对其负责的组地址的结尾范围。在沿组地址的环路报文 2256 增长的方向上指定范围。



实现
    public function get localCoverageTo():String

相关 API 元素

neighborCount

属性 
neighborCount:Number  [只读]

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

指定与此节点直接连接的组成员数。



实现
    public function get neighborCount():Number

相关 API 元素

receiveMode

属性 
receiveMode:String

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

指定此节点的路由接收模式作为 NetGroupReceiveMode enum 类中的一个值。



实现
    public function get receiveMode():String
    public function set receiveMode(value:String):void

相关 API 元素

replicationStrategy

属性 
replicationStrategy:String

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

指定对象复制获取策略。此值是 NetGroupReplicationStrategy 类中的枚举值之一。



实现
    public function get replicationStrategy():String
    public function set replicationStrategy(value:String):void

相关 API 元素

构造函数详细信息

NetGroup

()构造函数
public function NetGroup(connection:NetConnection, groupspec:String)

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

在指定的 NetConnection 对象上构造一个 NetGroup 并将其加入到 groupspec 指定的组。

大多数情况下,groupspec 有可能使用本地系统上的网络上行链路。当使用 groupspec 构造 NetStream 或 NetGroup 对象时,Flash Player 将显示一个“隐私”对话框。该对话框询问 Flash Player 是否可以使用连接与用户的同级共享数据。如果用户单击“允许此域”,则用户下一次连接到此应用程序时将不显示该对话框。如果用户不允许对等协助网络,则将禁用组中的所有对等功能(发布、定向路由、对象复制和多播)。如果允许此权限,则会使用 info 对象的 code 属性中的 NetGroup.Connect.Success 将 NetStatusEvent 发送到 NetConnection 的事件侦听器。如果拒绝此权限,code 属性是 NetGroup.Connect.Rejected。在接收到 NetGroup.Connect.Success 事件之前,如果您尝试调用 NetGroup 对象的任何方法,将引发异常。

注意:当客户端订阅本机 IP 多播流时,不显示安全对话框。

参数
connection:NetConnection — 一个 NetConnection 对象。
 
groupspec:String — 指定要加入的 RTMFP 对等组的字符串,包括其名称、该成员的能力、限制和授权。
     new NetGroup(myConnection, myGroupSpecifier.groupspecWithAuthorizations());
     

引发
ArgumentError — 未连接 NetConnection 实例。
 
Error — 此 groupspec 无效。

相关 API 元素

方法详细信息

addHaveObjects

()方法
public function addHaveObjects(startIndex:Number, endIndex:Number):void

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

将从 startIndexendIndex 的对象添加到对象集,此节点将对象集作为要完成其请求的对象向邻居播发。默认情况下,Have 集为空。索引必须是介于 0 和 9007199254740992 之间的整数。

有关对象复制的详细信息,请参阅《Flash Media Server 开发人员指南》中的“在组内复制对象”

此方法使用 info 对象的 code 属性中的 "NetGroup.Replication.Request" 将 NetStatusEvent 发送到 NetGroup 的事件侦听器。

注意:在调用此方法之前对 NetGroup.Neighbor.Connect 事件进行测试。

参数

startIndex:Number — 要添加到 Have 集的对象索引的起始范围。
 
endIndex:Number — 要添加到 Have 集的对象索引的结束范围。


引发
RangeError — 传递给此方法的数字小于 0 或大于 9007199254740992。

相关 API 元素

addMemberHint

()方法 
public function addMemberHint(peerID:String):Boolean

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

手动添加一个记录以指定 peerID 为组成员。仅当拓扑需要此记录时才尝试立即连接该记录。

参数

peerID:String — 要添加到潜在邻居的 peerID。

返回
Boolean — 若成功,则为 TRUE;若失败,则为 FALSE。

相关 API 元素

addNeighbor

()方法 
public function addNeighbor(peerID:String):Boolean

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

通过立即直接连接到指定的 peerID 手动添加邻居,该 peerID 必须位于此组中。如果拓扑不需要该直接连接,该直接连接可能稍后将删除。

参数

peerID:String — 要立即连接的 peerID。

返回
Boolean — 若成功,则为 TRUE;若失败,则为 FALSE。

相关 API 元素

addWantObjects

()方法 
public function addWantObjects(startIndex:Number, endIndex:Number):void

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

将从 startIndexendIndex 的对象添加到要检索的对象集。索引必须是介于 0 和 9007199254740992 之间的整数。默认情况下,Want 集为空。

有关对象复制的详细信息,请参阅《Flash Media Server 开发人员指南》中的“在组内复制对象”

此方法使用 info.code 属性中的 NetGroup.Replication.Fetch.SendNotify 将 NetStatusEvent 发送到 NetGroup 的事件侦听器。此事件后跟 NetGroup.Replication.Fetch.FailedNetGroup.Replication.Fetch.Result 事件。

注意:在调用此方法之前对 NetGroup.Neighbor.Connect 事件进行测试。

参数

startIndex:Number — 要添加到 Want 集的对象索引的起始范围。
 
endIndex:Number — 要添加到 Want 集的对象索引的结束范围。


引发
RangeError — 传递给此方法的数字小于 0 或大于 9007199254740992。

相关 API 元素

close

()方法 
public function close():void

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

断开与组的连接,然后关闭此 NetGroup。此 NetGroup 在调用此方法后不可用。

convertPeerIDToGroupAddress

()方法 
public function convertPeerIDToGroupAddress(peerID:String):String

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

将 peerID 转换为适合与 sendToNearest() 方法一起使用的组地址。

参数

peerID:String — 要转换的 peerID。

返回
String — peerID 的组地址。

相关 API 元素

denyRequestedObject

()方法 
public function denyRequestedObject(requestID:int):void

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

拒绝 NetStatusEvent NetGroup.Replication.Request 中收到的针对先前使用 addHaveObjects() 播发的对象的请求。请求者可能再次请求此对象,除非或直到它从 Have 集撤出。

有关对象复制的详细信息,请参阅《Flash Media Server 开发人员指南》中的“在组内复制对象”

注意:在调用此方法之前对 NetGroup.Neighbor.Connect 事件进行测试。

参数

requestID:int — 在 NetGroup.Replication.Request 事件中给定的请求标识符。

相关 API 元素

post

()方法 
public function post(message:Object):String

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

将消息发送给组中的所有成员。要调用此方法,则 GroupSpecifier.postingEnabled 属性在已传递给 NetGroup 构造函数的 groupspec 中必须为 true。有关详细信息,请参阅《Flash Media Server 开发人员指南》中的“向组发布消息”

所有消息都必须是唯一的;与早期发送的某一消息相同的消息可能不会传播。使用序列号使消息是唯一的。

消息传送没有顺序。无法保证消息传送。

消息在 AMF 中进行序列化。消息可以是下列类型之一:对象、整数、数字或字符串。消息不能是 MovieClip。

此方法使用 info.code 属性中的 "NetGroup.Posting.Notify" 将 NetStatusEvent 发送到 NetGroup 的事件侦听器。"NetGroup.Posting.Notify" 事件被调度到客户端和服务器上的 NetGroup。

注意:在调用此方法之前对 NetGroup.Neighbor.Connect 事件进行测试。

参数

message:Object — 要发送给组中的所有其他成员的消息。

返回
String — 如果发送,则为消息的 messageID;若出现错误,则为 null。messageID 是消息的序列化的原始字节的十六进制 SHA256。

相关 API 元素


示例  ( 如何使用本示例 )

这是一个使用对等网络的简单文本聊天应用程序。应用程序通过 RTMFP 连接到 Flash Media Server。服务器保留客户端应用程序的指纹并在客户端连接时管理对等组。但是,所有数据都是在客户端(对等机)之间发送的 -- 数据并不发送回服务器。

运行应用程序时,可以在文本输入字段中输入任何组名称。GroupSpecifier 类使用该名称(以及您设置的所有 GroupSpecifier 属性)来创建字符串,该字符串为该组的终身唯一名称。要将另一个客户端连接到该组,该客户端必须使用相同的组名称。例如,如果客户端 A 使用组名称“firstmesh”,要与客户端 A 通讯的其他客户端也必须使用组名称“firstmesh”。如果客户端 B 使用组名称“kite”,它将成功连接,但会创建一个新组,并将无法与“firstmesh”组中的客户端 A 或任何人进行通讯。

要运行此示例,将 Button、Label、TextInput 和 TextArea 组件添加到 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

()方法 
public function removeHaveObjects(startIndex:Number, endIndex:Number):void

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

将从 startIndexendIndex 的对象从对象集中删除,此节点将对象集作为其完成请求的对象播发到邻居。索引必须是介于 0 和 9007199254740992 之间的整数。

有关对象复制的详细信息,请参阅《Flash Media Server 开发人员指南》中的“在组内复制对象”

注意:在调用此方法之前对 NetGroup.Neighbor.Connect 事件进行测试。

参数

startIndex:Number — 要从 Have 集删除的对象索引的起始范围。
 
endIndex:Number — 要从 Have 集删除的对象索引的结束范围。


引发
RangeError — 传递给此方法的数字小于 0 或大于 9007199254740992。

相关 API 元素

removeWantObjects

()方法 
public function removeWantObjects(startIndex:Number, endIndex:Number):void

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

从要检索的对象集中删除从 startIndexendIndex 的对象。索引必须是介于 0 和 9007199254740992 之间的整数。

有关对象复制的详细信息,请参阅《Flash Media Server 开发人员指南》中的“在组内复制对象”

注意:在调用此方法之前对 NetGroup.Neighbor.Connect 事件进行测试。

参数

startIndex:Number — 从 Want 集删除的对象索引的起始范围。
 
endIndex:Number — 从 Want 集删除的对象索引的结束范围。


引发
RangeError — 传递给此方法的数字小于 0 或大于 9007199254740992。

相关 API 元素

sendToAllNeighbors

()方法 
public function sendToAllNeighbors(message:Object):String

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

将消息发送给所有邻居。如果选择了至少一个邻居,则返回 NetGroupSendResult.SENT

有关路由消息的详细信息,请参阅《Flash Media Server 开发人员指南》中的“将消息直接路由到同级”

当节点接收消息时,NetStatusEvent 将发送到 NetGroup 的事件侦听器,其中 info 对象的 code 属性为 NetGroup.SendTo.Notify

注意:在调用此方法之前对 NetGroup.Neighbor.Connect 事件进行测试。

参数

message:Object — 要发送的消息。

返回
String — 枚举类 NetGroupSendResult 的属性表示发送成功或失败。

相关 API 元素

sendToNearest

()方法 
public function sendToNearest(message:Object, groupAddress:String):String

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

将消息发送给最接近指定的组地址的邻居(或本地节点)。考虑整个环上的邻居。如果消息成功发送到其目标,则返回 NetGroupSendResult.SENT

有关路由消息的详细信息,请参阅《Flash Media Server 开发人员指南》中的“将消息直接路由到同级”

当节点接收消息时,NetStatusEvent 将发送到 NetGroup 的事件侦听器,其中 info 对象的 code 属性为 NetGroup.SendTo.Notify

注意:在调用此方法之前对 NetGroup.Neighbor.Connect 事件进行测试。

参数

message:Object — 要发送的消息。
 
groupAddress:String — 向其路由消息的组地址。

返回
String — 枚举类 NetGroupSendResult 的属性表示发送成功或失败。

相关 API 元素

sendToNeighbor

()方法 
public function sendToNeighbor(message:Object, sendMode:String):String

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

将消息发送到 sendMode 参数指定的邻居。如果消息成功发送到其请求目标,则返回 NetGroupSendResult.SENT

有关路由消息的详细信息,请参阅《Flash Media Server 开发人员指南》中的“将消息直接路由到同级”

当节点接收消息时,NetStatusEvent 将发送到 NetGroup 的事件侦听器,其中 info 对象的 code 属性为 NetGroup.SendTo.Notify

注意:在调用此方法之前对 NetGroup.Neighbor.Connect 事件进行测试。

参数

message:Object — 要发送的消息。
 
sendMode:String — 枚举类 NetGroupSendMode 的属性指定向其发送消息的邻居。

返回
String — 枚举类 NetGroupSendResult 的属性表示发送成功或失败。

相关 API 元素

writeRequestedObject

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

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

当 NetStatusEvent NetGroup.Replication.Request 收到针对先前使用 addHaveObjects() 方法播发的对象的请求时,满足请求。object 可以是下列任何类型:对象、整数、数字和字符串。object 不能是 MovieClip。

有关对象复制的详细信息,请参阅《Flash Media Server 开发人员指南》中的“在组内复制对象”

注意:在调用此方法之前对 NetGroup.Neighbor.Connect 事件进行测试。

参数

requestID:int — 在 NetGroup.Replication.Request 事件中给定的请求标识符。
 
object:Object — 与 NetGroup.Replication.Request 事件中给定的索引对应的对象。

相关 API 元素

事件详细信息

netStatus

事件
事件对象类型: flash.events.NetStatusEvent
属性 NetStatusEvent.type = flash.events.NetStatusEvent.NET_STATUS

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 10.1

在 NetGroup 对象报告其状态或错误条件时调度。netStatus 事件包含一个 info 属性。info 属性是一个对象,该对象包含有关该事件的信息,例如,连接尝试成功还是失败。

定义 netStatus 事件对象的 type 属性值。

此事件具有以下属性:

属性
bubblesfalse
cancelablefalse;没有要取消的默认行为。
currentTarget当前正在使用某个事件侦听器处理 Event 对象的对象。
info一个对象,具有描述对象的状态或错误条件的属性。
target报告其状态的 NetConnection 或 NetStream 对象。

相关 API 元素

NetGroupExample.as

这是一个使用对等网络的简单视频聊天应用程序。应用程序通过 RTMFP 连接到 Flash Media Server。服务器保留客户端应用程序的指纹并在客户端连接时管理对等组。但是,所有数据都是在客户端(对等机)之间发送的 -- 数据并不发送回服务器。

运行应用程序时,可以在文本输入字段中输入任何组名称。GroupSpecifier 类使用该名称(以及您设置的所有 GroupSpecifier 属性)来创建字符串,该字符串为该组的终身唯一名称。要将另一个客户端连接到该组,该客户端必须使用相同的组名称。例如,如果客户端 A 使用组名称“firstmesh”,要与客户端 A 通讯的其他客户端也必须使用组名称“firstmesh”。如果客户端 B 使用组名称“kite”,它将成功连接,但会创建一个新组,并将无法与“firstmesh”组中的客户端 A 或任何人进行通讯。


<?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>




[ X ]为什么显示为英语?
《ActionScript 3.0 参考》中的内容以英语显示

《ActionScript 3.0 参考》中的部分内容未翻译成所有语言。当某个语言元素未翻译时,将显示为英语。例如,ga.controls.HelpBox 类未翻译成任何语言。因此在简体中文版的参考中,ga.controls.HelpBox 类显示为英语。