Adobe® Flash® Platform용 ActionScript® 3.0 참조 설명서
 |  패키지 및 클래스 목록 숨기기 |  패키지  |  클래스  |  새로운 내용  |  색인  |  부록  |  영어로 표시되는 이유
필터: AIR 30.0 이하, Flash Player 30.0 이하, Flash Lite 4
Flex 4.6 이하, Flash Pro CS6 이하
필터 숨기기
flash.net 

FileReference  - 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 태그
사용되지 않는 요소의 목록
액세스 가능성 구현 상수
ActionScript 예제 사용 방법
법적 고지 사항
패키지flash.net
클래스public class FileReference
상속FileReference Inheritance EventDispatcher Inheritance Object
하위 클래스 File

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

FileReference 클래스는 사용자 컴퓨터와 서버 사이에서 파일을 업로드하거나 다운로드할 수 있는 방법을 제공합니다. 운영 체제의 대화 상자에는 업로드할 파일이나 다운로드 위치를 선택하라는 메시지가 표시됩니다. 각 FileReference 객체는 사용자 디스크의 단일 파일을 의미하며, 그 속성에는 파일 크기, 유형, 이름, 만든 날짜, 변경 날짜 및 작성자 유형(Macintosh에만 해당)에 대한 정보가 포함됩니다.

참고: Adobe AIR에서는 FileReference 클래스로 확장되는 File 클래스에서 더 많은 기능을 제공하며 이 클래스는 FileReference 클래스보다 보안 제한이 적습니다.

FileReference 인스턴스는 다음과 같은 방법으로 만들어집니다.

  • new 연산자를 FileReference 생성자와 함께 사용하는 방법: var myFileReference = new FileReference();
  • FileReference 객체 배열을 만드는 FileReferenceList.browse() 메서드를 호출하는 방법

업로드 작업 중 FileReference.browse() 또는 FileReferenceList.browse() 메서드를 호출하면 FileReference 객체의 모든 속성이 채워집니다. 다운로드 작업 중 select 이벤트가 전달되면 name 속성이 채워지고 다른 모든 속성은 complete 이벤트가 전달될 때 채워집니다.

browse() 메서드는 업로드할 파일을 선택하라는 메시지를 표시하는 운영 체제 대화 상자를 엽니다. FileReference.browse() 메서드를 사용하면 하나의 파일을, FileReferenceList.browse() 메서드를 사용하면 여러 파일을 선택할 수 있습니다. browse() 메서드 호출에 성공한 후 FileReference.upload() 메서드를 호출하여 한 번에 하나의 파일을 업로드합니다. FileReference.download() 메서드는 파일 저장 위치를 사용자에게 물어본 후 원격 URL에서 다운로드를 시작합니다.

FileReference 및 FileReferenceList 클래스를 사용하여 browse() 또는 download() 메서드가 생성하는 대화 상자의 기본 파일 위치를 설정할 수 없습니다. 대화 상자에 표시된 기본 위치는 가장 최근에 열어본 폴더이고(해당 위치를 확인할 수 있는 경우), 그렇지 않으면 데스크톱입니다. 이러한 클래스를 통해 전송된 파일을 읽거나 해당 파일에 쓸 수는 없습니다. 또한 이러한 클래스는 업로드되거나 다운로드된 파일 또는 사용자 디스크의 파일 위치에 액세스하기 위해 업로드 또는 다운로드를 시작하는 SWF 파일을 허용하지 않습니다.

FileReference 및 FileReferenceList 클래스는 인증 방법도 제공하지 않습니다. 인증을 필요로 하는 서버의 경우 Flash(r) Player 브라우저 플러그인을 사용하여 파일을 다운로드할 수 있지만, 모든 플레이어에서의 업로드 및 독립형 플레이어나 외부 플레이어에서의 다운로드는 실패합니다. FileReference 이벤트를 수신하여 작업이 성공적으로 완료되었는지 확인하고 오류를 처리합니다.

Flash Player에서 실행 중인 내용 또는 application 보안 샌드박스 외부의 Adobe AIR에서 실행 중인 내용의 경우 업로드 및 다운로드 작업은 자체 도메인 및 URL 정책 파일에 지정된 도메인 내에 있는 파일에만 액세스할 수 있습니다. 업로드 또는 다운로드를 시작하는 내용이 파일 서버와 같은 도메인에 속하지 않는 경우 파일 서버에 정책 파일을 배치해야 합니다.

새로운 기능이 Flash Player에 추가되어, Flash Player 10에 게시할 때 FileReference.browse(), FileReference.upload(), FileReference.download(), FileReference.load(), FileReference.save() 작업 중 한 번에 하나만 활성화할 수 있습니다. 그렇지 않으면 Flash Player에서 런타임 오류가 발생합니다(코드 2174). 진행 중인 작업을 중지하려면 FileReference.cancel()을 사용합니다. 이 제한은 Flash Player 10에만 적용되며, 이전 버전의 Flash Player에는 여러 개의 작업을 동시에 진행할 수 없는 제한이 적용되지 않습니다.

독립 실행형 및 외부 버전의 Flash Player와 Linux, Mac OS X 10.1 및 이전 버전용 AIR에서는 FileReference.browse(), FileReferenceList.browse() 또는 FileReference.download() 메서드를 호출하는 동안 SWF 파일 재생이 일시 정지됩니다.

