Se siete alla ricerca di un modo per utilizzare il cookie sul SharedObjects Flex può essere utile per coloro che non sanno SharedObjects è molto facile da usare e ha le seguenti caratteristiche:
Come il cookie è un file generato sulla macchina dell'utente finale;
Ha estensione. Sun;
Non Cookie ... non aiutano "pulire il Cookie" (senza scherzi a leggere questa frase
) Browser ... per la pulizia deve essere programmato e inserito nella domanda di flex ... il caso con il chiaro () dell'oggetto istanziato come SharedObjects; Come Cookie End SharedObjects L'utente può bloccare o limitare le sue dimensioni;
possono essere oggetti complessi che salvare il file ... solo che non può avere metodi.
Ti faccio vedere un semplice esempio di come utilizzare questa classe, l'idea è di fare una sorta di Flex profili utente ha in 3 stati e l'ultimo era in prima di chiudere il browser, che è aperto. Lasciate che il semplice codice:
Application.mxml
- encoding = "utf-8" ? > Xml version = "1.0" encoding = "utf-8"?
- layout = "absolute" width = "400" height = "300" <mx: Application xmlns: mx = "http://www.adobe.com/2006/mxml" layout = "absolute" width = "400" height = "300"
- viewSourceURL = "srcview/index.html" > creationComplete = "init ()" viewSourceURL = "srcview / index.html">
- <MX :states>
- > <MX Nome :State = "state2">
- name = "label" value = "State Principal" /> <MX Target :SetProperty = "{button1}" name = value = "label" /> "Principal Stato"
- name = "title" value = "State 2" /> <MX Target :SetProperty = "{panel}" name = value = "Title" "State 2" />
- name = "x" value = "283" /> <MX Target :SetProperty = "{button2}" name = value = "x" /> "283"
- name = "y" value = "54" /> <MX Target :SetProperty = "{button2}" name = value = "y" /> "54"
- name = "click" handler = "mudaState('')" /> <MX Target :SetEventHandler = "{button1}" name = "click" handler = "mudaState('')" />
- </ Mx: State>
- > <MX Nome :State = "state3">
- name = "label" value = "State Principal" /> <MX Target :SetProperty = "{button2}" name = value = "label" /> "Principal Stato"
- name = "x" value = "241" /> <MX Target :SetProperty = "{button2}" name = value = "x" /> "241"
- name = "title" value = "State 3" /> <MX Target :SetProperty = "{panel}" name = value = "Title" "State 3" />
- name = "y" value = "54" /> <MX Target :SetProperty = "{button2}" name = value = "y" /> "54"
- name = "click" handler = "mudaState('')" /> <MX Target :SetEventHandler = "{button2}" name = "click" handler = "mudaState('')" />
- </ Mx: State>
- </ Mx: Stati>
- <mx
= "86" width = "380" height = "120" layout = "absolute" title = "State Principal" id = "panel" > Anello x = "10" y = "86" width = "380" height = "120" layout = "absolute" title = "Stato" id = "panel"> - x = "10" y = "54" id = "button1" click = "mudaState('state2')" /> : Button <MX "State 2" label = "10" x = y = "54" id = "button1" scegliere = "mudaState('state2')" />
- x = "283" height = "22" y = "54" id = "button2" click = "mudaState('state3')" /> <MX Label :Button = "State 3" x = "283" height = "22" y = "54" id = "button2" scegliere = "mudaState('state3')" />
- </ Mx
Ring> - <MX :Script>
- <! [CDATA [
- Profilo pubblico var: SharedObject;
- private function init (): void (
- SharedObject.getLocal profile = ( "profilo");
- if (profile.data.state! = undefined) (
- mudaState (profile.data.state);
- ) Else (
- mudaState ('');
- )
- )
- mudaState private function (stato: String): void (
- Stato this.currentState =;
- Stato profile.data.state =;
- )
- / * Funzione non utilizzata è solo un esempio per pulire il
- il nostro SharedObject * /
- limparProfile private function (): void (
- profile.clear ();
- )
- ]]>
- </ Mx: Script>
- </ Mx: Application>
visto quanto è semplice!
- "profile" ) ; profile = SharedObject. getLocal ( "profilo");
è dove si assegna il valore del profilo, di ricerca SharedObject.getLocal se esiste un file con quel nome e ottiene i valori memorizzati in esso, se esiste in questo momento è creato.
Il resto è da manuale e ci salverà questo aspetto .. rs esempio di lavoro di seguito:
test vi è un cambiamento di stato .. Home per 2 o 3 ... .. chiudi il browser si prega di visitare questo post di nuovo e vi renderete conto che si aprirà nello stato che si erano finalmente ![]()
Poi c'è un accenno di utilizzare il SharedObject ![]()
Cumps.
Popolarità: 24% [?]
Tags: Cookie, FLEX, SharedOjects
Categoria (s): Adobe Flex, Tips










[...] Questo post è stato citato su Twitter da Igor Musardo, Vin
Vi è, ovviamente, molto da sapere di questo, che non sapevo. Penso che hai fatto dei buoni punti e ho segnalibro questa pagina.
Il tuo sito web è eccellente I m gonna bookmark, grazie
Mi piace molto il vostro weblog. Leggerà tutti. Mantenere fino al grande scrittura su di esso. Ty