Adobe® Flash® Platform 用 ActionScript® 3.0 リファレンスガイド
ホーム  |  パッケージおよびクラスリストの非表示 |  パッケージ  |  クラス  |  新機能  |  索引  |  付録  |  英語で表示される理由
フィルター: AIR 30.0 以前, Flash Player 30.0 以前, Flash Lite 4
Flex 4.6 以前, Flash Pro CS6 以前
フィルターを非表示
flash.net 

LocalConnection  - 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 のみのタグ
モーション XML エレメント
Timed Text タグ
使用されなくなったエレメントのリスト
Accessibility Implementation 定数
ActionScript の例の使用方法
法律上の注意
パッケージflash.net
クラスpublic class LocalConnection
継承LocalConnection Inheritance EventDispatcher Inheritance Object

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9, Flash Lite 4

LocalConnection クラスを使用すると、別の LocalConnection オブジェクトのメソッドを呼び出すことができる LocalConnection オブジェクトを作成できます。 次の通信が可能です。
  • 単一の SWF ファイル内での通信
  • 複数の SWF ファイル間の通信
  • AIR アプリケーションのコンテンツ(SWF ベースまたは HTML ベース)間の通信
  • AIR アプリケーションのコンテンツ(SWF ベースまたは HTML ベース)とブラウザーで実行されている SWF コンテンツ間の通信

AIR プロファイルのサポート:この機能はすべてのデスクトップオペレーティングシステムおよびすべての AIR for TV デバイスでサポートされますが、モバイルデバイスではサポートされません。LocalConnection.isSupported プロパティを使用して、サポートされているかどうかを実行時にテストすることができます。複数のプロファイル間での API サポートについて詳しくは、AIR プロファイルのサポートを参照してください。

注意:AIR for TV デバイスでは、AIR アプリケーションの SWF ベースのコンテンツ間でのみ通信がサポートされます。

ローカル接続では、SWF ファイル間のこの種の通信は fscommand() または JavaScript を使用しなくても可能です。LocalConnection オブジェクトを使って通信できるのは、同じクライアントコンピューター上で実行中のファイル間だけです。ただし、これらは異なるアプリケーションで実行されていてもかまいません。例えば、ブラウザーで実行されているファイルと、Adobe AIR で実行されている SWF ファイルとの間で通信することができます。

ActionScript 3.0 で作成された LocalConnection オブジェクトは、ActionScript 1.0 または 2.0 で作成された LocalConnection オブジェクトと通信できます。また、その逆も可能です。ActionScript 1.0 または 2.0 で作成された LocalConnection オブジェクトは、ActionScript 3.0 で作成された LocalConnection オブジェクトと通信できます。Flasn Player では、このようなバージョンの異なる LocalConnection オブジェクト間の通信が自動的に処理されます。

LocalConnection オブジェクトにコールバックメソッドを追加するには、次の 3 つの方法があります。

  • LocalConnection クラスのサブクラスを作成してメソッドを追加する方法
  • LocalConnection.client プロパティを、メソッドを実装したオブジェクトに設定する方法
  • LocalConnection を拡張した動的なクラスを作成し、動的にメソッドを追加する方法

各ファイルで使用されるコマンドを確認することで、2 つのファイル間で通信を行うための LocalConnection オブジェクトの使用方法が理解しやすくなります。一方のファイルを受信側ファイルと呼びます。呼び出されるメソッドが含まれるファイルです。受信側ファイルには、LocalConnection オブジェクトと connect() メソッドの呼び出しが含まれている必要があります。もう一方のファイルを送信側ファイルと呼びます。メソッドを呼び出すファイルです。送信側ファイルには、もう 1 つの LocalConnection オブジェクトと send() メソッドの呼び出しが含まれている必要があります。

send()connect() の使い方は、両方のファイルが同じドメインにある場合、予測可能なドメイン名を持つ異なるドメインにある場合、予測不可能または動的なドメイン名を持つ異なるドメインにある場合により異なります。次の段落では、上記の 3 つの場合それぞれについて、サンプルコードを使用して説明します。

同じドメインの場合:この場合は、同じドメイン内の LocalConnection オブジェクト間だけで通信を許可します。同一ドメイン通信はデフォルトで許可されているので、これは LocalConnection オブジェクトの最も簡単な使用方法です。 同じドメインにある 2 つの ファイル間で通信を行う場合は、特別なセキュリティ対策を実装する必要はありません。connectionName パラメーターの値をそのまま connect() メソッドと send() メソッドに渡すだけです。

同じドメインからのロード

// receivingLC is in http://www.domain.com/receiving.swf
receivingLC.connect('myConnection');

// sendingLC is in http://www.domain.com/sending.swf
// myMethod() is defined in sending.swf
sendingLC.send('myConnection', 'myMethod');

予測可能なドメイン名を持つ異なるドメインの場合:異なるドメインに存在する 2 つの SWF ファイル間で通信を行う場合は、allowDomain() メソッドを呼び出して、2 つのドメイン間の通信を許可する必要があります。また、send() メソッドの接続名を、受信側 LocalConnection オブジェクトのドメイン名で修飾する必要があります。

別個のドメインからのロード

// receivingLC is in http://www.domain.com/receiving.swf
receivingLC.allowDomain('www.anotherdomain.com');
receivingLC.connect('myConnection');

