PHP에는이를 저장하는 데 기반을 둔 setcookie
함수가 있습니다. 플래시에서 가능합니까? 가능하면 어떻게 될까요? 가치를 저장하고 싶습니다.플래시 또는 플렉스에 쿠키 저장 가치를 부여 할 수 있습니까?
답변
예. Flash 응용 프로그램은 사용자의 컴퓨터에 최대 100KB의 데이터 (기본적으로)를 저장할 수 있습니다. 이것은 플래시 쿠키 (브라우저 쿠키와 별도)에 저장됩니다. 사용자는 플래시 응용 프로그램을 마우스 오른쪽 버튼으로 클릭하고 설정으로 이동하여 저장할 수있는 응용 프로그램의 양을 조정할 수 있습니다. 당신은 "플래시 SharedObject를"
하는 것은 사용자가 데이터를 넣어하지 않는 경우를 처리 할 준비가되어 있는지 확인을 인터넷 검색으로 더 많은 정보를 얻을 수 있습니다 http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/SharedObject.html
: 여기
는 AS3의 SharedObject를 API입니다 SharedObjects에 저장합니다. 기술에 능숙한 사용자가 자신의 개인 정보를 염려하는 인기있는 트렌드가되었습니다.행운을 빈다.
우선 : PHP가 서버에서 실행되므로 쿠키를 설정하기 위해 필요한 HTTP 헤더를 보낼 수 있습니다. Flash는 클라이언트의 브라우저에서 실행되므로 동일하게 수행 할 수 없습니다.
그러나 flash.external.ExternalInterface
을 사용하고 쿠키를 가져오고 설정하는 JavaScript 함수를 호출하여 flash/flex에서 쿠키에 액세스하고 저장하는 방법이 있습니다.
package de.slashslash.util {
import flash.external.ExternalInterface;
/**
* The Cookie class provides a simple way to create or access
* cookies in the embedding HTML document of the application.
*
*/
public class Cookie {
/**
* Flag if the class was properly initialized.
*/
private static var _initialized:Boolean = false;
/**
* Name of the cookie.
*/
private var _name:String;
/**
* Contents of the cookie.
*/
private var _value:String;
/**
* Flag indicating if a cookie was just created. It is <code>true</code>
* when the cookie did not exist before and <code>false</code> otherwise.
*/
private var _isNew:Boolean;
/**
* Name of the external javascript function used for getting
* cookie information.
*/
private static const GET_COOKIE:String = "cookieGetCookie";
/**
* Name of the external javascript function used for setting
* cookie information.
*/
private static const SET_COOKIE:String = "cookieSetCookie";
/**
* Javascript code to define the GET_COOKIE function.
*/
private static var FUNCTION_GET_COOKIE:String =
"function() { " +
"if (document." + GET_COOKIE + " == null) {" +
GET_COOKIE + " = function (name) { " +
"if (document.cookie) {" +
"cookies = document.cookie.split('; ');" +
"for (i = 0; i < cookies.length; i++) {" +
"param = cookies[i].split('=', 2);" +
"if (decodeURIComponent(param[0]) == name) {" +
"value = decodeURIComponent(param[1]);" +
"return value;" +
"}" +
"}" +
"}" +
"return null;" +
"};" +
"}" +
"}";
/**
* Javascript code to define the SET_COOKIE function.
*/
private static var FUNCTION_SET_COOKIE:String =
"function() { " +
"if (document." + SET_COOKIE + " == null) {" +
SET_COOKIE + " = function (name, value) { " +
"document.cookie = name + '=' + value;" +
"};" +
"}" +
"}";
/**
* Initializes the class by injecting javascript code into
* the embedding document. If the class was already initialized
* before, this method does nothing.
*/
private static function initialize():void {
if (Cookie._initialized) {
return;
}
if (!ExternalInterface.available) {
throw new Error("ExternalInterface is not available in this container. Internet Explorer ActiveX, Firefox, Mozilla 1.7.5 and greater, or other browsers that support NPRuntime are required.");
}
// Add functions to DOM if they aren't already there
ExternalInterface.call(FUNCTION_GET_COOKIE);
ExternalInterface.call(FUNCTION_SET_COOKIE);
Cookie._initialized = true;
}
/**
* Creates a new Cookie object. If a cookie with the specified
* name already exists, the existing value is used. Otherwise
* a new cookie is created as soon as a value is assigned to it.
*
* @param name The name of the cookie
*/
public function Cookie(name:String) {
Cookie.initialize();
this._name = name;
this._value = ExternalInterface.call(GET_COOKIE, name) as String;
this._isNew = this._value == null;
}
/**
* The name of the cookie.
*/
public function get name():String {
return this._name;
}
/**
* The value of the cookie. If it is a new cookie, it is not
* made persistent until a value is assigned to it.
*/
public function get value():String {
return this._value;
}
/**
* @private
*/
public function set value(value:String):void {
this._value = value;
ExternalInterface.call(SET_COOKIE, this._name, this._value);
}
/**
* The <code>isNew</code> property indicates if the cookie
* already exists or not.
*/
public function get isNew():Boolean {
return this._isNew;
}
}
}
wooooow 무엇 답변입니까? . 나는 그것을 좋아한다. 그것은 나에게 매우 유용합니다. Simon Lehmann 대단히 감사합니다. –
를 실제 코드 예를 들어 :
나는 아주 쉽게이 작업을 수행하는 클래스를 개발 한 두 번 게시하고 저장하는 방법을 참조하십시오
import flash.net.SharedObject;
// get/create the shared object with a unique name.
// If the shared object exists this grab it, if not
// then it will create a new one
var so: SharedObject = SharedObject.getLocal("UniqueName");
// the shared object has a propery named data, it's
// an object on which you can create, read, or modify
// properties (you can't set the data property itself!)
// you can check to see if it already has something set
// using hasOwnProperty, so we'll check if it has a var
// use it if it does, or set it to a default if it doesn't
if (so.data.hasOwnProperty("theProp"))
{
trace("already has data! It reads: " + so.data.theProp);
}
else
{
so.data.theProp = "default value";
so.flush(); // flush saves the data
trace("It didn't have a value, so we set it.");
}
플래시이를 붙여 넣습니다 데이터 :)
- 1. 플렉스에 플래시 바를 건네기
- 2. 멋있는 방법으로 가치를 매칭 할 수 있습니까?
- 3. 쿠키 저장
- 4. 코드를 통한 플래시 쿠키 삭제
- 5. Javascript는 web.config AppSettings에서 가치를 얻을 수 있습니까?
- 6. 인터넷 연결을 확인할 수있는 방법 또는 플렉스에
- 7. 세션 또는 요청에서 가치를 얻으시겠습니까?
- 8. 오라클 클러스터 객체에 권한을 부여 할 수 있습니까?
- 9. 권한 부여 저장 프로 시저
- 10. jQuery - 쿠키 저장/사용
- 11. mvc 권한 부여 또는 인증
- 12. 플래시 빌더 내부에서 플래시 cs4 프로젝트를 디버그 할 수 있습니까?
- 13. 쿠키 저장 안함
- 14. HTTP 헤더에서 쿠키 저장
- 15. 안드로이드 쿠키 저장
- 16. 플래시 요소를 비활성화 할 수 있습니까?
- 17. S3로 플래시 의사 스트리밍을 할 수 있습니까?
- 18. PHP는 플래시 양식에 로그인 할 수 있습니까?
- 19. 개체가 자체 이벤트를 플래시 할 수 있습니까?
- 20. 플래시 프로젝터의 창을 최대화 할 수 있습니까?
- 21. UIWebView에서 스크롤 막대를 플래시 할 수 있습니까
- 22. 플렉스에 SVG 표시하기
- 23. 플래시 [: notice]가 플래시 [: error]의 위 또는 앞쪽에 나타나게 할 수 있습니까?
- 24. 플래시 게임 데이터 저장
- 25. Wordpress 익스플로잇은 서버에 루트 액세스 권한을 부여 할 수 있습니까?
- 26. 앱 수준에서 Super_user 권한을 어떻게 부여 할 수 있습니까?
- 27. 접두사와 와일드 카드가있는 데이터베이스에 액세스 권한을 부여 할 수 있습니까?
- 28. 내 코드의 소유권을 다른 사람에게 어떻게 부여 할 수 있습니까?
- 29. 플렉스에 SWFLoader하면 Event.COMPLETE
- 30. 임 플렉스에 3
조지 Deglin 감사합니다. 각 시간은 매우 명확합니다. 나는 많은 것을 좋아한다. :) :) –