If you are looking for a way to use the Cookie on flex SharedObjects can be useful for those who do not know SharedObjects is very easy to use and has these features:
As the Cookie is a file generated on the machine End User;
Has extension. Sun;
Not the Cookie ... not help "clean the Cookie" (no jokes to read that sentence
) Browser ... to clean has to be programmed and inserted into the flex application ... the case using the clear () object instantiated as SharedObjects; As the Cookie End User SharedObjects can block or limit its size;
can be complex objects that save file ... just can not have methods.
I'll show you a simple example of how to use this class, the idea is to make a sort of Flex Profiles in the User has 3 states and the last he was in before I close the browser that is open. Let the simple code:
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 :State name = "state2">
- name = "label" value = "State Principal" /> <MX :SetProperty target = "{button1}" name = value = "label" /> "State Principal"
- name = "title" value = "State 2" /> <MX :SetProperty target = "{panel}" name = value = "Title" "State 2" />
- name = "x" value = "283" /> <MX :SetProperty target = "{button2}" name = value = "x" /> "283"
- name = "y" value = "54" /> <MX :SetProperty target = "{button2}" name = value = "y" /> "54"
- name = "click" handler = "mudaState('')" /> <MX :SetEventHandler target = "{button1}" name = "click" handler = "mudaState('')" />
- </ mx: State>
- > <MX :State name = "state3">
- name = "label" value = "State Principal" /> <MX :SetProperty target = "{button2}" name = value = "label" /> "State Principal"
- name = "x" value = "241" /> <MX :SetProperty target = "{button2}" name = value = "x" /> "241"
- name = "title" value = "State 3" /> <MX :SetProperty target = "{panel}" name = value = "Title" "State 3" />
- name = "y" value = "54" /> <MX :SetProperty target = "{button2}" name = value = "y" /> "54"
- name = "click" handler = "mudaState('')" /> <MX :SetEventHandler target = "{button2}" name = "click" handler = "mudaState('')" />
- </ mx: State>
- </ mx: states>
- <mx
= "86" width = "380" height = "120" layout = "absolute" title = "State Principal" id = "panel" > ring x = "10" y = "86" width = "380" height = "120" layout = "absolute" title = "Home State" id = "panel"> - x = "10" y = "54" id = "button1" click = "mudaState('state2')" /> :Button <MX "State 2" label = "10" x = y = "54" id = "button1" click = "mudaState('state2')" />
- x = "283" height = "22" y = "54" id = "button2" click = "mudaState('state3')" /> <MX :Button label = "State 3" x = "283" height = "22" y = "54" id = "button2" click = "mudaState('state3')" />
- </ mx
Ring> - <MX :Script>
- <! [CDATA [
- public var profile: SharedObject;
- private function init (): void (
- SharedObject.getLocal profile = ( "profile");
- if (profile.data.state! = undefined) (
- mudaState (profile.data.state);
- ) else (
- mudaState ('');
- )
- )
- private function mudaState (state: String): void (
- this.currentState = state;
- profile.data.state = state;
- )
- / * Function not used is just an example to clean the
- our SharedObject * /
- private function limparProfile (): void (
- profile.clear ();
- )
- ]]>
- </ mx: Script>
- </ mx: Application>
saw how simple it is!
- "profile" ) ; profile = SharedObject. getLocal ( "profile");
is where we assign the value of the profile, search SharedObject.getLocal if a file exists with that name and gets the values stored in it, if it exists at the moment is created.
The rest is textbook and we will save this looks .. rs working example below:
test there is a change of state .. Home for 2 or 3 ... .. close your browser please visit this post again and you will realize that it will open in the state that you were finally ![]()
Then there is a hint to use the SharedObject ![]()
Cumps.
Popularity: 16% [?]
Tags: Cookie, FLEX, SharedOjects
Category (s): Adobe Flex, Tips













[...] This post was mentioned on Twitter by Igor Musardo, Vin
There is obviously a lot to know about this, which I did not know. I think you made some good points and I have bookmarked this page.
Your website is excellent I m gonna bookmark, thanks
I like your weblog greatly. Will read all. Keep up to great writing on it. ty