// sendingLC is in http://www.anotherdomain.com/sending.swf
sendingLC.send('www.domain.com:myConnection', 'myMethod');

予測不可能なドメイン名を持つ異なるドメインの場合:受信側の LocalConnection オブジェクトを含むファイルをドメイン間で移植しやすくしたい場合があります。send() メソッドでドメイン名を指定せずに受信側と送信側の LocalConnection オブジェクトが同じドメインにないことを Flash Player に認識させるには、connect() 呼び出しと send() 呼び出しの両方で、接続名の前にアンダースコア(_)を付けます。 2 つのドメイン間の通信を許可するには、allowDomain() メソッドを呼び出して、LocalConnection の呼び出しを許可するドメインを渡します。または、ワイルドカード(*)を引数に渡して、すべてのドメインからの呼び出しを許可します。

ドメイン名が不明のときのロード

// receivingLC is in http://www.domain.com/receiving.swf
receivingLC.allowDomain('*');
receivingLC.connect('_myConnection');

// sendingLC is in http://www.anotherdomain.com/sending.swf
sendingLC.send('_myConnection', 'myMethod');

Flash Player から AIR アプリケーション:AIR アプリケーションサンドボックスで作成された LocalConnection オブジェクトでは特別なストリングが使用されます。これはドメイン名ではなく接続接頭辞だからです。ストリングのフォームは app#appID.pubID で、appID はアプリケーション ID、pubID はアプリケーションの発行者 ID です(発行者 ID は、AIR アプリケーションで発行者 ID が使用されている場合にのみ含めます)。例えば、AIR アプリケーションのアプリケーション ID が「com.example」で、発行者 ID がない場合は、app#com.example:myConnection をローカル接続ストリングとして使用できます。また、AIR アプリケーションでは allowDomain() メソッドを呼び出して、呼び出し側 SWF ファイルの元のドメインで渡す必要があります。

Flash Player から AIR への接続

// receivingLC is an AIR application with app ID = com.example (and no publisher ID)
receivingLC.allowDomain('www.domain.com');
receivingLC.connect('myConnection');

// sendingLC is in http://www.domain.com/sending.swf
sendingLC.send('app#com.example:myConnection', 'myMethod');

注意: AIR アプリケーションが AIR アプリケーションサンドボックス外で SWF をロードする場合、その SWF とローカル接続を確立する際の規則は、Flash Player で実行されている SWF との接続を確立する規則と同じです。

AIR アプリケーションから Flash Player:AIR アプリケーションが、Flash Player ランタイムで実行されている SWF と通信するときは、allowDomain() メソッドを呼び出して、AIR アプリケーションの接続接頭辞で渡すことで、この 2 つの間の通信を許可する必要があります。例えば、AIR アプリケーションのアプリケーション ID が「com.example」で、発行者 ID がない場合は、ストリング app#com.exampleallowDomain() メソッドに渡します。また、send() メソッドの接続名を、受信側 LocalConnection オブジェクトのドメイン名で修飾する必要もあります(ローカルファイルシステムからロードされた SWF ファイルのドメインとして「localhost」を使用します)。

AIR から Flash Player への通信

// receivingLC is in http://www.domain.com/receiving.swf
receivingLC.allowDomain('app#com.example');
receivingLC.connect('myConnection');

// sendingLC is an AIR application with app ID = com.example (and no publisher ID)
sendingLC.send('www.domain.com:myConnection', 'myMethod');

AIR アプリケーションから他の AIR アプリケーション:2 つの AIR アプリケーション間を通信するには、allowDomain() メソッドを呼び出して、送信側 AIR アプリケーションの接続接頭辞で渡すことで、この 2 つの間の通信を許可する必要があります。例えば、送信側アプリケーションのアプリケーション ID が「com.example」で、発行者 ID がない場合は、ストリング app#com.example を受信側アプリケーションの allowDomain() メソッドに渡します。また、send() メソッドの接続名を、受信側 LocalConnection オブジェクトの接続接頭辞で修飾する必要もあります。

AIR 間の通信

// receivingLC is an AIR application with app ID = com.sample (and no publisher ID)
receivingLC.allowDomain('app#com.example');
receivingLC.connect('myConnection');

// sendingLC is an AIR application with app ID = com.example (and no publisher ID)
sendingLC.send('app#com.sample:myConnection', 'myMethod');

LocalConnection オブジェクトを使用して、1 つのファイル内でデータを送受信することもできますが、これは一般的な方法ではありません。

send() メソッドと connect() メソッドの詳細については、connectionName パラメーター(LocalConnection.send() エントリおよび LocalConnection.connect() エントリ)の説明を参照してください。また、allowDomain() エントリおよび domain エントリも参照してください。

例を表示

関連する API エレメント



パブリックプロパティ
 プロパティ定義元
  client : Object
コールバックメソッドが呼び出されるオブジェクトを示します。
LocalConnection
 Inheritedconstructor : Object
指定されたオブジェクトインスタンスのクラスオブジェクトまたはコンストラクター関数への参照です。
Object
  domain : String
[読み取り専用] 現在のファイルが存在するドメインを表すストリングです。
LocalConnection
  isPerUser : Boolean
LocalConnection オブジェクトへのアクセスが現在のユーザーのみに制限されているのか(true)、コンピューター上のすべてのユーザーがグローバルにアクセスできるのか(false)を示します。
LocalConnection
  isSupported : Boolean
