how to peserve location of any object ?

  • aktajay
  • Born
  • Born
  • aktajay
  • Posts: 1

Post 3+ Months Ago

hi
Actionscript is new for me .can u help me out to solve this problem:

prob :I have a circle that is dragable .if i drag that circle any position and close swf .end when i open that file again position of circle should same as that closing time

thanks in advance
aktajay
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

SOL

I'd love to just leave it at that so you'ld think I mean S*** Outta Luck. :lol:

Alot of people call them "Flash Cookies", you can use them to save properties of your objects between visits.

Shared Object Library, or SOL file.
The reference on them in Flash 8 is in,

Actionscript 2.0 Classes -> Movie -> SharedObject

Here's a basic implementation of a "Flash Cookie" from the documentation.

Quote:
The following example creates a shared object that stores text that is typed into a TextInput component instance. The resulting SWF file loads the saved text from the shared object when it starts playing. Every time the user presses Enter, the text in the text field is written to the shared object. To use this example, drag a TextInput component onto the Stage, and name the instance myText_ti. Copy the following code into the main Timeline (click in an empty area of the Stage or press Escape to remove focus from the component):
Code: [ Select ]
// Create the shared object and set localpath to server root.
var my_so:SharedObject = SharedObject.getLocal("savedText", "/");

// Load saved text from the shared object into the myText_ti TextInput component.
myText_ti.text = my_so.data.myTextSaved;

// Assign an empty string to myText_ti if the shared object is undefined
// to prevent the text input box from displaying "undefined" when
// this script is first run.
if (myText_ti.text == undefined) {
  myText_ti.text = "";
}

// Create a listener object and function for <enter> event
var textListener:Object = new Object();
textListener.enter = function(eventObj:Object) {
  my_so.data.myTextSaved = eventObj.target.text;
  my_so.flush();
};

// Register the listener with the TextInput component instance
myText_ti.addEventListener("enter", textListener);
  1. // Create the shared object and set localpath to server root.
  2. var my_so:SharedObject = SharedObject.getLocal("savedText", "/");
  3. // Load saved text from the shared object into the myText_ti TextInput component.
  4. myText_ti.text = my_so.data.myTextSaved;
  5. // Assign an empty string to myText_ti if the shared object is undefined
  6. // to prevent the text input box from displaying "undefined" when
  7. // this script is first run.
  8. if (myText_ti.text == undefined) {
  9.   myText_ti.text = "";
  10. }
  11. // Create a listener object and function for <enter> event
  12. var textListener:Object = new Object();
  13. textListener.enter = function(eventObj:Object) {
  14.   my_so.data.myTextSaved = eventObj.target.text;
  15.   my_so.flush();
  16. };
  17. // Register the listener with the TextInput component instance
  18. myText_ti.addEventListener("enter", textListener);


In cases where for whatever reason the visitor has Flash Cookies disabled, (sometimes people disable them for no good reason & don't realize it) there is still the "flash.external.ExternalInterface" class that can give you access to traditional Javascript based cookie functions if browser based cookies are still available.

When dealing with the ExternalInterface class in a web browser, data types passed for "functionParamaters" are automaticly converted to Javascript types from Actionscript types.

Code: [ Select ]
import flash.external.ExternalInterface;

ExternalInterface.call("JavascriptCookieFunction", functionParamaters);
  1. import flash.external.ExternalInterface;
  2. ExternalInterface.call("JavascriptCookieFunction", functionParamaters);

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 5 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.