올플래시로 사이트를 만들거나
자바스크립트, 제이쿼리등을 이용하여 동적으로 페이지를 로드하여 보여줄 때
페이지이동간 history가 쌓이지 않아서 앞으로가기 뒤로가기가 되지 않는다.
이는 해당페이지를 보다가 단축키 혹은 마우스 기능키등으로 뒤로가기를 습관적으로 누를 경우
아예 다른 곳으로 가버리게 된다 ㅠㅠ.
또다른 단점은 해당사이트의 특정 페이지를 보고싶을때 모든페이지가 같은 주소로 이루어져 있어
바로 접근이 불가능하여 원하는 화면을 보기 위해선 사이트의 처음에서 시작하여 해당 페이지로 이동해야 한다.
이것을 해결하려면
화면 전환 혹은 페이지 이동시 바로 해당컨텐츠를 로드,변환 하지 않고
주소창을 변경한후 플래시측에서 다시 그것을 해석하여 처리해야 한다.
큰 흐름은 이렇다.
1) 네비게이션 클릭
2) 주소창 변경
3) 브라우저 히스토리 축적
4) 플래시에서 주소창 변경을 캐치
5) 주소를 문자열로 받아 해석
6) 실제적 화면전환 혹은 페이지 로드
그리고 사이트 최초 접속시에 4번부터 로직을 실행한다.
그럼 해결.
이작업을 하려면 external 부터 시작해서 자바스크립트까지 이것저것 귀찮은 일들이 많다. 각종 브라우저, 버전, 상황에 따라 처리하려면 분명 쉽지않은 일;
하지만 이것을 해주는 라이브러리가 있었습니다. 두둥
http://www.asual.com/swfaddress/
아래는 doc
Class SWFAddress
SWFAddress is distributed as a top level class. Projects that utilize code packages should use it with the com.asual.swfaddress package.
Public Properties
onChange:Function
[static] Change event.
|
onExternalChange:Function
[static] External change event.
|
onInit:Function
[static] Init event.
|
onInternalChange:Function
[static] Internal change event.
|
Public Methods
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
[static] Registers an event listener.
|
back():void
[static] Loads the previous URL in the history list.
|
dispatchEvent(event:Event):Boolean
[static] Dispatches an event to all the registered listeners.
|
forward():void
[static] Loads the next URL in the history list.
|
up():void
[static] Navigates one level up in the deep linking path.
|
getBaseURL():String
[static] Provides the base address of the document.
|
getHistory():Boolean
[static] Provides the state of the history setting.
|
getParameter(param:String):Object
[static] Provides the value of a specific query parameter as a string or array of strings.
|
getParameterNames():Array
[static] Provides a list of all the query parameter names.
|
getPath():String
[static] Provides the deep linking value without the query string.
|
getPathNames():Array
[static] Provides a list of all the folders in the deep linking path.
|
getQueryString():String
[static] Provides the query string part of the deep linking value.
|
getStatus():String
[static] Provides the status of the browser window.
|
getStrict():Boolean
[static] Provides the state of the strict mode setting.
|
getTitle():String
[static] Provides the title of the HTML document.
|
getTracker():String
[static] Provides the tracker function.
|
getValue():String
[static] Provides the current deep linking value.
|
go(delta:Number):void
[static] Loads a URL from the history list.
|
hasEventListener(type:String):Boolean
[static] Checks the existance of any listeners registered for a specific type of event.
|
href(url:String, target:String = "_self"):void
[static] Opens a new URL in the browser.
|
popup(url:String, name:String = "popup", options:String = "", handler:String = ""):void
[static] Opens a browser popup window.
|
removeEventListener(type:String, listener:Function):void
[static] Removes an event listener.
|
resetStatus():void
[static] Resets the status of the browser window.
|
setHistory(history:Boolean):void
[static] Enables or disables the creation of history entries.
|
setStatus(status:String):void
[static] Sets the status of the browser window.
|
setStrict(strict:Boolean):void
[static] Enables or disables the strict mode.
|
setTitle(title:String):void
[static] Sets the title of the HTML document.
|
setTracker(tracker:String):void
[static] Sets a function for page view tracking.
|
setValue(value:String):void
[static] Sets the current deep linking value.
|
Property detail
onChange
public static var onChange:Function
Change event.
onExternalChange
public static var onExternalChange:Function
External change event.
onInit
public static var onInit:Function
Init event.
onInternalChange
public static var onInternalChange:Function
Internal change event.
Method detail
addEventListener
public static function addEventListener(type:String, listener:Function):void
Registers an event listener.
- Parameters
type:String
— Event type.listener:Function
— Event listener.useCapture:Boolean
— Determines whether the listener works in the capture phase or the target and bubbling phases.priority:int
— The priority level of the event listener.useWeakReference:Boolean
— Determines whether the reference to the listener is strong or weak.
back
public static function back():void
Loads the previous URL in the history list.
dispatchEvent
public static function dispatchEvent(event:Event):Boolean
Dispatches an event to all the registered listeners.
- Parameters
event:Event
— Event object.
- Returns
Boolean
forward
public static function forward():void
Loads the next URL in the history list.
getBaseURL
public static function getBaseURL():String
Provides the base address of the document.
- Returns
String
getHistory
public static function getHistory():Boolean
Provides the state of the history setting.
- Returns
Boolean
getParameter
public static function getParameter(param:String):Object
Provides the value of a specific query parameter as a string or array of strings.
- Parameters
param:String
— Parameter name.
- Returns
String
getParameterNames
public static function getParameterNames():Array
Provides a list of all the query parameter names.
- Returns
Array
getPath
public static function getPath():String
Provides the deep linking value without the query string.
- Returns
String
getPathNames
public static function getPathNames():Array
Provides a list of all the folders in the deep linking path.
- Returns
Array
getQueryString
public static function getQueryString():String
Provides the query string part of the deep linking value.
- Returns
String
getStatus
public static function getStatus():String
Provides the status of the browser window.
- Returns
String
getStrict
public static function getStrict():Boolean
Provides the state of the strict mode setting.
- Returns
Boolean
getTitle
public static function getTitle():String
Provides the title of the HTML document.
- Returns
String
getTracker
public static function getTracker():String
Provides the tracker function.
- Returns
String
getValue
public static function getValue():String
Provides the current deep linking value.
- Returns
String
go
public static function go(delta:Number):void
Loads a URL from the history list.
- Parameters
delta:Number
— An integer representing a relative position in the history list.
hasEventListener
public static function hasEventListener(type:String):Boolean
Checks the existance of any listeners registered for a specific type of event.
- Parameters
type:String
— Event type.
- Returns
Boolean
href
public static function href(url:String, target:String = "_self"):void
Opens a new URL in the browser.
- Parameters
url:String
— The resource to be opened.target:String
(default = "_self
")— Target window.
popup
public static function popup(url:String, name:String = "popup", options:String = "", handler:String = ""):void
Opens a browser popup window.
- Parameters
url:String
— Resource location.name:String
(default = "popup
")— Name of the popup window.
options:String
(default = "")
— Options which get evaluted and passed to the window.open() method.
handler:String
(default = "")
— Optional JavsScript handler code for popup handling.
removeEventListener
public static function removeEventListener(type:String, listener:Function):void
Removes an event listener.
- Parameters
type:String
— Event type.listener:Function
— Event listener.
resetStatus
public static function resetStatus():void
Resets the status of the browser window.
setHistory
public static function setHistory(history:Boolean):void
Enables or disables the creation of history entries.
- Parameters
history:Boolean
— history History state.
setStatus
public static function setStatus(status:String):void
Sets the status of the browser window.
- Parameters
status:String
— Status value.
setStrict
public static function setStrict(strict:Boolean):void
Enables or disables the strict mode.
- Parameters
strict:Boolean
— strict Strict mode state.
setTitle
public static function setTitle(title:String):void
Sets the title of the HTML document.
- Parameters
title:String
— Title value.
setTracker
public static function setTracker(tracker:String):void
Sets a function for page view tracking. By default both 'urchinTracker' and 'pageTracker._trackPageview' are automatically invoked.
- Parameters
tracker:String
— Tracker function.
setValue
public static function setValue(value:String):void
Sets the current deep linking value.
- Parameters
value:String
— A value which will be appended to the base link of the HTML document.
Class SWFAddressEvent
Event class for SWFAddress.
Public Properties
parameterNames:Array
[read-only] The parameters names of this event.
|
parameters:Object
[read-only] The parameters of this event.
|
path:String
[read-only] The path of this event.
|
pathNames:Array
[read-only] The folders in the deep linking path of this event.
|
target:Object
[read-only] The target of this event.
|
type:String
[read-only] The target of this event.
|
value:String
[read-only] The value of this event.
|
Public Methods
SWFAddressEvent(type:String)
Creates a new SWFAddress event.
|
clone():Event
Clones this event.
|
Public Constants
CHANGE:String = "change"
[static] Change event.
|
EXTERNAL_CHANGE:String = "externalChange"
[static] External change event.
|
INIT:String = "init"
[static] Init event.
|
INTERNAL_CHANGE:String = "internalChange"
[static] Internal change event.
|
Property detail
parameterNames
parameterNames:Array
[read-only]The parameters names of this event.
parameters
parameters:Object
[read-only]The parameters of this event.
path
path:String
[read-only]The path of this event.
pathNames
pathNames:Array
[read-only]The folders in the deep linking path of this event.
target
target:Object
[read-only]The target of this event.
type
type:String
[read-only]The target of this event.
value
value:String
[read-only]The value of this event.
Method detail
SWFAddressEvent
public function SWFAddressEvent(type:String)
Creates a new SWFAddress event.
- Parameters
type:String
— Type of the event.
clone
public override function clone():Event
Clones this event.
- Returns
Event
Constant detail
CHANGE
public static const CHANGE:String = "change"
Change event.
EXTERNAL_CHANGE
public static const EXTERNAL_CHANGE:String = "externalChange"
External change event.
INIT
public static const INIT:String = "init"
Init event.
INTERNAL_CHANGE
public static const INTERNAL_CHANGE:String = "internalChange"
Internal change event.
'ActionScript > AS3.0' 카테고리의 다른 글
MP3 Player (0) | 2012.11.15 |
---|---|
Message Queueing (0) | 2012.07.16 |
호 그리기 (drawArc). ASCBLibrary (4) | 2012.03.11 |
drawTriangle활용 - FoloderEffect (0) | 2012.01.19 |
표시객체의 3d속성 활용 후 뭉개지는 현상 (0) | 2012.01.09 |