[静的] [読み取り専用] 現在のプラットフォームで LocalConnection クラスがサポートされている場合、isSupported プロパティは true に設定されます。サポートされていない場合は、false に設定されます。
LocalConnection
パブリックメソッド
 メソッド定義元
  
LocalConnection オブジェクトを作成します。
LocalConnection
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
イベントリスナーオブジェクトを EventDispatcher オブジェクトに登録し、リスナーがイベントの通知を受け取るようにします。
EventDispatcher
  
この LocalConnection インスタンスに LocalConnection 呼び出しを送信できる 1 つ以上のドメインを指定します。
LocalConnection
  
この LocalConnection オブジェクトに LocalConnection 呼び出しを送信できる 1 つ以上のドメインを指定します。
LocalConnection
  
LocalConnection オブジェクトを閉じます(切断します)。
LocalConnection
  
connect(connectionName:String):void
send() コマンド(送信側 LocalConnection オブジェクト)から送信されたコマンドを受け入れるように LocalConnection オブジェクトを準備します。
LocalConnection
 Inherited
イベントをイベントフローに送出します。
EventDispatcher
 Inherited
EventDispatcher オブジェクトに、特定のイベントタイプに対して登録されたリスナーがあるかどうかを確認します。
EventDispatcher
 Inherited
オブジェクトに指定されたプロパティが定義されているかどうかを示します。
Object
 Inherited
Object クラスのインスタンスが、パラメーターとして指定されたオブジェクトのプロトタイプチェーン内にあるかどうかを示します。
Object
 Inherited
指定されたプロパティが存在し、列挙できるかどうかを示します。
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
EventDispatcher オブジェクトからリスナーを削除します。
EventDispatcher
  
send(connectionName:String, methodName:String, ... arguments):void
connect(connectionName) メソッド(受信側 LocalConnection オブジェクト)で確立した接続を使用して、methodName で指定されたメソッドを呼び出します。
LocalConnection
 Inherited
ループ処理に対するダイナミックプロパティの可用性を設定します。
Object
 Inherited
ロケール固有の規則に従って書式設定された、このオブジェクトのストリング表現を返します。
Object
 Inherited
指定されたオブジェクトのストリング表現を返します。
Object
 Inherited
指定されたオブジェクトのプリミティブな値を返します。
Object
 Inherited
指定されたイベントタイプについて、この EventDispatcher オブジェクトまたはその祖先にイベントリスナーが登録されているかどうかを確認します。
EventDispatcher
イベント
 イベント 概要 定義元
 Inherited[ブロードキャストイベント] Flash Player または AIR アプリケーションがオペレーティングシステムのフォーカスを取得して、アクティブになったときに送出されます。EventDispatcher
  非同期形式で、つまりネイティブ非同期コードから例外がスローされると送出されます。LocalConnection
 Inherited[ブロードキャストイベント] Flash Player または AIR アプリケーションがオペレーティングシステムのフォーカスを失って、非アクティブになったときに送出されます。EventDispatcher
  LocalConnection.send() の呼び出しで、異なるセキュリティサンドボックスにデータを送信しようとしたときに送出されます。LocalConnection
  LocalConnection オブジェクトがステータスを報告するときに送出されます。LocalConnection
プロパティの詳細

client

プロパティ
client:Object

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9, Flash Lite 4

コールバックメソッドが呼び出されるオブジェクトを示します。デフォルトのオブジェクトは、作成されるローカル接続 this です。client プロパティを別のオブジェクトに設定すると、その別のオブジェクトでコールバックメソッドを呼び出すことができます。



実装
    public function get client():Object
    public function set client(value:Object):void

例外
TypeError client プロパティは、null 以外のオブジェクトに設定する必要があります。

domain

プロパティ 
domain:String  [読み取り専用]

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9, Flash Lite 4

現在のファイルが存在するドメインを表すストリングです。

Adobe AIR のアプリケーションセキュリティサンドボックスで実行されているコンテンツ(AIR アプリケーションと共にインストールされたコンテンツ)では、スーパードメインの代わりに、app# + AIR アプリケーションのアプリケーション ID(アプリケーション記述ファイルで定義)が使用されます。 例えば、アプリケーション ID が com.example.air.MyApp のアプリケーションでは、connectionName"app#com.example.air.MyApp:connectionName" に解決されます。

Flash Player 9 以降用にパブリッシュされた SWF ファイルでは、ファイルのサブドメインを含む正確なドメインを示すストリングを返します。 例えば、現在のファイルが www.adobe.com にある場合は、"www.adobe.com" を返します。

現在のファイルが、Flash Player で実行されているクライアントコンピューター上のローカルファイルである場合は、"localhost" を返します。

このプロパティの最も一般的な使用方法としては、送信側 LocalConnection オブジェクトのドメイン名を、受信側 LocalConnection オブジェクトで呼び出すメソッドのパラメーターとして組み込みます。あるいは、LocalConnection.allowDomain() と組み合わせて使用して、特定のドメインからのコマンドを受け入れます。同じドメイン内にある LocalConnection オブジェクト間でのみ通信する場合は、通常、このプロパティを使用する必要はありません。



実装
    public function get domain():String

関連する API エレメント

isPerUser

プロパティ 
isPerUser:Boolean

言語バージョン: ActionScript 3.0
ランタイムバージョン: Flash Player 10.0.32, AIR 1.5.2