지정된 매개 변수가 없는 경우, Flash Player에서 다음과 같은 HTTP POST 요청 샘플을 서버측 스크립트로 보냅니다.

  POST /handler.cfm HTTP/1.1 
  Accept: text/*
  Content-Type: multipart/form-data; 
  boundary=----------Ij5ae0ae0KM7GI3KM7 
  User-Agent: Shockwave Flash 
  Host: www.example.com 
  Content-Length: 421 
  Connection: Keep-Alive 
  Cache-Control: no-cache
  
  ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
  Content-Disposition: form-data; name="Filename"
  
  MyFile.jpg
  ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
  Content-Disposition: form-data; name="Filedata"; filename="MyFile.jpg"
  Content-Type: application/octet-stream
  
  FileDataHere
  ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
  Content-Disposition: form-data; name="Upload"
  
  Submit Query
  ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7--
  

사용자가 "api_sig", "api_key""auth_token" 매개 변수를 지정하는 경우, Flash Player에서 다음과 같은 HTTP POST요청을 보냅니다.

  POST /handler.cfm HTTP/1.1 
  Accept: text/*
  Content-Type: multipart/form-data; 
  boundary=----------Ij5ae0ae0KM7GI3KM7 
  User-Agent: Shockwave Flash 
  Host: www.example.com 
  Content-Length: 421 
  Connection: Keep-Alive 
  Cache-Control: no-cache
  
  ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
  Content-Disposition: form-data; name="Filename"
  
  MyFile.jpg
  ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
  Content-Disposition: form-data; name="api_sig"
  
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
  Content-Disposition: form-data; name="api_key"
  
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
  Content-Disposition: form-data; name="auth_token"
  
  XXXXXXXXXXXXXXXXXXXXXX
  ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
  Content-Disposition: form-data; name="Filedata"; filename="MyFile.jpg"
  Content-Type: application/octet-stream
  
  FileDataHere
  ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
  Content-Disposition: form-data; name="Upload"
  
  Submit Query
  ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7--
  

예제 보기

관련 API 요소



공용 속성
 속성정의 주체
 Inheritedconstructor : Object
지정된 객체 인스턴스의 클래스 객체 또는 생성자 함수에 대한 참조입니다.
Object
  creationDate : Date
[읽기 전용] 로컬 디스크의 파일을 만든 날짜입니다.
FileReference
  creator : String
[읽기 전용] Mac OS X 이전의 Mac OS 버전에서만 사용된 파일의 Macintosh 작성자 유형입니다.
FileReference
  data : ByteArray
[읽기 전용] load() 메서드를 성공적으로 호출한 후 로드된 파일의 데이터를 나타내는 ByteArray 객체입니다.
FileReference
      extension : String
[읽기 전용] 파일 이름 확장명입니다.
FileReference
  modificationDate : Date
[읽기 전용] 로컬 디스크 파일의 가장 최근 수정 날짜입니다.
FileReference
  name : String
[읽기 전용] 로컬 디스크에 있는 파일의 이름입니다.
FileReference
      permissionStatus : String
[정적] [읽기 전용] 응용 프로그램에 파일 시스템에 액세스할 수 있는 권한이 부여되었는지 여부를 확인합니다.
FileReference
  size : Number
[읽기 전용] 로컬 디스크에 있는 파일의 크기(바이트)입니다.
FileReference
  type : String
[읽기 전용] 파일 유형입니다.
FileReference
공용 메서드
 메서드정의 주체
  
새 FileReference 객체를 만듭니다.
FileReference
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
리스너에서 이벤트 알림을 받을 수 있도록 EventDispatcher 객체에 이벤트 리스너 객체를 등록합니다.
EventDispatcher
  
browse(typeFilter:Array = null):Boolean
업로드할 파일을 선택할 수 있는 파일 탐색 대화 상자를 표시합니다.
FileReference
  
이 FileReference 객체에서 진행 중인 업로드나 다운로드 작업을 취소합니다.
FileReference
 Inherited
이벤트를 이벤트 흐름으로 전달합니다.
EventDispatcher
  
download(request:URLRequest, defaultFileName:String = null):void
원격 서버에서 파일을 다운로드할 수 있는 대화 상자를 엽니다.
FileReference
 Inherited
EventDispatcher 객체에 특정 유형의 이벤트에 대한 리스너가 등록되어 있는지 여부를 확인합니다.
EventDispatcher
 Inherited
지정된 속성이 객체에 정의되어 있는지 여부를 나타냅니다.
Object
 Inherited
Object 클래스의 인스턴스가 매개 변수로 지정된 객체의 프로토타입 체인에 있는지 여부를 나타냅니다.
Object
  
사용자가 선택한 로컬 파일 로드를 시작합니다.
FileReference
 Inherited
지정된 속성이 존재하고 열거 가능한지 여부를 나타냅니다.
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
EventDispatcher 객체에서 리스너를 제거합니다.
EventDispatcher
  
파일 시스템에 액세스할 수 있는 권한을 요청합니다.
FileReference
  
save(data:*, defaultFileName:String = null):void
로컬 파일 시스템에 파일을 저장할 수 있는 대화 상자를 엽니다.
FileReference
 Inherited
루프 작업에서 동적 속성을 사용할 수 있는지 여부를 설정합니다.
Object
 Inherited
로캘별 규칙에 따라 서식이 지정된 이 객체의 문자열 표현을 반환합니다.
Object
 Inherited
지정된 객체의 문자열 표현을 반환합니다.
Object
  
upload(request:URLRequest, uploadDataFieldName:String = "Filedata", testUpload:Boolean = false):void
원격 서버에 파일 업로드를 시작합니다.
FileReference
  
인코딩 없이 URL로 파일 업로드를 시작합니다.
FileReference
 Inherited
지정된 객체의 프리미티브 값을 반환합니다.
Object
 Inherited
이 EventDispatcher 객체 또는 조상 객체에 지정한 이벤트 유형에 대한 이벤트 리스너가 등록되어 있는지 여부를 확인합니다.
EventDispatcher
이벤트
 이벤트 요약 정의 주체
 Inherited[브로드캐스트 이벤트] Flash Player 또는 AIR 응용 프로그램이 운영 체제 포커스를 얻어 활성화될 때 전달됩니다.EventDispatcher
  사용자가 파일 탐색 대화 상자에서 파일 업로드 또는 다운로드를 취소할 때 전달됩니다.FileReference
  다운로드가 완료되거나 업로드가 HTTP 상태 코드 200을 생성할 때 전달됩니다.FileReference
 Inherited[브로드캐스트 이벤트] Flash Player 또는 AIR 응용 프로그램이 운영 체제 포커스를 잃고 비활성화될 때 전달됩니다.EventDispatcher
  upload() 또는 uploadUnencoded() 메서드 호출로 HTTP를 통해 데이터 액세스를 시도하고 Adobe AIR에서 요청에 대한 상태 코드를 감지 및 반환할 수 있을 때 전달됩니다.FileReference
  업로드에 실패하고 HTTP 상태 코드를 사용하여 실패를 설명할 수 있을 때 전달됩니다.FileReference
  업로드 또는 다운로드가 실패할 때 전달됩니다.FileReference
  업로드 또는 다운로드 작업이 시작될 때 전달됩니다.FileReference
  응용 프로그램이 파일 시스템에 액세스할 수 있는 권한을 요청할 때 전달됩니다.FileReference
  파일 업로드 또는 다운로드 작업 중 주기적으로 전달됩니다.FileReference
  FileReference.upload() 또는 FileReference.download() 메서드 호출로 호출자의 보안 샌드박스 외부에 있는 서버에 파일을 업로드하거나 파일을 가져오려고 시도하면 전달됩니다.FileReference
  사용자가 파일 탐색 대화 상자에서 업로드 또는 다운로드할 파일을 선택할 때 전달됩니다.FileReference
  업로드에 성공한 후 서버에서 데이터가 수신되면 전달됩니다.FileReference
속성 세부 정보

creationDate

속성
creationDate:Date  [읽기 전용]

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

로컬 디스크의 파일을 만든 날짜입니다. 객체가 채워지지 않은 경우 이 속성의 값을 얻기 위한 호출은 null을 반환합니다.

참고: 운영 체제에 속성으로 creationDate가 없는 경우에는 CreationDatelastModifiedDate와 같습니다.



구현
    public function get creationDate():Date

오류
IllegalOperationError FileReference.browse(), FileReferenceList.browse() 또는 FileReference.download() 메서드에 대한 호출이 성공적이지 않은 경우에는 함수가 잘못된 순서로 호출되었거나 이전 호출이 실패했음을 알리는 메시지와 함께 예외가 발생합니다. 이 경우 creationDate 속성 값은 null입니다.
 
IOError — 파일 정보에 액세스할 수 없는 경우에는 파일 입출력 오류를 알리는 메시지와 함께 예외가 발생합니다.

관련 API 요소

creator

속성 
creator:String  [읽기 전용]

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

Mac OS X 이전의 Mac OS 버전에서만 사용된 파일의 Macintosh 작성자 유형입니다. Windows 또는 Linux의 경우 이 속성은 null입니다. FileReference 객체가 채워지지 않은 경우, 이 속성의 값을 얻기 위한 호출은 null을 반환합니다.



구현
    public function get creator():String

오류
IllegalOperationError — Macintosh에서 FileReference.browse(), FileReferenceList.browse() 또는 FileReference.download() 메서드에 대한 호출이 성공적이지 않은 경우에는 함수가 잘못된 순서로 호출되었거나 이전 호출이 실패했음을 알리는 메시지와 함께 예외가 발생합니다. 이 경우 creator 속성 값은 null입니다.

관련 API 요소

data

속성 
data:ByteArray  [읽기 전용]

언어 버전: ActionScript 3.0
런타임 버전: Flash Player 10, AIR 1.5

load() 메서드를 성공적으로 호출한 후 로드된 파일의 데이터를 나타내는 ByteArray 객체입니다.



구현
    public function get data():ByteArray

오류
IllegalOperationError load() 메서드에 대한 호출이 성공적이지 않은 경우에는 함수가 잘못된 순서로 호출되었거나 이전 호출이 실패했음을 알리는 메시지와 함께 예외가 발생합니다. 이 경우 data 속성 값은 null입니다.
 
IOError — 파일을 열 수 없거나 읽을 수 없는 경우 또는 파일 액세스 시 유사한 오류가 발생하는 경우, 파일 입출력 오류를 알리는 메시지와 함께 예외가 발생합니다. 이 경우 data 속성 값은 null입니다.

관련 API 요소

    

extension

속성 
extension:String  [읽기 전용]

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0

파일 이름 확장명입니다.

파일의 확장명은 마지막 도트(".") 다음에 오는 이름 부분입니다. 파일 이름에 도트가 없으면 확장명은 null입니다.

참고: extension 속성을 사용하여 파일 유형을 결정해야 합니다. creator 또는 type 속성을 사용하지 마십시오. creatortype 속성은 앞으로 사용하지 않는 것이 좋습니다. 이러한 속성은 이전 버전의 Mac OS에 적용됩니다.



구현
    public function get extension():String

오류
IllegalOperationError — 참조가 초기화되지 않은 경우

modificationDate

속성 
modificationDate:Date  [읽기 전용]

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9, Flash Player 9

로컬 디스크 파일의 가장 최근 수정 날짜입니다. FileReference 객체가 채워지지 않은 경우, 이 속성의 값을 얻기 위한 호출은 null을 반환합니다.



구현
    public function get modificationDate():Date

오류
IllegalOperationError FileReference.browse(), FileReferenceList.browse() 또는 FileReference.download() 메서드에 대한 호출이 성공적이지 않은 경우에는 함수가 잘못된 순서로 호출되었거나 이전 호출이 실패했음을 알리는 메시지와 함께 예외가 발생합니다. 이 경우 modificationDate 속성 값은 null입니다.
 
IOError — 파일 정보에 액세스할 수 없는 경우에는 파일 입출력 오류를 알리는 메시지와 함께 예외가 발생합니다.

관련 API 요소

name

속성 
name:String  [읽기 전용]

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

로컬 디스크에 있는 파일의 이름입니다. FileReference.download() 또는 FileReference.browse()를 올바르게 호출하여 FileReference 객체가 채워지지 않은 경우 이 속성의 값을 가져오려고 하면 Flash Player에서 오류가 발생합니다.

browse() 메서드를 호출하면 FileReference 객체의 모든 속성이 채워집니다. 다른 FileReference 속성과 달리 download() 메서드를 호출하면 select 이벤트를 전달할 때 name 속성이 채워집니다.



구현
    public function get name():String

오류
IllegalOperationError FileReference.browse(), FileReferenceList.browse() 또는 FileReference.download() 메서드에 대한 호출이 성공적이지 않은 경우에는 함수가 잘못된 순서로 호출되었거나 이전 호출이 실패했음을 알리는 메시지와 함께 예외가 발생합니다.

관련 API 요소

    

permissionStatus

속성 
permissionStatus:String  [읽기 전용]

언어 버전: ActionScript 3.0
런타임 버전: AIR 24.0

응용 프로그램에 파일 시스템에 액세스할 수 있는 권한이 부여되었는지 여부를 확인합니다.



구현
    public static function get permissionStatus():String

관련 API 요소

size

속성 
size:Number  [읽기 전용]

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

로컬 디스크에 있는 파일의 크기(바이트)입니다.

참고: ActionScript 3.0 초기 버전의 경우 size 속성은 최대 4GB 크기의 파일을 지원하는 uint 객체로 정의되었습니다. 지금은 더 큰 파일을 지원하는 Number 객체로 구현되었습니다.



구현
    public function get size():Number

오류
IllegalOperationError FileReference.browse(), FileReferenceList.browse() 또는 FileReference.download() 메서드에 대한 호출이 성공적이지 않은 경우에는 함수가 잘못된 순서로 호출되었거나 이전 호출이 실패했음을 알리는 메시지와 함께 예외가 발생합니다.
 
IOError — 파일을 열 수 없거나 읽을 수 없는 경우 또는 파일 액세스 시 유사한 오류가 발생하는 경우, 파일 입출력 오류를 알리는 메시지와 함께 예외가 발생합니다.

관련 API 요소

type

속성 
type:String  [읽기 전용]

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

파일 유형입니다.

Windows 또는 Linux의 경우 이 속성은 파일 확장명입니다. Macintosh의 경우 이 속성은 Mac OS X 이전의 Mac OS 버전에서만 사용된 4개의 문자로 이루어진 파일 유형입니다. FileReference 객체가 채워지지 않은 경우 이 속성의 값을 가져오기 위한 호출은 null을 반환합니다.

Windows, Linux 및 Mac OS X의 경우 마지막 도트(.) 문자 다음에 오는 name 속성 부분인 파일 확장명은 파일 유형을 식별합니다.



구현
    public function get type():String

오류
IllegalOperationError FileReference.browse(), FileReferenceList.browse() 또는 FileReference.download() 메서드에 대한 호출이 성공적이지 않은 경우에는 함수가 잘못된 순서로 호출되었거나 이전 호출이 실패했음을 알리는 메시지와 함께 예외가 발생합니다. 이 경우 type 속성 값은 null입니다.

관련 API 요소

생성자 세부 정보

FileReference

()생성자
public function FileReference()

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

새 FileReference 객체를 만듭니다. 채워지면 FileReference 객체는 사용자의 로컬 디스크 파일을 나타냅니다.

관련 API 요소

메서드 세부 정보

browse

()메서드
public function browse(typeFilter:Array = null):Boolean

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

업로드할 파일을 선택할 수 있는 파일 탐색 대화 상자를 표시합니다. 대화 상자는 사용자 운영 체제에 따라 다릅니다. 사용자는 로컬 컴퓨터의 파일이나 Windows의 UNC 경로를 통해 다른 시스템의 파일을 선택할 수 있습니다.

참고: Adobe AIR에서 사용 가능한 File 클래스에는 시스템 파일을 좀더 세부적으로 선택할 수 있는 대화 상자에 액세스하는 데 사용되는 메서드가 포함되어 있습니다. 이러한 메서드에는 File.browseForDirectory(), File.browseForOpen(), File.browseForOpenMultiple()File.browseForSave()가 있습니다.

이 메서드를 호출하여 파일 선택에 성공하면 FileReference 객체 속성은 선택된 파일의 속성으로 채워집니다. 다음에 FileReference.browse() 메서드를 호출할 때마다 FileReference 객체의 속성은 대화 상자에서 사용자가 선택한 파일로 다시 설정됩니다. 한 번에 하나의 대화 상자만 호출할 수 있으므로 browse() 또는 download() 세션은 한 번에 하나만 수행할 수 있습니다.

typeFilter 매개 변수를 사용하여 대화 상자에 표시할 파일을 결정할 수 있습니다.

Flash Player 10 및 Flash Player 9 업데이트 5에서는 마우스 클릭이나 키 누르기 이벤트에 대한 이벤트 핸들러 등 사용자 이벤트에 대한 응답으로만 이 메서드를 호출할 수 있습니다. 그렇지 않은 경우 이 메서드를 호출하면 Flash Player에서 오류 예외가 발생합니다.

새로운 기능이 Flash Player에 추가되어, Flash Player 10에 게시할 때 FileReference.browse(), FileReference.upload(), FileReference.download(), FileReference.load(), FileReference.save() 작업 중 한 번에 하나만 활성화할 수 있습니다. 그렇지 않으면 Flash Player에서 런타임 오류가 발생합니다(코드 2174). 진행 중인 작업을 중지하려면 FileReference.cancel()을 사용합니다. 이 제한은 Flash Player 10에만 적용되며, 이전 버전의 Flash Player에는 여러 개의 작업을 동시에 진행할 수 없는 제한이 적용되지 않습니다.

Adobe AIR에서는 [파일 탐색] 대화 상자가 항상 다른 윈도우가 "소유한" 윈도우(owner 속성 값이 null이 아닌 윈도우) 앞에 표시되는 것은 아닙니다. 윈도우 순서 문제를 피하려면 이 메서드를 호출하기 전에 소속된 윈도우를 숨기십시오.

매개 변수

typeFilter:Array (default = null) — 대화 상자에 표시되는 파일을 필터링하는 데 사용되는 FileFilter 인스턴스 배열입니다. 이 매개 변수를 생략하면 모든 파일이 표시됩니다. 자세한 내용은 FileFilter 클래스를 참조하십시오.

반환값
Boolean — 매개 변수가 유효하고 파일 탐색 대화 상자가 열리면 true를 반환합니다.

이벤트
select:Event — 사용자가 파일 탐색 선택기에서 항목을 성공적으로 선택할 때 전달됩니다.
 
cancel:Event — 사용자가 파일 업로드 탐색 윈도우를 취소할 때 전달됩니다.

오류
IllegalOperationError — 발생 상황: 1) 다른 FileReference 또는 FileReferenceList 탐색 세션이 진행 중일 경우. 파일 탐색 세션은 한 번에 하나만 수행할 수 있습니다. 2) 사용자의 mms.cfg 파일 설정이 이 작업을 금지한 경우.
 
ArgumentError typeFilter 배열에 잘못된 형식의 FileFilter 객체가 포함되어 있는 경우 예외가 발생합니다. FileFilter 객체의 올바른 형식에 대한 자세한 내용은 FileFilter 클래스를 참조하십시오.
 
Error — 메서드가 마우스 클릭이나 키 누르기 이벤트와 같은 사용자 액션에 대한 응답으로 호출되지 않는 경우.

관련 API 요소

select 이벤트
cancel 이벤트
FileReference.download()
FileReferenceList.browse()
File.browseForDirectory()
File.browseForOpen()
File.browseForOpenMultiple()
File.browseForSave()

cancel

()메서드 
public function cancel():void

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

이 FileReference 객체에서 진행 중인 업로드나 다운로드 작업을 취소합니다. 이 메서드를 호출할 때 cancel 이벤트는 전달되지 않습니다. 이 이벤트는 사용자가 파일 업로드 또는 다운로드 대화 상자를 닫아 해당 작업을 취소하는 경우에만 전달됩니다.

download

()메서드 
public function download(request:URLRequest, defaultFileName:String = null):void

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

원격 서버에서 파일을 다운로드할 수 있는 대화 상자를 엽니다. Flash Player에서는 업로드 또는 다운로드할 수 있는 파일의 크기를 제한하지 않지만, 공식적으로 이 플레이어는 100MB 이하의 업로드 또는 다운로드를 지원합니다.

download() 메서드는 먼저 운영 체제 대화 상자를 열어 파일 이름을 입력하고 파일을 저장할 로컬 컴퓨터 위치를 선택하도록 사용자에게 요청합니다. 사용자가 위치를 선택하고 다운로드 작업을 확인하면(예: [저장]을 클릭) 원격 서버에서 다운로드를 시작합니다. 리스너는 다운로드의 진행, 성공 또는 실패를 나타내는 이벤트를 수신합니다. 대화 상자의 상태와 download() 호출 후의 다운로드 작업을 확인하려면 코드가 cancel, open, progresscomplete 등의 이벤트를 수신해야 합니다.

FileReference.upload()FileReference.download() 함수는 비차단 방식입니다. 이들 함수는 호출 후 파일 전송이 완료되기 전에 반환됩니다. 또한 만일 FileReference 객체가 범위를 벗어나는 경우, 아직 완료되지 않은 해당 객체의 업로드 또는 다운로드는 범위를 벗어나는 즉시 취소됩니다. 업로드 또는 다운로드를 계속해야 한다면 FileReference 객체가 범위 내에 있도록 주의해야 합니다.

파일이 성공적으로 다운로드되면 FileReference 객체의 속성이 로컬 파일의 속성으로 채워집니다. 다운로드에 성공하면 complete 이벤트가 전달됩니다.

한 번에 하나의 대화 상자만 호출할 수 있으므로 browse() 또는 download() 세션은 한 번에 하나만 수행할 수 있습니다.

이 메서드는 HTTP 또는 HTTPS의 모든 파일 유형에 대한 다운로드를 지원합니다.

일반적으로 예약된 포트에 연결할 수 없습니다. 차단된 포트의 전체 목록은 ActionScript 3.0 개발자 안내서의 "제한적 네트워킹 API"를 참조하십시오.

참고: 서버에 사용자 인증이 필요한 경우 브라우저에서 실행 중인, 즉 브라우저 플러그인이나 ActiveX 컨트롤을 사용하는 SWF 파일만이 인증 및 다운로드에 필요한 사용자 이름과 암호를 요청하는 대화 상자를 제공할 수 있습니다. 플러그인이나 ActiveX 컨트롤을 사용하는 업로드 또는 독립형이나 외부 플레이어를 사용하는 업로드 또는 다운로드의 경우에는 파일 전송에 실패합니다.

이 메서드를 사용할 때는 다음과 같은 Flash Player 보안 모델을 고려해야 합니다.

  • 호출하는 SWF 파일이 신뢰할 수 없는 로컬 샌드박스에 있는 경우에는 로딩 작업이 허용되지 않습니다.
  • 기본 비헤이비어는 샌드박스 간의 액세스를 거부하는 것입니다. URL 정책 파일을 추가하여 웹 사이트에서 리소스에 액세스를 허용할 수 있습니다.
  • SWF 내용이 들어 있는 HTML 페이지에서 allowNetworking 매개 변수(objectembed 태그)를 설정하여 SWF 파일에서 이 메서드를 사용하지 않게 할 수 있습니다.
  • Flash Player 10 및 Flash Player 9 업데이트 5에서는 마우스 클릭이나 키 누르기 이벤트에 대한 이벤트 핸들러 등 사용자 이벤트에 대한 응답으로만 이 메서드를 호출할 수 있습니다. 그렇지 않은 경우 이 메서드를 호출하면 Flash Player에서 오류 예외가 발생합니다.

그러나 Adobe AIR에서 application 보안 샌드박스의 내용(AIR 응용 프로그램과 함께 설치된 내용)에는 이러한 보안 제한 사항이 적용되지 않습니다.

보안에 대한 자세한 내용은 Flash Player 개발자 센터 항목: 보안을 참조하십시오.

이 메서드를 사용하여 파일을 다운로드하는 경우 다음과 같은 운영 체제에서는 다운로드한 파일에 "다운로드됨"으로 플래그를 설정합니다.

  • Windows XP 서비스 팩 2 이상, Windows Vista
  • Mac OS 10.5 이상

Linux와 같은 일부 운영 체제는 다운로드한 파일에 플래그를 설정하지 않습니다.

새로운 기능이 Flash Player에 추가되어, Flash Player 10에 게시할 때 FileReference.browse(), FileReference.upload(), FileReference.download(), FileReference.load(), FileReference.save() 작업 중 한 번에 하나만 활성화할 수 있습니다. 그렇지 않으면 Flash Player에서 런타임 오류가 발생합니다(코드 2174). 진행 중인 작업을 중지하려면 FileReference.cancel()을 사용합니다. 이 제한은 Flash Player 10에만 적용되며, 이전 버전의 Flash Player에는 여러 개의 작업을 동시에 진행할 수 없는 제한이 적용되지 않습니다.

Adobe AIR에서는 [다운로드] 대화 상자가 항상 다른 윈도우가 "소유한" 윈도우(owner 속성 값이 null이 아닌 윈도우) 앞에 표시되는 것은 아닙니다. 윈도우 순서 문제를 피하려면 이 메서드를 호출하기 전에 소속된 윈도우를 숨기십시오.

매개 변수

request:URLRequest — URLRequest 객체입니다. URLRequest 객체의 url 속성에는 로컬 컴퓨터로 다운로드할 파일의 URL이 포함되어야 합니다. 이 매개 변수가 null인 경우 예외가 발생합니다. URLRequest 객체의 requestHeaders 속성은 무시됩니다. 사용자 정의 HTTP 요청은 업로드 또는 다운로드에서 지원되지 않습니다. POST 또는 GET 매개 변수를 서버로 보내려면 URLRequest.data 값을 해당 매개 변수로, URLRequest.methodURLRequestMethod.POST 또는 URLRequestMethod.GET으로 설정합니다.

일부 브라우저에서는 URL 문자열의 길이가 제한됩니다. 길이가 256 문자보다 긴 경우 일부 브라우저나 서버에서는 실패할 수 있습니다.

 
defaultFileName:String (default = null) — 대화 상자에 표시되는 다운로드할 파일의 기본 파일 이름입니다. 이 문자열은 다음 문자를 포함할 수 없습니다. / \ : * ? " < > | %

이 매개 변수를 생략하면 원격 URL의 파일 이름을 구문 분석하여 이를 기본값으로 사용합니다.


이벤트
open:Event — 다운로드 작업이 시작될 때 전달됩니다.
 
progress:ProgressEvent — 파일 다운로드 작업 중 주기적으로 전달됩니다.
 
complete:Event — 파일 다운로드 작업이 성공적으로 완료되었을 때 전달됩니다.
 
cancel:Event — 사용자가 대화 상자를 닫을 때 전달됩니다.
 
select:Event — 사용자가 대화 상자에서 다운로드할 파일을 선택할 때 전달됩니다.
 
securityError:SecurityErrorEvent — 보안 오류로 인해 다운로드에 실패할 때 전달됩니다.
 
ioError:IOErrorEvent — 다음과 같은 이유로 전달됩니다.
  • 파일을 읽거나 전송하는 동안 입력/출력 오류가 발생하는 경우
  • Flash Player의 독립 실행형 또는 외부 버전에서 실행 중인 SWF 내용이 인증이 요구되는 서버로부터 파일 다운로드를 시도합니다. 다운로드 시 독립형 플레이어 및 외부 플레이어는 암호 입력 방법을 제공하지 않습니다. 이러한 플레이어에서 SWF 파일이 인증이 필요한 서버로부터 파일 다운로드를 시도하면 다운로드는 실패하게 됩니다. 파일은 ActiveX 컨트롤이나 브라우저 플러그인 플레이어를 사용하여 다운로드해야 합니다.

오류
IllegalOperationError — 발생 상황: 1) 다른 탐색 세션이 진행 중일 경우. 파일 탐색 세션은 한 번에 하나만 수행할 수 있습니다. 2) request에 전달된 값이 유효한 경로 또는 프로토콜을 포함하지 않는 경우. 3) 다운로드할 파일 이름에 금지된 문자가 포함되어 있는 경우. 4) 사용자의 mms.cfg 파일 설정이 이 작업을 금지한 경우.
 
SecurityError — 신뢰할 수 없는 로컬 내용은 인터넷 통신이 불가능합니다. 이 SWF 파일을 네트워킹 가능한 로컬 파일(local-with-networking) 또는 신뢰할 수 있는 파일로 다시 규정하면 이 문제를 해결할 수 있습니다. 이 예외가 발생할 때는 로컬 파일 보안 제한으로 인해 액세스할 수 없는 파일 이름 및 URL을 알리는 메시지가 함께 표시됩니다.
 
SecurityError — 일반적으로 예약된 포트에 연결할 수 없습니다. 차단된 포트의 전체 목록은 ActionScript 3.0 개발자 안내서의 "제한적 네트워킹 API"를 참조하십시오.
 
ArgumentError url.data가 ByteArray 유형인 경우 예외가 발생합니다. FileReference.upload()FileReference.download() 메서드와 함께 사용하려면 url.data가 URLVariables 또는 String 유형이어야 합니다.
 
MemoryError — 이 오류는 다음과 같은 이유로 발생할 수 있습니다. 1) Flash Player에서 URLRequest.data 매개 변수를 UTF8에서 MBCS로 변환할 수 없습니다. FileReference.download() 메서드에 전달된 URLRequest 객체가 GET 작업을 수행하도록 설정되고 System.useCodePagetrue로 설정된 경우 이 오류가 발생합니다. 2) Flash Player에서 POST 데이터를 위한 메모리를 할당할 수 없습니다. FileReference.download() 메서드에 전달된 URLRequest 객체가 POST 작업을 수행하도록 설정된 경우 이 오류가 발생합니다.
 
Error — 메서드가 마우스 클릭이나 키 누르기 이벤트와 같은 사용자 액션에 대한 응답으로 호출되지 않는 경우.

관련 API 요소


예제  ( 예제 사용 방법 )

다음 예제에서는 download 이벤트 객체의 사용법을 보여 줍니다. 이 예제를 실행하려면 가상의 http://www.[yourDomain].com/SomeFile.pdf가 아닌 실제의 도메인과 파일을 가리키도록 downloadURL.url 속성을 변경합니다. 로컬 재생 보안을 네트워크만 액세스로 설정하여 SWF 파일을 컴파일해야 할 수도 있습니다. 또는 Flash Player 보안 설정을 업데이트하여 이 파일의 네트워크 액세스를 허용합니다.
package {
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.FileReference;
    import flash.net.URLRequest;
    import flash.net.FileFilter;

    public class FileReference_download extends Sprite {
        private var downloadURL:URLRequest;
        private var fileName:String = "SomeFile.pdf";
        private var file:FileReference;

        public function FileReference_download() {
            downloadURL = new URLRequest();
            downloadURL.url = "http://www.[yourDomain].com/SomeFile.pdf";
            file = new FileReference();
            configureListeners(file);
            file.download(downloadURL, fileName);
        }

        private function configureListeners(dispatcher:IEventDispatcher):void {
            dispatcher.addEventListener(Event.CANCEL, cancelHandler);
            dispatcher.addEventListener(Event.COMPLETE, completeHandler);
            dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
            dispatcher.addEventListener(Event.OPEN, openHandler);
            dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
            dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
            dispatcher.addEventListener(Event.SELECT, selectHandler);
        }

        private function cancelHandler(event:Event):void {
            trace("cancelHandler: " + event);
        }

        private function completeHandler(event:Event):void {
            trace("completeHandler: " + event);
        }

        private function ioErrorHandler(event:IOErrorEvent):void {
            trace("ioErrorHandler: " + event);
        }

        private function openHandler(event:Event):void {
            trace("openHandler: " + event);
        }

        private function progressHandler(event:ProgressEvent):void {
            var file:FileReference = FileReference(event.target);
            trace("progressHandler name=" + file.name + " bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
        }

        private function securityErrorHandler(event:SecurityErrorEvent):void {
            trace("securityErrorHandler: " + event);
        }

        private function selectHandler(event:Event):void {
            var file:FileReference = FileReference(event.target);
            trace("selectHandler: name=" + file.name + " URL=" + downloadURL.url);
        }
    }
}

load

()메서드 
public function load():void

언어 버전: ActionScript 3.0
런타임 버전: Flash Player 10, AIR 1.5

사용자가 선택한 로컬 파일 로드를 시작합니다. Flash Player에서는 업로드, 다운로드, 로드 또는 저장할 수 있는 파일의 크기를 제한하지 않지만 공식적으로는 최대 100MB 크기를 지원합니다. Flash Player에서 내용을 실행하려면 FileReference.browse() 또는 FileReferenceList.browse() 메서드를 호출한 다음 load() 메서드를 호출해야 합니다. 그러나 응용 프로그램 샌드박스의 AIR에서 실행 중인 내용은 browse() 메서드를 먼저 호출하지 않고도 File 객체의 load() 메서드를 호출할 수 있습니다. AIR File 클래스는 FileReference 클래스를 확장합니다.

리스너는 로드의 진행, 성공 또는 실패를 나타내는 이벤트를 수신합니다. FileReferenceList 객체를 사용하여 로드할 파일을 여러 개 선택하도록 할 수 있지만 파일을 한 번에 하나씩 로드해야 합니다. 파일을 하나씩 로드하려면 FileReference 객체의 FileReferenceList.fileList 배열을 반복합니다.

Adobe AIR는 파일 읽기에 더 많은 옵션을 제공하는 FileStream 클래스도 포함합니다.

FileReference.upload(), FileReference.download(), FileReference.load()FileReference.save() 함수는 비차단 방식입니다. 이들 함수는 호출 후 파일 전송이 완료되기 전에 반환됩니다. 또한 FileReference 객체가 범위를 벗어나는 경우 아직 완료되지 않은 해당 객체의 모든 트랜잭션은 범위를 벗어나는 즉시 취소됩니다. 업로드, 다운로드, 로드 또는 저장을 계속해야 한다면 FileReference 객체가 범위 내에 있도록 주의해야 합니다.

파일이 성공적으로 로드되면 해당 내용이 FileReference 객체의 data 속성에 바이트 배열로 저장됩니다.

다음과 같은 보안 사항이 적용됩니다.

  • 호출하는 SWF 파일이 신뢰할 수 없는 로컬 샌드박스에 있는 경우에는 로딩 작업이 허용되지 않습니다.
  • 기본 비헤이비어는 샌드박스 간의 액세스를 거부하는 것입니다. 크로스 도메인 정책 파일을 추가하여 웹 사이트에서 리소스에 액세스하도록 할 수 있습니다.
  • SWF 내용이 들어 있는 HTML 페이지에서 allowNetworking 매개 변수(objectembed 태그)를 설정하여 SWF 파일에서 이 메서드를 사용하지 않게 할 수 있습니다.

그러나 응용 프로그램 샌드박스의 AIR 내용에는 이러한 사항이 적용되지 않습니다.

Flash Player 10 또는 AIR 1.5로 제작할 때 FileReference.browse(), FileReference.upload(), FileReference.download(), FileReference.load(), FileReference.save() 작업 중 한 번에 하나만 활성화할 수 있습니다. 그렇지 않으면 응용 프로그램에서 런타임 오류가 발생합니다(코드 2174). 진행 중인 작업을 중지하려면 FileReference.cancel()을 사용합니다. 이 제한은 Flash Player 10 및 AIR 1.5에만 적용되며, 이전 버전의 Flash Player 또는 AIR에는 여러 개의 작업을 동시에 진행할 수 없는 제한이 적용되지 않습니다.

Adobe AIR에서는 [파일 탐색] 대화 상자가 항상 다른 윈도우가 "소유한" 윈도우(owner 속성 값이 null이 아닌 윈도우) 앞에 표시되는 것은 아닙니다. 윈도우 순서 문제를 피하려면 이 메서드를 호출하기 전에 소속된 윈도우를 숨기십시오.


이벤트
open:Event — 로드 작업이 시작될 때 전달됩니다.
 
progress:ProgressEvent — 파일 로드 작업 중 주기적으로 전달됩니다.
 
complete:Event — 파일 로드 작업이 성공적으로 완료되었을 때 전달됩니다.
 
ioError:IOErrorEvent — 응용 프로그램에서 파일을 읽거나 쓰는 중 입력/출력 오류로 인해 로드에 실패하면 호출됩니다.

오류
IllegalOperationError — 발생 상황: 1) 다른 FileReference 또는 FileReferenceList 탐색 세션이 진행 중일 경우. 파일 탐색 세션은 한 번에 하나만 수행할 수 있습니다. 2) 사용자의 mms.cfg 파일 설정이 이 작업을 금지한 경우.
 
MemoryError — 이 오류는 응용 프로그램이 파일을 위한 메모리를 할당할 수 없는 경우 발생할 수 있습니다. 파일이 너무 크거나 사용 가능한 메모리가 너무 적을 수 있습니다.

관련 API 요소


예제  ( 예제 사용 방법 )

다음 예제에서는 로컬 파일 시스템의 이미지를 루트 표시 객체(이 경우 스테이지)에 업로드합니다. 이 예제는 Andre Venancio가 제공합니다.
var buttonShape:Shape = new Shape();
buttonShape.graphics.beginFill(0x336699);
buttonShape.graphics.drawCircle(50, 50, 25);
var button = new SimpleButton(buttonShape, buttonShape, buttonShape, buttonShape);
addChild(button);

var fileRef:FileReference= new FileReference();
button.addEventListener(MouseEvent.CLICK, onButtonClick);

function onButtonClick(e:MouseEvent):void {
fileRef.browse([new FileFilter("Images", "*.jpg;*.gif;*.png")]);
fileRef.addEventListener(Event.SELECT, onFileSelected);
}

function onFileSelected(e:Event):void {
fileRef.addEventListener(Event.COMPLETE, onFileLoaded);
fileRef.load();
}

function onFileLoaded(e:Event):void {
var loader:Loader = new Loader();
loader.loadBytes(e.target.data);
addChild(loader);
}

    requestPermission

()메서드 
public function requestPermission():void

언어 버전: ActionScript 3.0
런타임 버전: AIR 24.0

파일 시스템에 액세스할 수 있는 권한을 요청합니다.


이벤트
PermissionStatus:PermissionEvent — 사용자가 요청된 권한을 부여/거부할 때 전달됩니다.

save

()메서드 
public function save(data:*, defaultFileName:String = null):void

언어 버전: ActionScript 3.0
런타임 버전: Flash Player 10, AIR 1.5

로컬 파일 시스템에 파일을 저장할 수 있는 대화 상자를 엽니다. Flash Player에서는 업로드, 다운로드, 로드 또는 저장할 수 있는 파일의 크기를 제한하지 않지만 공식적으로는 최대 100MB 크기를 지원합니다.

save() 메서드는 먼저 운영 체제 대화 상자를 열어 파일 이름을 입력하고 파일을 저장할 로컬 컴퓨터 위치를 선택하도록 사용자에게 요청합니다. 사용자가 위치를 선택하고 저장 작업을 확인하면(예: [저장]을 클릭) 저장 프로세스가 시작됩니다. 리스너는 저장 작업의 진행, 성공 또는 실패를 나타내는 이벤트를 수신합니다. 대화 상자의 상태와 save() 호출 후의 저장 작업을 확인하려면 코드가 cancel, open, progresscomplete 등의 이벤트를 수신해야 합니다.

Adobe AIR에는 파일을 로컬에 저장하는 데 더 많은 옵션을 제공하는 FileStream 클래스도 포함되어 있습니다.

FileReference.upload(), FileReference.download(), FileReference.load()FileReference.save() 함수는 비차단 방식입니다. 이들 함수는 호출 후 파일 전송이 완료되기 전에 반환됩니다. 또한 FileReference 객체가 범위를 벗어나는 경우 아직 완료되지 않은 해당 객체의 모든 트랜잭션은 범위를 벗어나는 즉시 취소됩니다. 업로드, 다운로드, 로드 또는 저장을 계속해야 한다면 FileReference 객체가 범위 내에 있도록 주의해야 합니다.

파일이 성공적으로 저장되면 FileReference 객체의 속성이 로컬 파일의 속성으로 채워집니다. 저장에 성공하면 complete 이벤트가 전달됩니다.

한 번에 하나의 대화 상자만 호출할 수 있으므로 browse() 또는 save() 세션은 한 번에 하나만 수행할 수 있습니다.

Flash Player에서는 마우스 클릭이나 키 누르기 이벤트에 대한 이벤트 핸들러 등 사용자 이벤트에 대한 응답으로만 이 메서드를 호출할 수 있습니다. 그렇지 않은 경우 이 메서드를 호출하면 Flash Player에서 오류 예외가 발생합니다. 응용 프로그램 샌드박스의 AIR 내용에는 이 제한이 적용되지 않습니다.

Adobe AIR에서는 [저장] 대화 상자가 항상 다른 윈도우가 "소유한" 윈도우(owner 속성 값이 null이 아닌 윈도우) 앞에 표시되는 것은 아닙니다. 윈도우 순서 문제를 피하려면 이 메서드를 호출하기 전에 소속된 윈도우를 숨기십시오.

매개 변수

data:* — 저장할 데이터입니다. 데이터는 다양한 다음 형식 중 하나일 수 있으며 그에 따라 적절히 처리됩니다.
  • 값이 null인 경우 응용 프로그램에서 ArgumentError 예외가 발생합니다.
  • 값이 String인 경우 UTF-8 텍스트 파일로 저장됩니다.
  • 값이 XML인 경우 텍스트 파일에 XML 형식으로 기록되며 모든 형식을 유지합니다.
  • 값이 ByteArray 객체인 경우 데이터 파일에 그대로 기록됩니다.
  • 그 외의 값이면 save() 메서드가 객체의 toString() 메서드를 호출하여 데이터를 문자열로 변환한 다음 텍스트 파일로 저장합니다. 이 작업이 실패하면 응용 프로그램에서 ArgumentError 예외가 발생합니다.
 
defaultFileName:String (default = null) — 대화 상자에 표시되는 저장할 파일의 기본 파일 이름입니다. 이 문자열은 다음 문자를 포함할 수 없습니다. / \ : * ? " < > | %

File 객체가 이 메서드를 호출하면 파일 이름이 File 객체가 참조하는 파일이 됩니다. AIR File 클래스는 FileReference 클래스를 확장합니다.


이벤트
open:Event — 다운로드 작업이 시작될 때 전달됩니다.
 
progress:ProgressEvent — 파일 다운로드 작업 중 주기적으로 전달됩니다.
 
complete:Event — 파일 다운로드 작업이 성공적으로 완료되었을 때 전달됩니다.
 
cancel:Event — 사용자가 대화 상자를 닫을 때 전달됩니다.
 
select:Event — 사용자가 대화 상자에서 다운로드할 파일을 선택할 때 전달됩니다.
 
ioError:IOErrorEvent — 파일을 읽거나 전송하는 중에 입력/출력 오류가 발생하면 전달됩니다.

오류
IllegalOperationError — 발생 상황: 1) 다른 탐색 세션이 진행 중일 경우. 파일 탐색 세션은 한 번에 하나만 수행할 수 있습니다. 2) 다운로드할 파일 이름에 금지된 문자가 포함되어 있는 경우. 3) 사용자의 mms.cfg 파일 설정이 이 작업을 금지한 경우.
 
ArgumentError data가 ByteArray 유형이 아니며 toString() 메서드를 포함하지 않는 경우 예외가 발생합니다. data가 XML 유형이 아니며 toXMLString() 메서드를 포함하지 않는 경우 예외가 발생합니다.
 
Error — 메서드가 마우스 클릭이나 키 누르기 이벤트와 같은 사용자 액션에 대한 응답으로 호출되지 않는 경우.
 
MemoryError — 이 오류는 Flash Player가 파일을 위한 메모리를 할당할 수 없는 경우 발생할 수 있습니다. 파일이 너무 크거나 사용 가능한 메모리가 너무 적을 수 있습니다.

관련 API 요소


예제  ( 예제 사용 방법 )

다음 예제는 텍스트 필드에 입력한 내용을 파일에 저장합니다. 이 예제는 마우스 클릭에 응답하는 "버튼"과 같은 역할을 하는 편집 가능한 텍스트 필드(MyTextField) 및 편집할 수 없는 다른 텍스트 필드(MyButtonField)를 만듭니다. 사용자는 첫 번째 텍스트 필드를 편집하고 버튼을 클릭하여 로컬 파일로 텍스트 필드 내용을 저장할 수 있습니다. 마우스 클릭 이벤트 핸들러인 clickhandlerFileReference.save() 메서드(이름이 MyFileReference인 FileReference 객체의 경우)를 사용하여 사용자의 현재 운영 체제에서 대화 상자를 열어 사용자가 제공하는 이름으로 로컬 파일에 내용을 저장할 수 있도록 합니다.
var MyTextField:TextField = new TextField();
var MyButtonField:TextField = new TextField();
var MyFile:FileReference = new FileReference();

MyTextField.border = true;
MyTextField.type = TextFieldType.INPUT;

MyButtonField.background = true;
MyButtonField.backgroundColor = 0x339933;
MyButtonField.x = 150;
MyButtonField.height = 20;
MyButtonField.text = "Click here to save";

addChild(MyTextField);
addChild(MyButtonField);
MyButtonField.addEventListener(MouseEvent.CLICK, clickhandler);

function clickhandler(e:MouseEvent): void {
    MyFile.save(MyTextField.text);
}

upload

()메서드 
public function upload(request:URLRequest, uploadDataFieldName:String = "Filedata", testUpload:Boolean = false):void

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

원격 서버에 파일 업로드를 시작합니다. Flash Player에서는 업로드 또는 다운로드할 수 있는 파일의 크기를 제한하지 않지만, 공식적으로 이 플레이어는 100MB 이하의 업로드 또는 다운로드를 지원합니다. 이 메서드를 호출하기 전에 FileReference.browse() 또는 FileReferenceList.browse() 메서드를 호출해야 합니다.

FileReference를 확장하는 Adobe AIR 파일 클래스의 경우 upload() 메서드를 사용하여 파일을 업로드할 수 있습니다. Flash Player에서 사용되는 FileReference 클래스의 경우 사용자가 파일을 먼저 선택해야 합니다.

리스너는 업로드의 진행, 성공 또는 실패를 나타내는 이벤트를 수신합니다. FileReferenceList 객체를 사용하면 사용자가 업로드할 파일을 여러 개 선택하도록 할 수 있지만 파일을 한 번에 하나씩 업로드해야 합니다. 이렇게 하려면 FileReference 객체의 FileReferenceList.fileList 배열을 반복합니다.

FileReference.upload()FileReference.download() 함수는 비차단 방식입니다. 이들 함수는 호출 후 파일 전송이 완료되기 전에 반환됩니다. 또한 만일 FileReference 객체가 범위를 벗어나는 경우, 아직 완료되지 않은 해당 객체의 업로드 또는 다운로드는 범위를 벗어나는 즉시 취소됩니다. 업로드 또는 다운로드를 계속해야 한다면 FileReference 객체가 범위 내에 있도록 주의해야 합니다.

url 매개 변수에 전달된 URL에 파일이 업로드됩니다. URL은 업로드를 허용하도록 구성된 서버 스크립트여야 합니다. Flash Player는 HTTP POST 메서드를 사용하여 파일을 업로드합니다. 업로드를 처리하는 서버 스크립트에는 다음 요소가 포함된 POST 요청을 사용해야 합니다.

  • Content-Type : multipart/form-data
  • name 특성을 기본적으로 "Filedata"로 설정하고 filename 특성을 원본 파일의 이름으로 설정한 Content-Disposition
  • 파일의 이진 내용

일반적으로 예약된 포트에 연결할 수 없습니다. 차단된 포트의 전체 목록은 ActionScript 3.0 개발자 안내서의 "제한적 네트워킹 API"를 참조하십시오.

POST 요청 샘플은 uploadDataFieldName 매개 변수에 대한 설명을 참조하십시오. upload() 메서드를 사용하여 POST 또는 GET 매개 변수를 서버에 보낼 수 있습니다. request 매개 변수에 대한 설명을 참조하십시오.

testUpload 매개 변수가 true이고 업로드할 파일이 약 10KB보다 큰 경우, Windows용 Flash Player는 실제 파일을 업로드하기 전에 전송이 성공할 수 있는지 확인하기 위해 먼저 내용 없이 테스트 업로드 POST 작업을 보냅니다. 그런 다음, Flash Player는 실제 파일 내용을 포함하는 두 번째 POST 작업을 보냅니다. 10KB보다 작은 파일의 경우, Flash Player는 업로드할 실제 파일 내용을 사용하여 한 번의 업로드 POST를 수행합니다. Macintosh용 Flash Player는 테스트 업로드 POST 작업을 수행하지 않습니다.

참고: 서버에 사용자 인증이 필요한 경우 브라우저에서 실행 중인, 즉 브라우저 플러그인이나 ActiveX 컨트롤을 사용하는 SWF 파일만이 인증 및 다운로드에 필요한 사용자 이름과 암호를 요청하는 대화 상자를 제공할 수 있습니다. 플러그인이나 ActiveX 컨트롤을 사용하는 업로드 또는 독립형이나 외부 플레이어를 사용하는 업로드 또는 다운로드의 경우에는 파일 전송에 실패합니다.

이 메서드를 사용할 때는 다음과 같은 Flash Player 보안 모델을 고려해야 합니다.

  • 호출하는 SWF 파일이 신뢰할 수 없는 로컬 샌드박스에 있는 경우에는 로딩 작업이 허용되지 않습니다.
  • 기본 비헤이비어는 샌드박스 간의 액세스를 거부하는 것입니다. URL 정책 파일을 추가하여 웹 사이트에서 리소스에 액세스를 허용할 수 있습니다.
  • SWF 내용이 들어 있는 HTML 페이지에서 allowNetworking 매개 변수(objectembed 태그)를 설정하여 SWF 파일에서 이 메서드를 사용하지 않게 할 수 있습니다.

그러나 Adobe AIR에서 application 보안 샌드박스의 내용, 즉 AIR 응용 프로그램과 함께 설치되는 내용은 이러한 보안 제한에 의해 제한되지 않습니다.

보안에 대한 자세한 내용은 Flash Player 개발자 센터 항목: 보안을 참조하십시오.

새로운 기능이 Flash Player에 추가되어, Flash Player 10에 게시할 때 FileReference.browse(), FileReference.upload(), FileReference.download(), FileReference.load(), FileReference.save() 작업 중 한 번에 하나만 활성화할 수 있습니다. 그렇지 않으면 Flash Player에서 런타임 오류가 발생합니다(코드 2174). 진행 중인 작업을 중지하려면 FileReference.cancel()을 사용합니다. 이 제한은 Flash Player 10에만 적용되며, 이전 버전의 Flash Player에는 여러 개의 작업을 동시에 진행할 수 없는 제한이 적용되지 않습니다.

매개 변수

request:URLRequest — URLRequest 객체입니다. URLRequest 객체의 url 속성에는 HTTP POST 호출을 통한 업로드를 처리하도록 구성된 서버 스크립트의 URL이 포함되어야 합니다. 일부 브라우저에서는 URL 문자열의 길이가 제한됩니다. 길이가 256 문자보다 긴 경우 일부 브라우저나 서버에서는 실패할 수 있습니다. 이 매개 변수가 null인 경우 예외가 발생합니다. URLRequest 객체의 requestHeaders 속성은 무시됩니다. 사용자 정의 HTTP 요청은 업로드 또는 다운로드에서 지원되지 않습니다.

URL은 HTTP 또는 보안 업로드를 위한 HTTPS가 될 수 있습니다. HTTPS를 사용하려면 url 매개 변수에 HTTPS url을 사용합니다. url 매개 변수에 포트 번호를 지정하지 않는 경우 기본적으로 HTTP에 포트 80, HTTPS에 포트 443이 사용됩니다.

POST 또는 GET 매개 변수를 서버에 보내려면 URLRequest 객체의 data 속성을 해당 매개 변수로, method 속성을 URLRequestMethod.POST 또는 URLRequestMethod.GET으로 설정합니다.

 
uploadDataFieldName:String (default = "Filedata") — 업로드 POST 작업에서 파일 데이터 앞에 오는 필드 이름입니다. uploadDataFieldName 값은 null이나 빈 문자열이 아니어야 합니다. 다음의 POST 요청 샘플과 같이 uploadDataFieldName 값은 기본적으로 "Filedata"입니다.
    Content-Type: multipart/form-data; boundary=AaB03x
    --AaB03x 
    Content-Disposition: form-data; name="Filedata"; filename="example.jpg" 
    Content-Type: application/octet-stream
    ... contents of example.jpg ... 
    --AaB03x-- 
    
 
testUpload:Boolean (default = false) — 테스트 파일 업로드를 요청하는 설정입니다. testUpload is true인 경우 파일 크기가 10KB보다 크면, Flash Player는 내용 길이(Content-Length)가 0인 테스트 파일 업로드 POST를 시도합니다. 테스트 업로드는 실제 파일 업로드가 성공적으로 수행될지 확인하며, 필요한 경우 서버 인증이 성공할지도 확인합니다. 테스트 업로드는 Windows용 플레이어에서만 사용할 수 있습니다.


이벤트
open:Event — 업로드 작업이 시작될 때 전달됩니다.
 
progress:ProgressEvent — 파일 업로드 작업 중 주기적으로 전달됩니다.
 
complete:Event — 파일 업로드 작업이 성공적으로 완료되었을 때 전달됩니다.
 
uploadCompleteData:DataEvent — 파일 업로드에 성공한 후 서버에서 데이터가 수신되면 전달됩니다.
 
securityError:SecurityErrorEvent — 보안 오류로 인해 업로드에 실패할 때 전달됩니다.
 
httpStatus:HTTPStatusEvent — HTTP 오류로 인해 업로드에 실패할 때 전달됩니다.
 
httpResponseStatus:HTTPStatusEvent — 업로드 작업을 성공적으로 완료한 후 서버는 응답 URL과 응답 헤더를 반환합니다.
 
ioError:IOErrorEvent — 다음과 같은 상황에 호출됩니다.
  • Flash Player 또는 Adobe AIR에서 파일을 읽고 쓰고 전송하는 동안 입력/출력 오류가 발생하여 업로드에 실패한 경우
  • 인증(예: 사용자 이름 및 암호)이 요구되는 서버에 파일 업로드를 시도하여 업로드에 실패한 경우 업로드 중에는 암호 입력 방법이 제공되지 않습니다.
  • url 매개 변수에 유효하지 않은 프로토콜이 포함되었기 때문에 업로드에 실패한 경우. FileReference.upload()는 HTTP 또는 HTTPS를 사용해야 합니다.

오류
SecurityError — 신뢰할 수 없는 로컬 SWF 파일은 인터넷 통신이 불가능합니다. 이 SWF 파일을 네트워킹 가능한 로컬 파일(local-with-networking) 또는 신뢰할 수 있는 파일로 다시 규정하면 이 문제를 해결할 수 있습니다. 이 예외가 발생할 때는 액세스할 수 없는 로컬 파일 이름 및 URL을 알리는 메시지가 함께 표시됩니다.
 
SecurityError — 일반적으로 예약된 포트에 연결할 수 없습니다. 차단된 포트의 전체 목록은 ActionScript 3.0 개발자 안내서의 "제한적 네트워킹 API"를 참조하십시오.
 
IllegalOperationError — 발생 상황: 1) 다른 FileReference 또는 FileReferenceList 탐색 세션이 진행 중일 경우. 파일 탐색 세션은 한 번에 하나만 수행할 수 있습니다. 2) URL 매개 변수가 유효한 경로 또는 프로토콜이 아닌 경우. 파일 업로드는 HTTP를 사용해야 하며, 파일 다운로드는 FTP 또는 HTTP를 사용해야 합니다. 3) uploadDataFieldName 매개 변수가 null로 설정되어 있는 경우. 4) 사용자의 mms.cfg 파일 설정이 이 작업을 금지한 경우.
 
ArgumentError — 발생 상황: 1) uploadDataFieldName 매개 변수가 빈 문자열인 경우. 2) url.data가 ByteArray 유형인 경우. FileReference.upload()FileReference.download() 메서드와 함께 사용하려면 url.data가 URLVariables 또는 String 유형이어야 합니다. 3) application 보안 샌드박스의 AIR 런타임에서 URLRequest의 메서드가 GET 또는 POST(uploadEncoded() 대신 사용)가 아닌 경우
 
MemoryError — 이 오류는 다음과 같은 이유로 발생할 수 있습니다. 1) Flash Player에서 URLRequest.data 매개 변수를 UTF8에서 MBCS로 변환할 수 없습니다. FileReference.upload()로 전달된 URLRequest 객체가 GET 작업을 수행하도록 설정되고 System.useCodePagetrue로 설정된 경우 이 오류가 발생합니다. 2) Flash Player에서 POST 데이터를 위한 메모리를 할당할 수 없습니다. FileReference.upload()로 전달된 URLRequest 객체가 POST 작업을 수행하도록 설정된 경우 이 오류가 발생합니다.

관련 API 요소

    uploadUnencoded

()메서드 
public function uploadUnencoded(request:URLRequest):void

런타임 버전: AIR 1.0

인코딩 없이 URL로 파일 업로드를 시작합니다. upload() 메서드는 파일을 양식 데이터 엔벌로프로 인코딩하는 반면 uploadUnencoded() 메서드는 HTTP 요청 본문의 파일 내용을 그대로 전달합니다. 보내려는 데이터가 수신 서버가 이해할 수 있는 형식으로 이미 인코딩된 경우에는 uploadUnencoded() 메서드를 사용하십시오. 일반적으로 uploadeUnencoded() 메서드는 HTTP/WebDAV PUT 메서드와 함께 사용됩니다.

매개 변수

request:URLRequest — URLRequest 객체입니다. URLRequest 객체의 url 속성에는 HTTP POST 호출을 통한 업로드를 처리하도록 구성된 서버 스크립트의 URL이 포함되어야 합니다. 일부 브라우저에서는 URL 문자열의 길이가 제한됩니다. 길이가 256 문자보다 긴 경우 일부 브라우저나 서버에서는 실패할 수 있습니다. 이 매개 변수가 null인 경우 예외가 발생합니다.

URL은 HTTP 또는 보안 업로드를 위한 HTTPS가 될 수 있습니다. HTTPS를 사용하려면 url 매개 변수에 HTTPS url을 사용합니다. url 매개 변수에 포트 번호를 지정하지 않는 경우 기본적으로 HTTP에 포트 80, HTTPS에 포트 443이 사용됩니다.

POST 또는 GET 매개 변수를 서버에 보내려면 URLRequest 객체의 data 속성을 해당 매개 변수로, method 속성을 URLRequestMethod.POST 또는 URLRequestMethod.GET으로 설정합니다.


이벤트
open:Event — 업로드 작업이 시작될 때 전달됩니다.
 
progress:ProgressEvent — 파일 업로드 작업 중 주기적으로 전달됩니다.
 
complete:Event — 파일 업로드 작업이 성공적으로 완료되었을 때 전달됩니다.
 
uploadCompleteData:DataEvent — 파일 업로드에 성공한 후 서버에서 데이터가 수신되면 전달됩니다.
 
securityError:SecurityErrorEvent — 보안 오류로 인해 업로드에 실패할 때 전달됩니다.
 
httpStatus:HTTPStatusEvent — HTTP 오류로 인해 업로드에 실패할 때 전달됩니다.
 
httpResponseStatus:HTTPStatusEvent — 업로드 작업을 성공적으로 완료한 후 서버는 응답 URL과 응답 헤더를 반환합니다.
 
ioError:IOErrorEvent — 다음과 같은 상황에 호출됩니다.
  • Adobe AIR에서 파일을 읽고 쓰고 전송하는 동안 입력/출력 오류가 발생하여 업로드에 실패한 경우
  • 인증(예: 사용자 이름 및 암호)이 요구되는 서버에 파일 업로드를 시도하여 업로드에 실패한 경우 업로드 중에는 암호 입력 방법이 제공되지 않습니다.
  • url 매개 변수에 유효하지 않은 프로토콜이 포함되었기 때문에 업로드에 실패한 경우. FileReference.upload()는 HTTP 또는 HTTPS를 사용해야 합니다.

오류
SecurityError — 신뢰할 수 없는 로컬 SWF 파일은 인터넷 통신이 불가능합니다. 이 SWF 파일을 네트워킹 가능한 로컬 파일(local-with-networking) 또는 신뢰할 수 있는 파일로 다시 규정하면 이 문제를 해결할 수 있습니다. 이 예외가 발생할 때는 액세스할 수 없는 로컬 파일 이름 및 URL을 알리는 메시지가 함께 표시됩니다.
 
IllegalOperationError — 발생 상황: 1) 다른 FileReference 또는 FileReferenceList 탐색 세션이 진행 중일 경우. 파일 탐색 세션은 한 번에 하나만 수행할 수 있습니다. 2) URL 매개 변수가 유효한 경로 또는 프로토콜이 아닌 경우. 파일 업로드는 HTTP를 사용해야 합니다.

관련 API 요소

이벤트 세부 정보

cancel

이벤트
이벤트 객체 유형: flash.events.Event
속성 Event.type = flash.events.Event.CANCEL

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

사용자가 파일 탐색 대화 상자에서 파일 업로드 또는 다운로드를 취소할 때 전달됩니다. Flash Player에서는 사용자가 브라우저를 닫거나 현재 응용 프로그램을 중지하는 등 다른 방법으로 업로드나 다운로드를 취소하는 경우 이 이벤트를 전달하지 않습니다.

Event.CANCEL 상수는 cancel 이벤트 객체의 type 속성 값을 정의합니다.

이 이벤트에는 다음과 같은 속성이 있습니다.

속성
bubblesfalse
cancelablefalse. 취소할 기본 비헤이비어가 없습니다.
currentTarget이벤트 리스너를 통해 Event 객체를 처리하고 있는 객체입니다.
target작업이 취소된 객체에 대한 참조입니다.

예제  ( 예제 사용 방법 )

다음 예제에서는 cancel 이벤트 객체의 사용법을 보여 줍니다. 이 예제를 실행하려면 가상의 http://www.[yourDomain].com/SomeFile.pdf가 아닌 실제의 도메인과 파일을 가리키도록 downloadURL.url 속성을 변경합니다. 로컬 재생 보안을 네트워크만 액세스로 설정하여 SWF 파일을 컴파일해야 할 수도 있습니다. 또는 Flash Player 보안 설정을 업데이트하여 이 파일의 네트워크 액세스를 허용합니다.
package {
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.FileReference;
    import flash.net.URLRequest;

    public class FileReference_event_cancel extends Sprite {
        private var downloadURL:URLRequest;
        private var fileName:String = "SomeFile.pdf";
        private var file:FileReference;

        public function FileReference_event_cancel() {
            downloadURL = new URLRequest();
            downloadURL.url = "http://www.[yourDomain].com/SomeFile.pdf";
            file = new FileReference();
            file.addEventListener(Event.CANCEL, cancelHandler);
            file.download(downloadURL, fileName);
        }
        private function cancelHandler(event:Event):void {
            trace("cancelHandler: " + event);
        }
    }
}

complete

이벤트  
이벤트 객체 유형: flash.events.Event
속성 Event.type = flash.events.Event.COMPLETE

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

다운로드가 완료되거나 업로드가 HTTP 상태 코드 200을 생성할 때 전달됩니다. 파일 다운로드의 경우 Flash Player 또는 Adobe AIR가 디스크로 전체 파일 다운로드를 완료했을 때 이 이벤트가 전달됩니다. 파일 업로드의 경우 Flash Player 또는 Adobe AIR가 전송을 받는 서버로부터 HTTP 상태 코드 200을 수신한 후 이 이벤트가 전달됩니다.

Event.COMPLETE 상수는 complete 이벤트 객체의 type 속성 값을 정의합니다.

이 이벤트에는 다음과 같은 속성이 있습니다.

속성
bubblesfalse
cancelablefalse. 취소할 기본 비헤이비어가 없습니다.
currentTarget이벤트 리스너를 통해 Event 객체를 처리하고 있는 객체입니다.
target로드가 완료된 네트워크 객체입니다.

예제  ( 예제 사용 방법 )

다음 예제에서는 complete 이벤트 객체의 사용법을 보여 줍니다. 이 예제를 실행하려면 가상의 http://www.[yourDomain].com/SomeFile.pdf가 아닌 실제의 도메인과 파일을 가리키도록 downloadURL.url 속성을 변경합니다. 로컬 재생 보안을 네트워크만 액세스로 설정하여 SWF 파일을 컴파일해야 할 수도 있습니다. 또는 Flash Player 보안 설정을 업데이트하여 이 파일의 네트워크 액세스를 허용합니다.
package {
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.FileReference;
    import flash.net.URLRequest;

    public class FileReference_event_complete extends Sprite {
        private var downloadURL:URLRequest;
        private var fileName:String = "SomeFile.pdf";
        private var file:FileReference;

        public function FileReference_event_complete() {
            downloadURL = new URLRequest();
            downloadURL.url = "http://www.[yourDomain].com/SomeFile.pdf";
            file = new FileReference();
            configureListeners(file);
            file.download(downloadURL, fileName);
        }

        private function configureListeners(dispatcher:IEventDispatcher):void {
            dispatcher.addEventListener(Event.CANCEL, cancelHandler);
            dispatcher.addEventListener(Event.COMPLETE, completeHandler);
            dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
            dispatcher.addEventListener(Event.OPEN, openHandler);
            dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
            dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
            dispatcher.addEventListener(Event.SELECT, selectHandler);
        }

        private function cancelHandler(event:Event):void {
            trace("cancelHandler: " + event);
        }

        private function completeHandler(event:Event):void {
            trace("completeHandler: " + event);
        }

        private function ioErrorHandler(event:IOErrorEvent):void {
            trace("ioErrorHandler: " + event);
        }

        private function openHandler(event:Event):void {
            trace("openHandler: " + event);
        }

        private function progressHandler(event:ProgressEvent):void {
            var file:FileReference = FileReference(event.target);
            trace("progressHandler name=" + file.name + " bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
        }

        private function securityErrorHandler(event:SecurityErrorEvent):void {
            trace("securityErrorHandler: " + event);
        }

        private function selectHandler(event:Event):void {
            var file:FileReference = FileReference(event.target);
            trace("selectHandler: name=" + file.name + " URL=" + downloadURL.url);
        }
    }
}

관련 API 요소

    

httpResponseStatus

이벤트  
이벤트 객체 유형: flash.events.HTTPStatusEvent
속성 HTTPStatusEvent.type = flash.events.HTTPStatusEvent.HTTP_RESPONSE_STATUS

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, AIR 1.0

upload() 또는 uploadUnencoded() 메서드 호출로 HTTP를 통해 데이터 액세스를 시도하고 Adobe AIR에서 요청에 대한 상태 코드를 감지 및 반환할 수 있을 때 전달됩니다.

httpStatus 이벤트와는 달리, httpResponseStatus 이벤트는 응답 데이터 이전에 전달됩니다. 또한 httpResponseStatus 이벤트에는 responseHeadersresponseURL 속성(httpStatus 이벤트에 대해 정의되어 있지 않음) 값이 포함되어 있습니다. httpResponseStatus 이벤트(있는 경우)는 complete 또는 error 이벤트 발생 전에 추가로 전송됩니다.

HTTPStatusEvent.HTTP_RESPONSE_STATUS 상수는 httpResponseStatus 이벤트 객체의 type 속성 값을 정의합니다.

이 이벤트에는 다음과 같은 속성이 있습니다.

속성
bubblesfalse
cancelablefalse. 취소할 기본 비헤이비어가 없습니다.
currentTarget이벤트 리스너를 통해 Event 객체를 처리하고 있는 객체입니다.
responseURL응답이 반환된 URL입니다.
responseHeadersURLRequestHeader 객체의 배열로 응답이 반환된 응답 헤더입니다.
status서버에 의해 반환된 HTTP 상태 코드입니다.
redirected응답이 리디렉션의 결과인지 여부입니다.
targetHTTP 상태 코드를 수신하는 네트워크 객체입니다.

관련 API 요소

httpStatus

이벤트  
이벤트 객체 유형: flash.events.HTTPStatusEvent
속성 HTTPStatusEvent.type = flash.events.HTTPStatusEvent.HTTP_STATUS

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

업로드에 실패하고 HTTP 상태 코드를 사용하여 실패를 설명할 수 있을 때 전달됩니다. httpStatus 이벤트가 전달된 후 ioError 이벤트가 전달됩니다.

httpStatus 이벤트는 업로드에 실패한 경우에만 전달됩니다. Flash Player에서 실행 중인 내용의 경우 다운로드 실패 시에는 이 이벤트가 적용되지 않습니다. HTTP 오류로 인해 다운로드에 실패하면, 이 오류는 입출력 오류로 보고됩니다.

HTTPStatusEvent.HTTP_STATUS 상수는 httpStatus 이벤트 객체의 type 속성 값을 정의합니다.

이 이벤트에는 다음과 같은 속성이 있습니다.

속성
bubblesfalse
cancelablefalse. 취소할 기본 비헤이비어가 없습니다.
currentTarget이벤트 리스너를 통해 Event 객체를 처리하고 있는 객체입니다.
status서버에 의해 반환된 HTTP 상태 코드입니다.
targetHTTP 상태 코드를 수신하는 네트워크 객체입니다.

관련 API 요소

ioError

이벤트  
이벤트 객체 유형: flash.events.IOErrorEvent
속성 IOErrorEvent.type = flash.events.IOErrorEvent.IO_ERROR

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

업로드 또는 다운로드가 실패할 때 전달됩니다. 파일 전송은 다음과 같은 이유로 실패할 수 있습니다.

  • 플레이어가 파일을 읽기, 쓰기 또는 전송하는 중 입력/출력 오류가 발생했습니다.
  • SWF 파일이 인증(예: 사용자 이름 및 암호)이 필요한 서버에 파일 업로드를 시도했습니다. 업로드 시 Flash Player 또는 Adobe AIR는 암호 입력 방법을 제공하지 않습니다. SWF 파일이 인증이 필요한 서버에 파일을 업로드하려고 하면 업로드에 실패합니다.
  • 독립형 플레이어 또는 외부 플레이어에서 SWF 파일이 인증이 필요한 서버로부터 파일 다운로드를 시도했습니다. 다운로드 시 독립 실행형 플레이어 및 외부 플레이어는 암호 입력 방법을 제공하지 않습니다. 이러한 플레이어에서 SWF 파일이 인증이 필요한 서버로부터 파일 다운로드를 시도하면 다운로드에 실패합니다. 파일은 ActiveX 컨트롤, 브라우저 플러그인 플레이어 및 Adobe AIR 런타임을 사용하여 다운로드해야 합니다.
  • upload() 메서드의 url 매개 변수에 전달된 값에 유효하지 않은 프로토콜이 포함되어 있습니다. 유효한 프로토콜은 HTTP 및 HTTPS입니다.

중요: 브라우저에서 실행 중인 응용 프로그램(브라우저 플러그인이나 ActiveX 컨트롤을 사용하는 응용 프로그램)과 Adobe AIR에서 실행 중인 내용만이 인증 및 다운로드에 필요한 사용자 이름과 암호 입력을 요청하는 대화 상자를 제공할 수 있습니다. 플러그인 또는 ActiveX 컨트롤을 사용하여 업로드하거나 독립형 플레이어 또는 외부 플레이어를 사용하여 업로드하거나 다운로드하면 파일 전송이 실패합니다.

ioError 이벤트 객체의 type 속성 값을 정의합니다.

이 이벤트에는 다음과 같은 속성이 있습니다.

속성
bubblesfalse
cancelablefalse. 취소할 기본 비헤이비어가 없습니다.
currentTarget이벤트 리스너를 통해 Event 객체를 처리하고 있는 객체입니다.
errorID특정 오류와 연결된 참조 번호입니다(AIR만 해당).
target입력/출력 오류가 발생한 네트워크 객체입니다.
text오류 메시지로 표시될 텍스트입니다.

관련 API 요소

open

이벤트  
이벤트 객체 유형: flash.events.Event
속성 Event.type = flash.events.Event.OPEN

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

업로드 또는 다운로드 작업이 시작될 때 전달됩니다.

Event.OPEN 상수는 open 이벤트 객체의 type 속성 값을 정의합니다.

이 이벤트에는 다음과 같은 속성이 있습니다.

속성
bubblesfalse
cancelablefalse. 취소할 기본 비헤이비어가 없습니다.
currentTarget이벤트 리스너를 통해 Event 객체를 처리하고 있는 객체입니다.
target연결을 설정한 네트워크 객체입니다.

예제  ( 예제 사용 방법 )

다음 예제에서는 download 이벤트 객체의 사용법을 보여 줍니다. 이 예제를 실행하려면 가상의 http://www.[yourDomain].com/SomeFile.pdf가 아닌 실제의 도메인과 파일을 가리키도록 downloadURL.url 속성을 변경합니다. 로컬 재생 보안을 네트워크만 액세스로 설정하여 SWF 파일을 컴파일해야 할 수도 있습니다. 또는 Flash Player 보안 설정을 업데이트하여 이 파일의 네트워크 액세스를 허용합니다.
package {
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.FileReference;
    import flash.net.URLRequest;
    import flash.net.FileFilter;

    public class FileReference_download extends Sprite {
        private var downloadURL:URLRequest;
        private var fileName:String = "SomeFile.pdf";
        private var file:FileReference;

        public function FileReference_download() {
            downloadURL = new URLRequest();
            downloadURL.url = "http://www.[yourDomain].com/SomeFile.pdf";
            file = new FileReference();
            configureListeners(file);
            file.download(downloadURL, fileName);
        }

        private function configureListeners(dispatcher:IEventDispatcher):void {
            dispatcher.addEventListener(Event.CANCEL, cancelHandler);
            dispatcher.addEventListener(Event.COMPLETE, completeHandler);
            dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
            dispatcher.addEventListener(Event.OPEN, openHandler);
            dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
            dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
            dispatcher.addEventListener(Event.SELECT, selectHandler);
        }

        private function cancelHandler(event:Event):void {
            trace("cancelHandler: " + event);
        }

        private function completeHandler(event:Event):void {
            trace("completeHandler: " + event);
        }

        private function ioErrorHandler(event:IOErrorEvent):void {
            trace("ioErrorHandler: " + event);
        }

        private function openHandler(event:Event):void {
            trace("openHandler: " + event);
        }

        private function progressHandler(event:ProgressEvent):void {
            var file:FileReference = FileReference(event.target);
            trace("progressHandler name=" + file.name + " bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
        }

        private function securityErrorHandler(event:SecurityErrorEvent):void {
            trace("securityErrorHandler: " + event);
        }

        private function selectHandler(event:Event):void {
            var file:FileReference = FileReference(event.target);
            trace("selectHandler: name=" + file.name + " URL=" + downloadURL.url);
        }
    }
}

관련 API 요소

    

permissionStatus

이벤트  
이벤트 객체 유형: flash.events.PermissionEvent
속성 PermissionEvent.type = flash.events.PermissionEvent.PERMISSION_STATUS

언어 버전: ActionScript 3.0
런타임 버전: AIR 24.0

응용 프로그램이 파일 시스템에 액세스할 수 있는 권한을 요청할 때 전달됩니다. status 속성 값을 검사하여 권한이 부여되었는지 아니면 거부되었는지 확인합니다.

관련 API 요소

progress

이벤트  
이벤트 객체 유형: flash.events.ProgressEvent
속성 ProgressEvent.type = flash.events.ProgressEvent.PROGRESS

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

파일 업로드 또는 다운로드 작업 중 주기적으로 전달됩니다. progress 이벤트는 Flash Player가 서버에 바이트를 전송하는 동안 전달되며, 결국 전송에 실패하더라도 전송 과정에서 주기적으로 전달됩니다. 파일 전송이 성공적으로 완료되었는지 여부와 완료 시점을 확인하려면 complete 이벤트를 수신합니다.

progress 이벤트가 수신되지 않는 경우도 있습니다. 예를 들어 전송 중인 파일 크기가 매우 작거나 업로드 또는 다운로드가 매우 빠르게 진행되는 경우에는 progress 이벤트가 전달되지 않을 수도 있습니다.

OS X 10.3 이전의 Macintosh 플랫폼에서는 파일 업로드 과정을 확인할 수 없습니다. progress 이벤트가 업로드 작업 중 호출되지만, progress 이벤트의 bytesLoaded 속성 값이 -1로 진행 과정을 확인할 수 없음을 나타냅니다.

progress 이벤트 객체의 type 속성 값을 정의합니다.

이 이벤트에는 다음과 같은 속성이 있습니다.

속성
bubblesfalse
bytesLoaded리스너가 이벤트를 처리할 때 로드된 항목 수 또는 바이트 수입니다.
bytesTotal로드 프로세스가 완료되면 최종적으로 로드될 총 바이트 수 또는 항목 수입니다.
cancelablefalse. 취소할 기본 비헤이비어가 없습니다.
currentTarget이벤트 리스너를 통해 Event 객체를 처리하고 있는 객체입니다.
target진행률을 보고하는 객체입니다.

예제  ( 예제 사용 방법 )

다음 예제에서는 progress 이벤트의 사용법을 보여 줍니다. 이 예제를 실행하려면 가상의 http://www.[yourDomain].com/SomeFile.pdf가 아닌 실제의 도메인과 파일을 가리키도록 downloadURL.url 속성을 변경합니다. 로컬 재생 보안을 네트워크만 액세스로 설정하여 SWF 파일을 컴파일해야 할 수도 있습니다. 또는 Flash Player 보안 설정을 업데이트하여 이 파일의 네트워크 액세스를 허용합니다.
package {
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.FileReference;
    import flash.net.URLRequest;

    public class FileReference_event_progress extends Sprite {
        private var downloadURL:URLRequest;
        private var fileName:String = "SomeFile.pdf";
        private var file:FileReference;

        public function FileReference_event_progress() {
            downloadURL = new URLRequest();
            downloadURL.url = "http://www.[yourDomain].com/SomeFile.pdf";
            file = new FileReference();
            file.addEventListener(ProgressEvent.PROGRESS, progressHandler);
            file.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
            file.addEventListener(Event.COMPLETE, completeHandler);
            file.download(downloadURL, fileName);
        }

        private function progressHandler(event:ProgressEvent):void {
            var file:FileReference = FileReference(event.target);
            trace("progressHandler: name=" + file.name + " bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
        }
        
        private function ioErrorHandler(event:IOErrorEvent):void {
            trace("ioErrorHandler: " + event);
        }
        
        private function completeHandler(event:Event):void {
            trace("completeHandler: " + event);
        }
    }
}

관련 API 요소

securityError

이벤트  
이벤트 객체 유형: flash.events.SecurityErrorEvent
속성 SecurityErrorEvent.type = flash.events.SecurityErrorEvent.SECURITY_ERROR

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

FileReference.upload() 또는 FileReference.download() 메서드 호출로 호출자의 보안 샌드박스 외부에 있는 서버에 대한 파일 업로드 또는 파일 가져오기를 시도할 때 전달됩니다. 발생한 특정 오류를 설명하는 텍스트 속성의 값은 일반적으로 "securitySandboxError"입니다. 호출 SWF 파일에서 도메인 외부의 SWF 파일을 액세스하려고 시도했지만 해당 권한이 없을 수도 있습니다. URL 정책 파일을 사용하여 이 오류를 해결할 수 있습니다.

Adobe AIR에서 이러한 보안 제한 사항은 application 보안 샌드박스의 내용에 적용되지 않습니다.

Adobe AIR에서 이러한 보안 제한 사항은 application 보안 샌드박스의 내용에 적용되지 않습니다.

SecurityErrorEvent.SECURITY_ERROR 상수는 securityError 이벤트 객체의 type 속성 값을 정의합니다.

이 이벤트에는 다음과 같은 속성이 있습니다.

속성
bubblesfalse
cancelablefalse. 취소할 기본 비헤이비어가 없습니다.
currentTarget이벤트 리스너를 통해 Event 객체를 처리하고 있는 객체입니다.
target보안 오류를 보고하는 네트워크 객체입니다.
text오류 메시지로 표시될 텍스트입니다.

관련 API 요소

select

이벤트  
이벤트 객체 유형: flash.events.Event
속성 Event.type = flash.events.Event.SELECT

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9

사용자가 파일 탐색 대화 상자에서 업로드 또는 다운로드할 파일을 선택할 때 전달됩니다. 이 대화 상자는 FileReference.browse(), FileReferenceList.browse() 또는 FileReference.download() 메서드를 호출할 때 열립니다. 파일을 선택하고 작업을 확인하면(예: [확인]을 클릭) FileReference 객체 속성이 채워집니다.

Flash Player에서 또는 Adobe AIR 런타임의 응용 프로그램 보안 샌드박스 외부에서 실행 중인 내용의 경우 select 이벤트는 이 이벤트를 호출하는 메서드에 따라 약간 다르게 동작합니다. browse() 호출 후에 select 이벤트가 전달되면 사용자가 선택한 파일이 로컬 파일 시스템에 있으므로 Flash Player 또는 AIR 응용 프로그램이 FileReference 객체의 모든 속성을 읽을 수 있습니다. download() 호출 후에 select 이벤트가 발생하면 select 이벤트가 전달되는 시점에 해당 파일이 로컬 파일 시스템으로 아직 다운로드되지 않으므로 Flash Player 또는 AIR 응용 프로그램이 name 속성만 읽을 수 있습니다. 파일이 다운로드된 후 complete 이벤트가 전달되면 Flash Player 또는 AIR 응용 프로그램이 FileReference 객체의 다른 모든 속성을 읽을 수 있습니다.

Event.SELECT 상수는 select 이벤트 객체의 type 속성 값을 정의합니다.

이 이벤트에는 다음과 같은 속성이 있습니다.

속성
bubblesfalse
cancelablefalse. 취소할 기본 비헤이비어가 없습니다.
currentTarget이벤트 리스너를 통해 Event 객체를 처리하고 있는 객체입니다.
target항목이 선택된 객체입니다.

예제  ( 예제 사용 방법 )

다음 예제에서는 select 이벤트 객체의 사용법을 보여 줍니다. 이 예제를 실행하려면 가상의 http://www.[yourDomain].com/SomeFile.pdf가 아닌 실제의 도메인과 파일을 가리키도록 uploadURL.url 속성을 변경합니다. 로컬 재생 보안을 네트워크만 액세스로 설정하여 SWF 파일을 컴파일해야 할 수도 있습니다. 또는 Flash Player 보안 설정을 업데이트하여 이 파일의 네트워크 액세스를 허용합니다. 이 예제를 데스크톱에서 실행하려면 게시된 crossdomain.xml 파일이 해당 서버에도 있어야 합니다. ioErrorHandler() 함수가 트리거되면 업로드를 수신하도록 구성된 유효한 url로 제공된 uploadURL을 업데이트해야 할 수 있습니다.
 
package {
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.FileReference;
    import flash.net.URLRequest;

    public class FileReference_event_select extends Sprite {
        private var uploadURL:URLRequest;
        private var file:FileReference;

        public function FileReference_event_select() {
            uploadURL = new URLRequest();
            uploadURL.url = "http://www.[yourDomain].com/yourUploadHandlerScript.cfm";
            file = new FileReference();
            file.addEventListener(Event.SELECT, selectHandler);
            file.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
            file.addEventListener(ProgressEvent.PROGRESS, progressHandler);
            file.addEventListener(Event.COMPLETE, completeHandler);
            file.browse();
        }

        private function selectHandler(event:Event):void {
            var file:FileReference = FileReference(event.target);
            trace("selectHandler: name=" + file.name + " URL=" + uploadURL.url);
            file.upload(uploadURL);
        }

        private function ioErrorHandler(event:IOErrorEvent):void {
            trace("ioErrorHandler: " + event);
        }

        private function progressHandler(event:ProgressEvent):void {
            var file:FileReference = FileReference(event.target);
            trace("progressHandler: name=" + file.name + " bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
        }

        private function completeHandler(event:Event):void {
            trace("completeHandler: " + event);
        }
    }
}

uploadCompleteData

이벤트  
이벤트 객체 유형: flash.events.DataEvent
속성 DataEvent.type = flash.events.DataEvent.UPLOAD_COMPLETE_DATA

언어 버전: ActionScript 3.0
런타임 버전: AIR 1.0, Flash Player 9.0.28.0

업로드에 성공한 후 서버에서 데이터가 수신되면 전달됩니다. 이 이벤트는 서버에서 데이터가 반환되지 않은 경우 전달되지 않습니다.

uploadCompleteData 이벤트 객체의 type 속성 값을 정의합니다.

이 이벤트에는 다음과 같은 속성이 있습니다.

속성
bubblesfalse
cancelablefalse. 취소할 기본 비헤이비어가 없습니다.
currentTarget이벤트 리스너를 통해 Event 객체를 처리하고 있는 객체입니다.
data파일 업로드 성공 후 서버에서 반환되는 원시 데이터입니다.
target업로드 성공 후 데이터를 수신하는 FileReference 객체입니다.
FileReferenceExample.as

다음 예제에서는 런타임 시 로드되는 파일의 데이터 유형 및 상태 정보를 표시합니다.

참고: 이 예제를 실행하려면 가상의 URL이 아닌 실제 URL을 가리키도록 uploadURL.url 속성을 변경합니다. URL은 지정된 URL의 루트 웹 디렉토리에서 yourUploadHandlerScript.cfm이라는 파일을 가리켜야 합니다. 해당 구성에 따라, 로컬 재생 보안을 네트워크만 액세스로 설정하여 SWF 파일을 컴파일해야 할 수도 있습니다. 또는 Flash Player 보안 설정을 업데이트하여 이 파일의 네트워크 액세스를 허용합니다.

package {
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.FileFilter;
    import flash.net.FileReference;
    import flash.net.URLRequest;

    public class FileReferenceExample extends Sprite {
        private var uploadURL:URLRequest;
        private var file:FileReference;

        public function FileReferenceExample() {
            uploadURL = new URLRequest();
            uploadURL.url = "http://www.[yourDomain].com/yourUploadHandlerScript.cfm";
            file = new FileReference();
            configureListeners(file);
            file.browse(getTypes());
        }

        private function configureListeners(dispatcher:IEventDispatcher):void {
            dispatcher.addEventListener(Event.CANCEL, cancelHandler);
            dispatcher.addEventListener(Event.COMPLETE, completeHandler);
            dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
            dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
            dispatcher.addEventListener(Event.OPEN, openHandler);
            dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
            dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
            dispatcher.addEventListener(Event.SELECT, selectHandler);
            dispatcher.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,uploadCompleteDataHandler);
        }

        private function getTypes():Array {
            var allTypes:Array = new Array(getImageTypeFilter(), getTextTypeFilter());
            return allTypes;
        }

        private function getImageTypeFilter():FileFilter {
            return new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg;*.jpeg;*.gif;*.png");
        }

        private function getTextTypeFilter():FileFilter {
            return new FileFilter("Text Files (*.txt, *.rtf)", "*.txt;*.rtf");
        }

        private function cancelHandler(event:Event):void {
            trace("cancelHandler: " + event);
        }

        private function completeHandler(event:Event):void {
            trace("completeHandler: " + event);
        }

        private function uploadCompleteDataHandler(event:DataEvent):void {
            trace("uploadCompleteData: " + event);
        }

        private function httpStatusHandler(event:HTTPStatusEvent):void {
            trace("httpStatusHandler: " + event);
        }
        
        private function ioErrorHandler(event:IOErrorEvent):void {
            trace("ioErrorHandler: " + event);
        }

        private function openHandler(event:Event):void {
            trace("openHandler: " + event);
        }

        private function progressHandler(event:ProgressEvent):void {
            var file:FileReference = FileReference(event.target);
            trace("progressHandler name=" + file.name + " bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
        }

        private function securityErrorHandler(event:SecurityErrorEvent):void {
            trace("securityErrorHandler: " + event);
        }

        private function selectHandler(event:Event):void {
            var file:FileReference = FileReference(event.target);
            trace("selectHandler: name=" + file.name + " URL=" + uploadURL.url);
            file.upload(uploadURL);
        }
    }
}




[ X ]영어로 표시되는 이유
ActionScript 3.0 참조 설명서의 내용이 영어로 나타납니다.

ActionScript 3.0 참조 설명서 중 일부는 전체 언어로 번역되지 않았습니다. 언어 요소가 번역되지 않은 경우 영어로 나타납니다. 예를 들어 ga.controls.HelpBox 클래스는 어떤 언어로도 번역되지 않았습니다. 그러므로 한국어 버전의 참조 설명서에서 ga.controls.HelpBox 클래스는 영어로 나타납니다.