SharedObjects - Cookie per la vostra applicazione Flex

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:

  1. Come il cookie è un file generato sulla macchina dell'utente finale;

  2. Ha estensione. Sun;

  3. 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;

  4. Come Cookie End SharedObjects L'utente può bloccare o limitare le sue dimensioni;

  5. 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

XML:
  1. encoding = "utf-8" ? > Xml version = "1.0" encoding = "utf-8"?
  2. layout = "absolute" width = "400" height = "300" <mx: Application xmlns: mx = "http://www.adobe.com/2006/mxml" layout = "absolute" width = "400" height = "300"
  3. viewSourceURL = "srcview/index.html" > creationComplete = "init ()" viewSourceURL = "srcview / index.html">
  4. <MX :states>
  5. > <MX Nome :State = "state2">
  6. name = "label" value = "State Principal" /> <MX Target :SetProperty = "{button1}" name = value = "label" /> "Principal Stato"
  7. name = "title" value = "State 2" /> <MX Target :SetProperty = "{panel}" name = value = "Title" "State 2" />
  8. name = "x" value = "283" /> <MX Target :SetProperty = "{button2}" name = value = "x" /> "283"
  9. name = "y" value = "54" /> <MX Target :SetProperty = "{button2}" name = value = "y" /> "54"
  10. name = "click" handler = "mudaState('')" /> <MX Target :SetEventHandler = "{button1}" name = "click" handler = "mudaState('')" />
  11. </ Mx: State>
  12. > <MX Nome :State = "state3">
  13. name = "label" value = "State Principal" /> <MX Target :SetProperty = "{button2}" name = value = "label" /> "Principal Stato"
  14. name = "x" value = "241" /> <MX Target :SetProperty = "{button2}" name = value = "x" /> "241"
  15. name = "title" value = "State 3" /> <MX Target :SetProperty = "{panel}" name = value = "Title" "State 3" />
  16. name = "y" value = "54" /> <MX Target :SetProperty = "{button2}" name = value = "y" /> "54"
  17. name = "click" handler = "mudaState('')" /> <MX Target :SetEventHandler = "{button2}" name = "click" handler = "mudaState('')" />
  18. </ Mx: State>
  19. </ Mx: Stati>
  20. <mx :P = "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">
  21. x = "10" y = "54" id = "button1" click = "mudaState('state2')" /> : Button <MX "State 2" label = "10" x = y = "54" id = "button1" scegliere = "mudaState('state2')" />
  22. 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')" />
  23. </ Mx :P Ring>
  24. <MX :Script>
  25. <! [CDATA [
  26. Profilo pubblico var: SharedObject;
  27. private function init (): void (
  28. SharedObject.getLocal profile = ( "profilo");
  29. if (profile.data.state! = undefined) (
  30. mudaState (profile.data.state);
  31. ) Else (
  32. mudaState ('');
  33. )
  34. )
  35. mudaState private function (stato: String): void (
  36. Stato this.currentState =;
  37. Stato profile.data.state =;
  38. )
  39. / * Funzione non utilizzata è solo un esempio per pulire il
  40. il nostro SharedObject * /
  41. limparProfile private function (): void (
  42. profile.clear ();
  43. )
  44. ]]>
  45. </ Mx: Script>
  46. </ Mx: Application>

visto quanto è semplice!

CODICE:
  1. "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:

Categoria (s): Adobe Flex, Tips


Altri articoli:

Questo sito web utilizza i commenti IntenseDebate, ma non sono attualmente caricati in quanto sia il vostro browser non supporta JavaScript, o non hanno carichi abbastanza veloce.

to “SharedObjects – Cookie para sua app flex” 4 risposte a "SharedObjects - Cookie per la vostra applicazione Flex"

  1. DeShawn Trudics ha detto:

    Vi è, ovviamente, molto da sapere di questo, che non sapevo. Penso che hai fatto dei buoni punti e ho segnalibro questa pagina.

  2. Lang Perriello ha detto:

    Il tuo sito web è eccellente I m gonna bookmark, grazie

  3. Piedad Machinskij ha detto:

    Mi piace molto il vostro weblog. Leggerà tutti. Mantenere fino al grande scrittura su di esso. Ty

Lasci una risposta