LocalConnection オブジェクトへのアクセスが現在のユーザーのみに制限されているのか(true)、コンピューター上のすべてのユーザーがグローバルにアクセスできるのか(false)を示します。このプロパティは、Mac OS X で実行されるコンテンツのみに適用されます。他のプラットフォームでは、このパラメーターは無視されます。Windows および Linux オペレーティングシステムの接続は常にユーザーごとに管理されます。

Flash Player 10.0.22 以前および AIR 1.5.1 以前では、Mac OS X の LocalConnection オブジェクトにはグローバルにアクセスできます。以前のバージョンとの互換性を維持する必要がない限り、このプロパティは常に true に設定してください。将来のリリースでは、このプロパティのデフォルト値が true に変更される可能性があります。

デフォルト値: false。



実装
    public function get isPerUser():Boolean
    public function set isPerUser(value:Boolean):void

isSupported

プロパティ 
isSupported:Boolean  [読み取り専用]

言語バージョン: ActionScript 3.0
ランタイムバージョン: Flash Player 10.1, AIR 2

現在のプラットフォームで LocalConnection クラスがサポートされている場合、isSupported プロパティは true に設定されます。サポートされていない場合は、false に設定されます。



実装
    public static function get isSupported():Boolean
コンストラクターの詳細

LocalConnection

()コンストラクター
public function LocalConnection()

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9, Flash Lite 4

LocalConnection オブジェクトを作成します。LocalConnection オブジェクトを使用すると、同じクライアントコンピューター上で実行されている異なるファイル間で通信できるようになります。

関連する API エレメント

メソッドの詳細

allowDomain

()メソッド
public function allowDomain(... domains):void

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9, Flash Lite 4

この LocalConnection インスタンスに LocalConnection 呼び出しを送信できる 1 つ以上のドメインを指定します。

このメソッドを使用して、セキュアでないプロトコルでホストされているファイルから、セキュアなプロトコル(HTTPS)を使用してホストされているファイルへのアクセスを許可することはできません。この場合は、allowInsecureDomain() メソッドを使用してくだい。

場合によっては、このメソッドを使用して、ドメインの異なる子ファイルから親ファイルへの LocalConnection 呼び出しを、子ファイルの最終的なドメインが不明な状態でも実行できるようにしたいことがあります。 例えば、ロードバランシングリダイレクトやサードパーティー製サーバーを使用する場合などです。このような場合、ロードに使用される LoaderInfo オブジェクトの url プロパティを使用すれば、allowDomain() メソッドで使用するドメインを取得できます。例えば、Loader オブジェクトを使用して子ファイルをロードする場合は、ファイルがロードされた後、Loader オブジェクトの contentLoaderInfo.url プロパティをチェックすることにより、完全な URL ストリングから子 SWF ファイルのドメインを解析できます。この場合、ファイルがロードされるまで待つようにしてください。ファイルが完全にロードされるまで、contentLoaderInfo.url プロパティが最終的な正しい値に設定されないためです。

また、これとは反対に、ドメインの不明な親からの LocalConnection 呼び出しを子ファイルに受け入れさせたい場合もあります。この場合は、ドメインパラメーターが、ロードされたファイルの loaderInfo.url プロパティのドメインに一致するかどうかをチェックすることにより、このメソッドを実装できます。この場合も、loaderInfo.url に含まれている完全な URL からドメインを解析する必要があります。この状況では、親ファイルがロードされるまで待つ必要はありません。親 SWF ファイルは子 SWF ファイルがロードされた時点で既にロードされているからです。

このメソッドを使用するときは、Flash Player セキュリティモデルを考慮してください。デフォルトでは、LocalConnection オブジェクトはそれを作成したファイルのサンドボックスに関連付けられ、LocalConnection オブジェクトのクロスドメイン呼び出しは、受信側ファイルで LocalConnection.allowDomain() メソッドが呼び出されていない限り許可されません。ただし、Adobe AIR では、アプリケーションセキュリティサンドボックス内のコンテンツ(AIR アプリケーションと共にインストールされたコンテンツ)は、これらのセキュリティ制限による制限を受けません。

セキュリティについて詳しくは、Flash Player デベロッパーセンターのトピック:セキュリティを参照してください。

注意:allowDomain() メソッドは、ActionScript 1.0 および 2.0 での形式から変更されています。これらの以前のバージョンでは、allowDomain は実装するコールバックメソッドでした。ActionScript 3.0 では、allowDomain() は LocalConnection のビルトインメソッドとして呼び出されます。変更された allowDomain()flash.system.Security.allowDomain() とほぼ同じように作用します。

パラメーター

... domains — LocalConnection 呼び出しを許可するドメインを指定するストリングです。このパラメーターには次の 2 つの特殊なケースがあります。
  • ワイルドカード文字 "*" を使用して、すべてのドメインからの呼び出しを許可できます。
  • "localhost" というストリングを指定して、ローカル環境にインストールされているファイルからこのファイルへの呼び出しを許可することができます。Flash Player 8 から、ローカルファイルに関するセキュリティ制限が導入されました。デフォルトでは、Flash Player で実行されている、インターネットへのアクセスを許可された SWF ファイルは、ローカルファイルシステムにアクセスできません。 Flash Player では、"localhost" を指定すると、すべてのローカル SWF ファイルがこの SWF ファイルにアクセスできます。


例外
ArgumentError — 指定されたすべてのパラメーターは、null 以外にする必要があります。

関連する API エレメント

allowInsecureDomain

()メソッド 
public function allowInsecureDomain(... domains):void

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9, Flash Lite 4

この LocalConnection オブジェクトに LocalConnection 呼び出しを送信できる 1 つ以上のドメインを指定します。

allowInsecureDomain() メソッドは allowDomain() メソッドと同じように作用しますが、allowInsecureDomain() メソッドは、HTTPS 以外でロードされたファイルが HTTPS でロードされた SWF ファイルに LocalConnection 呼び出しを送信することも許可する点が異なります。この違いは、HTTPS を使用してロードされたファイルから allowInsecureDomain() メソッドを呼び出す場合にのみ意味があります。同じドメイン内の非 HTTPS と HTTPS の境界を越える場合でも、allowInsecureDomain() メソッドを呼び出す必要があります。デフォルトでは、同じドメイン内でも 非 HTTPS ファイルから HTTPS ファイルへの LocalConnection 呼び出しは許可されません。

allowInsecureDomain() を呼び出すことは、HTTPS によるセキュリティが損なわれる恐れがあるので、お勧めできません。HTTPS によってファイルをロードする場合は、ほぼ確実に、ファイルがネットワークでの配信中に不正操作を受けることはありません。 非 HTTPS ファイルから HTTPS ファイルへの LocalConnection 呼び出しを許可した場合、配信中に不正操作された可能性のあるファイルからの呼び出しを受け入れることになります。この場合は、HTTPS ファイルに送られてきた LocalConnection 呼び出しの正当性を信頼できないので、一般に特別な警戒を必要とします。

デフォルトでは、HTTPS プロトコルを使用してホストされたファイルは、HTTPS プロトコルを使用してホストされた他のファイルにのみアクセスできます。 この実装方法により、HTTPS プロトコルが提供する整合性が保たれます。

このメソッドでデフォルトの動作を変更することはお勧めできません。デフォルトの動作を変更すると、HTTPS のセキュリティが損なわれます。ただし、デフォルトの動作を変更せざるをえない場合もあります。例えば、Flash Player 9 以降用にパブリッシュされた HTTPS SWF ファイルに対して、Flash Player 6 以前のバージョン用にパブリッシュされた HTTP SWF ファイルからのアクセスを許可しなければならない場合などです。

セキュリティについて詳しくは、Flash Player デベロッパーセンターのトピック:セキュリティを参照してください。

パラメーター

... domains — LocalConnection 呼び出しを許可するドメインを指定するストリングです。このパラメーターには 2 つの特殊なケースがあります。
  • ワイルドカード文字 "*" を指定して、すべてのドメインからの呼び出しを許可できます。"*" を指定する場合、ローカルホストは含まれません。
  • "localhost" というストリングを指定して、ローカル環境にインストールされている SWF ファイルからこの SWF ファイルへの呼び出しを許可することができます。Flash Player 8 から、ローカル SWF ファイルに関するセキュリティ制限が導入されました。これにより、インターネットへのアクセスを許可された SWF ファイルは、ローカルファイルシステムにはアクセスできません。"localhost" を指定すると、どのローカル SWF ファイルもこの SWF ファイルにアクセスできます。オーサリング時に、呼び出し元の SWF ファイルを local-with-networking タイプの SWF ファイルとして指定する必要もあります。


例外
ArgumentError — 指定されたすべてのパラメーターは、null 以外にする必要があります。

関連する API エレメント

close

()メソッド 
public function close():void

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9, Flash Lite 4

LocalConnection オブジェクトを閉じます(切断します)。このコマンドは、LocalConnection オブジェクトがもうコマンドを受け入れないようにする場合に実行します。例えば、connect() コマンドを、別の SWF ファイルで同じ connectionName パラメーターを使用して実行する場合などです。


例外
ArgumentError — LocalConnection インスタンスが接続されていないので、閉じることができません。

関連する API エレメント

connect

()メソッド 
public function connect(connectionName:String):void

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9, Flash Lite 4

send() コマンド(送信側 LocalConnection オブジェクト)から送信されたコマンドを受け入れるように LocalConnection オブジェクトを準備します。 connect() メソッドで使用されるオブジェクトは、受信側 LocalConnection オブジェクトと呼ばれます。受信側と送信側のオブジェクトは、同じクライアントコンピューター上で実行されている必要があります。

競合状況を避けるため、このメソッドを呼び出す前に、受信側の LocalConnection オブジェクトに関連付けられるメソッドを定義します(LocalConnection クラスの例を参照)。

デフォルトでは、connectionName 引数は "superdomain:connectionName" の値に解決されます。ここで superdomain は、connect() コマンドを含むファイルのスーパードメインを表します。 例えば、受信側 LocalConnection オブジェクトを含むファイルが www.someDomain.com に配置されている場合、connectionName"someDomain.com:connectionName" に解決されます。(Flash Player で実行されているファイルがクライアントコンピューターに配置されている場合、superdomain には "localhost" が割り当てられます。)

Adobe AIR のアプリケーションセキュリティサンドボックスで実行されているコンテンツ(AIR アプリケーションと共にインストールされたコンテンツ)では、スーパードメインの代わりに、app# + AIR アプリケーションのアプリケーション ID(アプリケーション記述ファイルで定義)が使用されます。 例えば、アプリケーション ID が com.example.air.MyApp のアプリケーションでは、connectionName"app#com.example.air.MyApp:connectionName" に解決されます。

またデフォルトでは、受信側 LocalConnection オブジェクトは、接続名が "superdomain:connectionName" の値に解決される送信側 LocalConnection オブジェクトからのコマンドだけを受け入れます。このため、同じドメインに置かれているファイル間の通信は簡単です。

同じドメインのファイル間のみの通信を実装する場合は、先頭がアンダースコア(_)でなくドメイン名を含まないストリングを connectionName に指定します("myDomain:connectionName" など)。connect(connectionName) メソッドと同じストリングを使用してください。

異なるドメイン内のファイル間の通信を実装する場合は、アンダースコア(_)で始まるストリングを connectionName に指定すると、受信側 LocalConnection オブジェクトを含むファイルをドメイン間で移植しやすくなります。考えられる 2 つの状況を次に示します。

  • connectionName のストリングがアンダースコア(_)で始まっていない場合は、"myDomain:connectionName" のように、スーパードメインとコロンが前に追加されます。 これにより、他のドメインの同じ名前を持つ接続との競合は回避できますが、送信側 LocalConnection オブジェクトでも必ずこのスーパードメインを指定する必要があります("myDomain:connectionName" など)。受信側 LocalConnection オブジェクトを含むファイルが別のドメインに移動された場合は、"anotherDomain:connectionName" のように、新しいスーパードメインに応じて接頭辞が変更されます。すべての送信側 LocalConnection オブジェクトは、新しいスーパードメインを参照するように手動で編集する必要があります。
  • connectionName のストリングがアンダースコア(_)で始まっている場合("_connectionName" など)は、ストリングに接頭辞は追加されません。 つまり、受信側と送信側の LocalConnection オブジェクトは、connectionName にまったく同じストリングを使用します。受信側オブジェクトが allowDomain() を使用し、すべてのドメインからの通信を受け入れるように指定した場合は、送信側 LocalConnection オブジェクトを変更せずに、受信側 LocalConnection オブジェクトを含むファイルを別のドメインに移動させることができます。

詳細については、クラスの概要の説明、connectionNamesend())の説明、および allowDomain() エントリと domain エントリを参照してください。

注意:コロンは、connectionName のストリングとスーパードメインを区切る特殊文字として使用されます。connectionName にコロンを含むストリングを指定するのは無効です。

このメソッドを使用するときは、Flash Player セキュリティモデルを考慮してください。 デフォルトでは、LocalConnection オブジェクトはそれを作成したファイルのサンドボックスに関連付けられ、LocalConnection オブジェクトのクロスドメイン呼び出しは、受信側ファイルで LocalConnection.allowDomain() メソッドが呼び出されていない限り許可されません。ファイルがこのメソッドを使用しないようにするには、SWF コンテンツを含む HTML ページに allowNetworking パラメーター(object タグおよび embed タグ)を設定します。ただし、Adobe AIR では、application セキュリティサンドボックス内のコンテンツ(AIR アプリケーションと共にインストールされたコンテンツ)は、これらのセキュリティ制限による制限を受けません。

セキュリティについて詳しくは、Flash Player デベロッパーセンターのトピック:セキュリティを参照してください。

パラメーター

connectionName:String — 受信側 LocalConnection オブジェクトと通信する、send() コマンドで指定された接続名に対応するストリングです。


例外
TypeError connectionName パラメーターに渡される値は null 以外にする必要があります。
 
ArgumentError — このエラーは、次の 3 つの理由によって発生する可能性があります。1) connectionName パラメーターに渡されたストリング値が null だった場合。null 以外の値を渡します。2) connectionName パラメーターに渡された値にコロン(:)が含まれていた場合。コロンは、スーパードメインと connectionName ストリングを区切る特殊文字として send() メソッドで使用されます。connect() メソッドでは使用しません。3) LocalConnection インスタンスが既に接続されている場合。

関連する API エレメント

send

()メソッド 
public function send(connectionName:String, methodName:String, ... arguments):void

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9, Flash Lite 4

connect(connectionName) メソッド(受信側 LocalConnection オブジェクト)で確立した接続を使用して、methodName で指定されたメソッドを呼び出します。send() メソッドで使用されるオブジェクトは、送信側 LocalConnection オブジェクトと呼ばれます。送信側オブジェクトと受信側オブジェクトを含む SWF ファイルは、同じクライアントコンピューター上で実行されている必要があります。

このコマンドにパラメーターとして渡すことができるデータの量は 40 KB に制限されます。シンタックスが正しいにもかかわらず、send()ArgumentError をスローする場合は、send() 要求を複数のコマンドに分割してそれぞれのデータを 40 KB より小さくしてみてください。

connect() の項目で説明したように、connectionName にはデフォルトで現在のスーパードメインが追加されます。 異なるドメイン間の通信を実装する場合は、送信側と受信側の両方の LocalConnection オブジェクトの connectionName を、現在のスーパードメインが connectionName に追加されないように定義する必要があります。 これには、次の 2 つの方法があります。

  • 送信側と受信側の両方の LocalConnection オブジェクトで、connectionName の先頭にアンダースコア(_)を使用します。受信側オブジェクトを含むファイルでは、LocalConnection.allowDomain() を使用して、どのドメインからの接続も受け入れるように指定します。この方法では、送信側と受信側のファイルを任意のドメインに配置できます。
  • 送信側 LocalConnection オブジェクトの connectionName にスーパードメインを含めます。例えば、myDomain.com:myConnectionName と指定します。受信側オブジェクトでは、LocalConnection.allowDomain() を使用して、指定したスーパードメイン(この例では myDomain.com)からの接続を受け入れるか、またはすべてのドメインからの接続を受け入れるように指定します。

注意:受信側 LocalConnection オブジェクトの connectionName ではスーパードメインを指定できません。スーパードメインを指定できるのは送信側 LocalConnection オブジェクトだけです。

このメソッドを使用するときは、Flash Player セキュリティモデルを考慮してください。 デフォルトでは、LocalConnection オブジェクトはそれを作成したファイルのサンドボックスに関連付けられ、LocalConnection オブジェクトのクロスドメイン呼び出しは、受信側ファイルで LocalConnection.allowDomain() メソッドが呼び出されていない限り許可されません。ブラウザーで実行されている SWF コンテンツで、ファイルがこのメソッドを使用しないようにするには、SWF コンテンツを含む HTML ページに allowNetworking パラメーター(object タグおよび embed タグ)を設定します。 ただし、Adobe AIR では、アプリケーションセキュリティサンドボックス内のコンテンツ(AIR アプリケーションと共にインストールされたコンテンツ)は、これらのセキュリティ制限による制限を受けません。

セキュリティについて詳しくは、Flash Player デベロッパーセンターのトピック:セキュリティを参照してください。

パラメーター

connectionName:String — 送信側 LocalConnection オブジェクトと通信する、connect() コマンドで指定された接続名に対応します。
 
methodName:String — 受信側 LocalConnection オブジェクト内で呼び出されるメソッドの名前。次のメソッド名を使用すると、このコマンドは失敗します。sendconnectcloseallowDomainallowInsecureDomainclient、および domain
 
... arguments — 指定するメソッドに渡す追加のパラメーター。このパラメーターはオプションです。


イベント
securityError:SecurityErrorEventLocalConnection.send() は、呼び出し元のコードがアクセスできないセキュリティ Sandbox から SWF ファイルと通信しようとしました。この問題は、受信側が LocalConnection.allowDomain() を実装することで回避できます。
 
status:StatusEventLevel プロパティの値が "status" の場合は呼び出しが成功したことを示し、"error" の場合は呼び出しが失敗したことを示します。受信側の SWF ファイルが接続を拒否した場合、呼び出しは失敗する可能性があります。

例外
TypeError connectionName または methodName のいずれかの値が null です。これらのパラメーターに null 以外の値を渡します。
 
ArgumentError — このエラーは、次のうちいずれかの理由で発生する可能性があります。1) connectionName または methodName のいずれかの値が空ストリングである場合。これらのパラメーターに有効なストリングを渡します。2) methodName で指定されているメソッドが制限されている場合。3) 送信された直列化メッセージが大きすぎる場合(40 K 以上)。

関連する API エレメント

イベントの詳細

asyncError

イベント
イベントオブジェクトの型: flash.events.AsyncErrorEvent
プロパティ AsyncErrorEvent.type = flash.events.AsyncErrorEvent.ASYNC_ERROR

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9, Flash Lite 4

非同期形式で、つまりネイティブ非同期コードから例外がスローされると送出されます。

AsyncErrorEvent.ASYNC_ERROR 定数は、type プロパティ(asyncError イベントオブジェクト)の値を定義します。

このイベントには、次のプロパティがあります。

プロパティ
bubblesfalse
cancelablefalse は、キャンセルするデフォルトの動作がないことを示します。
currentTargetイベントリスナーで Event オブジェクトをアクティブに処理しているオブジェクトです。
targetイベントを送出するオブジェクトです。
errorイベントをトリガーしたエラーです。

securityError

イベント  
イベントオブジェクトの型: flash.events.SecurityErrorEvent
プロパティ SecurityErrorEvent.type = flash.events.SecurityErrorEvent.SECURITY_ERROR

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9, Flash Lite 4

LocalConnection.send() の呼び出しで、異なるセキュリティサンドボックスにデータを送信しようとすると送出されます。

SecurityErrorEvent.SECURITY_ERROR 定数は、type プロパティ(securityError イベントオブジェクト)の値を定義します。

このイベントには、次のプロパティがあります。

プロパティ
bubblesfalse
cancelablefalse は、キャンセルするデフォルトの動作がないことを示します。
currentTargetイベントリスナーで Event オブジェクトをアクティブに処理しているオブジェクトです。
targetセキュリティエラーを報告するネットワークオブジェクトです。
textエラーメッセージとして表示されるテキストです。

関連する API エレメント

status

イベント  
イベントオブジェクトの型: flash.events.StatusEvent
プロパティ StatusEvent.type = flash.events.StatusEvent.STATUS

言語バージョン: ActionScript 3.0
ランタイムバージョン: AIR 1.0, Flash Player 9, Flash Lite 4

LocalConnection オブジェクトがステータスを報告するときに送出されます。LocalConnection.send() が正常に実行された場合、status イベントオブジェクトの level プロパティの値は "status" になります。また、呼び出しに失敗した場合、level プロパティの値は "error" になります。受信側ファイルで接続が拒否されると、送信側ファイルへの通知なしで呼び出しが失敗する可能性があります。

type プロパティ(status イベントオブジェクト)の値を定義します。

このイベントには、次のプロパティがあります。

プロパティ
bubblesfalse
cancelablefalse は、キャンセルするデフォルトの動作がないことを示します。
codeオブジェクトのステータスの説明です。
currentTargetイベントリスナーで Event オブジェクトをアクティブに処理しているオブジェクトです。
level"status""warning""error" など、メッセージのカテゴリです。
targetそのステータスをレポートするオブジェクトです。

関連する API エレメント

LocalConnectionSenderExample.as

このサンプルは、2 つの異なる SWF ファイルにコンパイルする必要のある 2 つの ActionScript クラスから構成されています。

LocalConnectionSenderExample SWF ファイルでは LocalConnection インスタンスが作成され、ボタンが押されると call() メソッドを使用して SWF ファイル内の lcHandler というメソッドが呼び出されます。このとき接続名 "myConnection" が使用され、パラメーターとして TextField の内容が渡されます。

LocalConnectionReceiverExample SWF ファイルでは LocalConnection インスタンスが作成され、connect() メソッドが呼び出されて、この SWF ファイルが接続名 "myConnection" 宛のメッセージの受信者に指定されます。さらにこのクラスには、lcHandler() というパブリックメソッドが含まれています。これは、LocalConnectionSenderExample SWF ファイルによって呼び出されるメソッドです。メソッドが呼び出されると、パラメーターとして渡されるテキストがステージ上の TextField に追加されます。

注意:この例をテストするには、両方の SWF ファイルを同じコンピューター上に同時にロードする必要があります。

// Code in LocalConnectionSenderExample.as
package {
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.net.LocalConnection;
    import flash.text.TextField;
    import flash.text.TextFieldType;
    import flash.events.StatusEvent;
    import flash.text.TextFieldAutoSize;

    public class LocalConnectionSenderExample extends Sprite {
        private var conn:LocalConnection;
        
        // UI elements
        private var messageLabel:TextField;
        private var message:TextField;
        private var sendBtn:Sprite;
        
        public function LocalConnectionSenderExample() {
            buildUI();
            sendBtn.addEventListener(MouseEvent.CLICK, sendMessage);
            conn = new LocalConnection();
            conn.addEventListener(StatusEvent.STATUS, onStatus);
        }
        
        private function sendMessage(event:MouseEvent):void {
            conn.send("myConnection", "lcHandler", message.text);
        }
        
        private function onStatus(event:StatusEvent):void {
            switch (event.level) {
                case "status":
                    trace("LocalConnection.send() succeeded");
                    break;
                case "error":
                    trace("LocalConnection.send() failed");
                    break;
            }
        }
        
        private function buildUI():void {
            const hPadding:uint = 5;
            // messageLabel
            messageLabel = new TextField();
            messageLabel.x = 10;
            messageLabel.y = 10;
            messageLabel.text = "Text to send:";
            messageLabel.autoSize = TextFieldAutoSize.LEFT;
            addChild(messageLabel);
            
            // message
            message = new TextField();
            message.x = messageLabel.x + messageLabel.width + hPadding;
            message.y = 10;
            message.width = 120;
            message.height = 20;
            message.background = true;
            message.border = true;
            message.type = TextFieldType.INPUT;
            addChild(message);
            
            // sendBtn
            sendBtn = new Sprite();
            sendBtn.x = message.x + message.width + hPadding;
            sendBtn.y = 10;
            var sendLbl:TextField = new TextField();
            sendLbl.x = 1 + hPadding;
            sendLbl.y = 1;
            sendLbl.selectable = false;
            sendLbl.autoSize = TextFieldAutoSize.LEFT;
            sendLbl.text = "Send";
            sendBtn.addChild(sendLbl);
            sendBtn.graphics.lineStyle(1);
            sendBtn.graphics.beginFill(0xcccccc);
            sendBtn.graphics.drawRoundRect(0, 0, (sendLbl.width + 2 + hPadding + hPadding), (sendLbl.height + 2), 5, 5);
            sendBtn.graphics.endFill();
            addChild(sendBtn);
        }
    }
}
LocalConnectionReceiverExample.as

// Code in LocalConnectionReceiverExample.as
package {
    import flash.display.Sprite;
    import flash.net.LocalConnection;
    import flash.text.TextField;

    public class LocalConnectionReceiverExample extends Sprite {
        private var conn:LocalConnection;
        private var output:TextField;
        
        public function LocalConnectionReceiverExample()     {
            buildUI();
            
            conn = new LocalConnection();
            conn.client = this;
            try {
                conn.connect("myConnection");
            } catch (error:ArgumentError) {
                trace("Can't connect...the connection name is already being used by another SWF");
            }
        }
        
        public function lcHandler(msg:String):void {
            output.appendText(msg + "\n");
        }
        
        private function buildUI():void {
            output = new TextField();
            output.background = true;
            output.border = true;
            output.wordWrap = true;
            addChild(output);
        }
    }
}




[ X ]英語で表示される理由
ActionScript 3.0 リファレンスガイドのコンテンツが英語で表示されます。

ActionScript 3.0 リファレンスガイドのすべての部分がすべての言語に翻訳されているわけではありません。言語エレメントが翻訳されていない場合、そのエレメントは英語で表示されます。例えば、ga.controls.HelpBox クラスはどの言語にも訳されていません。このため、リファレンスガイドの日本語バージョンでは、ga.controls.HelpBox クラスは英語で表示されます。