Problem Saving Shared Object On Linux
Hi,
My requirement is to save Shared object on the Linux machine and retrieve the data back for later use. As I have made the required changes in my code the same works fine on the Windows platform but behaves strangly on the Linux platform.
In class named "save.as" I am using the following code:
Code: var objRecordSO:SharedObject = SharedObject.getLocal("record"); objRecordSO.data.RecordData = _strFileData; var bSuccess = objRecordSO.flush(1024 * 100); where _strFileData is the data being sent by some other function.
trace(bSuccess); returns true on the Linux machine but while retrieving the data in userProfile.as file (some other class file) does not always returs same data as been saved. It sometimes returns no data at all.
Can anyone through some light on the erratic behavior of Shared Object on Linux. Note that the same code always runs perfect on the Windows machine.
thanks.
ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 04-26-2007, 05:46 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Problem Saving Shared Object On Linux
Hi,
My requirement is to save Shared object on the Linux machine and retrieve the data back for later use. As I have made the required changes in my code the same works fine on the Windows platform but behaves strangly on the Linux platform.
In class named "save.as" I am using the following code:
Code:
var objRecordSO:SharedObject = SharedObject.getLocal("record");
objRecordSO.data.RecordData = _strFileData;
var bSuccess = objRecordSO.flush(1024 * 100);
where _strFileData is the data being sent by some other function.
trace(bSuccess); returns true on the Linux machine but while retrieving the data in userProfile.as file (some other class file) does not always returs same data as been saved. It sometimes returns no data at all.
Can anyone through some light on the erratic behavior of Shared Object on Linux. Note that the same code always runs perfect on the Windows machine.
thanks.
Local Shared Object On Linux ?
Can Flash's Local Shared Object be used on Linux machines (Mozilla or Opera)? Because i successfully scripted this for Windows but it failed to save files on computers with Linux as its operating system.
Save And Retrieve Shared Object On Linux
Hi,
I am using flash shared object to save certain user information on the Linux platform and using the same data whenever the same user re-login into the application. I have observed that as the number of users (i.e. shared objects) increase in number (approx 15-20 users) the application is no longer able to retrieve the already saved shared object for that user. However, the same application works perfectly on the Windows platform (I have created atleast 30-40 users on win but application does work fine.)
I am using the following code for the SO save functionality:
Code:
var objRecordSO:SharedObject = SharedObject.getLocal("record", "/");
objRecordSO.data.username = "Komal";
objRecordSO.data.score = 30;
var bSuccess = objRecordSO.flush(1024 * 100);
Please advice.
Save And Retrieve Shared Object On Linux
Hi,
I am saving certain user information using flash shared object and using the same data whenever the same user re-login into the application. I have observed that, on the Linux platform, as the number of users (i.e. shared objects) increases (approx 15-20 users) the application is no longer able to retrieve the already saved data of the user. Which means that if the same user logins into the application, the application get closed automatically instead of redirecting him to his page.
However, the same application works perfectly on the Windows platform. I have created atleast 30-40 users on windows but application does work fine.
I am using the following code for the SO save functionality:
Code:
var objRecordSO:SharedObject = SharedObject.getLocal("record", "/");
objRecordSO.data.username = "Komal";
objRecordSO.data.score = 30;
var bSuccess = objRecordSO.flush(1024 * 100);
Can anyone provide me a reliable solution for Linux as well...
Shared Object Not Saving?
Here's the code. It appears that it will not save te cookie because on a return visit, it still triggers the undefined... any ideas? I've done this before and never had trouble, but something is obviously wrong:
get_flookies = function () {
_root.flookies = SharedObject.getLocal("preferences");
if (_root.flookies.desktop == undefined) {
trace("no desktop");
_root.flookies.desktop = _root.pref_pane.thumb0.name;
//_root.flookies.flush();
}
if (_root.flookies.volume == undefined) { trace("no volume");
_root.flookies.volume = 50;
//_root.flookies.flush();
}
};
What SHOULD happen is on the first visit, we'll create the preferences file and check to see if it has any values from a previous visit. If so, we'll use them and if not we need to set the defaults.
If anyone has any ideas, I'd appreciate the help!
Saving XML Into Shared Object Etc...
I'm setting up a system that will pull data from an XML doc, allow users to edit the attributes of items with a clcik, and then save it into a shared object on the computer (this will only be running on one machine).
There will also be a basic RESET function that at any time will load the data back in from the original XML and overwrite their SharedObject data.
But I'm having trouble figuring out how this SharedObject works. Once I've loaded my XML into an XML object in my movie, how do I then copy that data into the SharedObject?
Any help is greatly appreciated!
Shared Object Not Saving?
hey all. i have two different swfs. one sets a shared object and one is supposed to read it. it is always coming back as undefined (I'm not permitted to have a containing .swf, btw)
writer of SO:
var user = SharedObject.getLocal("userData");
var cookieValue=_root[mcAtTarget0]._name.charAt(10)+_root[mcAtTarget0]._name.charAt(11);
user.data.first=cookieValue;
user.flush();
reader:
user = SharedObject.getLocal("userData");
if (user.data.first == undefined){
text_txt.text = "not here";
} else {
text_txt.text = user.data.first;
}
what am i not getting? thanks!
Saving Text With 'shared Object'
can anyone tell me for sure that you can use the new 'shared object' feature of flash to save variables to a txt file to the users hard drive. this will be done offline from a projector. the text file will need to be somewhat cleanly formatted so the user can understand it.
i think this macromedia article suggests that it can be done, but i need a definitive answer.
thanks!!
corey
Saving Bitmaps To A Shared Object?
Hi, I have a simple question: Is it possible to save a bitmap or an array of bitmaps to a shared object?
I've looked around for this and I don't think it's possible but is there anyway around it?
Saving Bitmaps To A Shared Object?
Hi, I have a simple question: Is it possible to save a bitmap or an array of bitmaps to a shared object?
I've looked around for this and I don't think it's possible but is there anyway around it?
Shared Object Not Saving - Any Ideas?
Here's the code. It appears that it will not save te cookie because on a return visit, it still triggers the undefined... any ideas? I've done this before and never had trouble, but something is obviously wrong:
get_flookies = function () {
_root.flookies = SharedObject.getLocal("preferences");
if (_root.flookies.desktop == undefined) {
trace("no desktop");
_root.flookies.desktop = _root.pref_pane.thumb0.name;
//_root.flookies.flush();
}
if (_root.flookies.volume == undefined) { trace("no volume");
_root.flookies.volume = 50;
//_root.flookies.flush();
}
};
What SHOULD happen is on the first visit, we'll create the preferences file and check to see if it has any values from a previous visit. If so, we'll use them and if not we need to set the defaults.
If anyone has any ideas, I'd appreciate the help!
Saving/loading By Shared Object File
I want to save my variables that are stored in a dynamic text field into a shared object file by clicking on my "save" button, and then load my variable data into the dynamic text fields from that shared object file using the "load" button.
When I click on the save button I dont see the shared object file being created. I had read the tutorials but cant seem to figure the thing I am doing wrong. Thats why I am including my fla file
(the fls file I made is very simple) so you can check it out. My code looks like this:
PS Could you please modify the fla file (if you find a programmnig misteke there) and attach the modified working file into your post, and tell me what I did wrong. Thanks for help!
//SAVE BUTTON
on (release) {
// create the local shared object
pos = sharedobject.getLocal("gamesave");
// save the variable number data value
pos.data.money = "money";
pos.data.week = "week";
// commit the change to disk
so.flush();
}
//LOAD BUTTON
on (release) {
// open the local shared object
pos = sharedobject.getLocal("gamesave");
// read the variable number data we saved previously
money = pos.data.money;
week = pos.data.week;
// spit it out so we can see it
trace(pos.data.money);
trace(pos.data.week);
}
Shared Object (saving Frame States)
Hello...
I'm fairly new to AS & especially new to SOs...
I am working on an application that (on 16 different frames) has various loaded SWFs that have selections for the user to make. These SWFs are basically 6 frame animations - first frame for the roll over effect, and the remaining 5 frames for the actual selection. Therefore, the 'selection' is basically a gotoandstop on a certain frame. Once the user makes his selections for each item, he will then move onto another (of the 16) frame to make further selections. As of right now, the selections would revert back to their default state (frame 1 of 6 - rollover state) when they moved from one frame to another and back.
What I'm hoping to do is this:
A frame action that upon entering/exiting one of the 16 frames, would save and/or load a Shared Object that has the states (frame number) of all the loaded SWFs for that frame.
I hope this was clear...thanks in advance!!!
Saving Tons Of Vars W/ Shared Object, And Arrays?
(Using actionscript 2) I would want to know a way to write a code that would save tons of variables in a shared object, using for loops, to avoid having to write all the code for every variables, as this:
sharedobject.var1 = something
sharedobject.var2 = something
sharedobject.var3 = something
sharedobject.var4 = something
sharedobject.var5 = something
sharedobject.var6 = something
sharedobject.var7 = something
sharedobject.var8 = something
...
sharedobject.var100 = something
And I would like to do it this way, with a variable that increases to change the name of the variable to be saved:
for(number=0; number<101; number++) {
"sharedobject."+number = something
}
The problem is that I can't write "sharedobject."+number =....., because I can't use "+" on the left side of the assigment.
So what then should I do?
I think I should use arrays, but I don't know how to make it work properly, and if you find a way, please make sure it works.
Sandbox Violation When Saving MovieClip To Shared Object
I have a Library symbol called Panel. My movie allows the user to create and organize many Panels on the stage. I save them to a SharedObject so the user can pick up where he left off.
Panel extends MovieClip, which has the property transform. If I simply use registerClassAlias("Panel", Panel), I get a jumble of errors about converting generic Objects to SoundTransforms, ColorTransforms, etc.. As long as I don't try to access Panel.transform, there is no need for concern; however, I need to allow the user to change the color of the panel. The easiest way to do this ought to be accessing the transform property, but I am running into problems.
Code:
registerClassAlias("Transform", Transform); // errors "Argument count mismatch. Got 0, expected 1"
registerClassAlias("Transform", flash.geom.Transform)) or registerClassAlias("Transform", Class(Transform) //errors"*** Security Sandbox Violation *** SecurityDomain "myMovie.swf' tried to access Player UI context"
For now, I can create Shapes in different colors to workaround the problem. There has to be a better way though. What is this about accessing the Player UI context? How can I save flash.geom.Transform to a SharedObject?
Shared Object / Saving & Retrieving Arrays Problem
I have used SO's to save and retrieve simple variables successfully, but I am a problem saving and retreiving array data in the following example:
http://www.nottingham.ac.uk/home/ccz...llRenderer.fla
A user selects several options using radio buttons. All that happens is that the SO should store in memory which buttons the user clicked on. If run through flash with the output window, you can see that when the save button is clicked, the data is saved. But when you load the activity a second time, the array data that was stored in the SO only gets recalled as 'undefined'.
Can someone suggest how I might fix this please? It may be to do with how I am moving the array data around, I am not sure.
Thanks
Could A MovieClip Be Stored And Shared In A Remote Shared Object?
Let's say there are two clients connected via FMS,
and have a remote shared object SO.
When one client has a movieclip mc and sets,
SO.data["movie"] = mc;
is it possible for the other client to render
the content of mc, after SO synchronization,
by simply doing:
mc = SO.data["movie"]:
???
Shared Objects. How To Undo Shared Object
Hi guys,
Basicaly I created a simple login function by following the shared objects tutorial (http://www.kirupa.com/developer/mx/sharedobjects.htm).
I wanted a button placed on my wlecome screen allowing the user to go back to the creating screen of the shared objects.
So basically another shared object can be made.
Any Ideas?
Saving To Shared Objects
Let me try and build the scenario. I have a SO entitled "TDS_Log" that I set up like this:
ActionScript Code:
activity1 = SharedObject.getLocal("TDS_Log");
I add values to the SO like this:
ActionScript Code:
activity1.data.completion = "true"
activity1.data.activityType = "drag and drop"
I then run a conditional statement to ensure it's saved succesfully.
My question is can I write to this SO from another swf without overwriting the existing values? So I'd have something like this:
ActionScript Code:
activity2 = SharedObject.getLocal("TDS_Log");
ActionScript Code:
activity2.data.completion = "true"
activity2.data.activityType = "drag and drop"
Shared Objects.....saving To A Server?
CAN ANYONE ANSWER ME:
Can "shared objects" send info to a server .swf
instead of saving info into the user's computer?
I am wanting to make a real-time chat with flash.
any-help would be very much thanked
Saving Colour With Shared Objects?
Hi,
I am developing a uk map application that all the regions colours can be changed.
So far so good, the problem i'm having is trying to get each region to save to a SO so that when the .swf is next opened the changed regions keep their colour.
Any help on saving a MC's colour would be much appreciated.
Thanks,
Phil
[Flash CS3] Saving Datagrids In Shared Objects
Hello everyone,
I am trying to make a phonebook where it saves the data they have entered into the Datagrid. This is my script:
Quote:
function dataGridFunction() {
var characters:Array = new Array(new Array("DK", "NH", "111-111-1111"), new Array("DK", "NH", "111-111-1111"));
for (var i = 0; i<characters.length; i++) {
var firstName:String = characters[i][0];
var lastName:String = characters[i][1];
var phonenumber:String = characters[i][2];
var email:String = characters[i][3];
dataGridMain.addItem({First:firstName, Last:lastName, Phonehonenumber, Email:email});
}
dataGridMain.setStyle("fontFamily","Verdana");
dataGridMain.setStyle("headerColor","0xA6CBDD");
dataGridMain.setStyle("alternatingRowColors",["0xF0F0F0", "0xFFFFFF"]);
dataGridMain.setStyle("rollOverColor","0xDCEBF1");
dataGridMain.setStyle("selectionColor","0xFFF97D") ;
dataGridMain.setStyle("selectionDuration",300);
}
function dataGridFunction1() {
var firstName:String = characters[i][0];
var lastName:String = characters[i][1];
var phonenumber:String = characters[i][2];
var email:String = characters[i][3];
dataGridMain.addItem({First:firstName, Last:lastName, Phonehonenumber, Email:email});
dataGridMain.setStyle("fontFamily","Verdana");
dataGridMain.setStyle("headerColor","0xA6CBDD");
dataGridMain.setStyle("alternatingRowColors",["0xF0F0F0", "0xFFFFFF"]);
dataGridMain.setStyle("rollOverColor","0xDCEBF1");
dataGridMain.setStyle("selectionColor","0xFFF97D") ;
dataGridMain.setStyle("selectionDuration",300);
}
so = SharedObject.getLocal("dataset1");
if (so.data.name != undefined) {
dataGridFunction1();
//dataGridMain.onLoad = function() {
dataGridMain.loadFromSharedObj("dataset");
//};
} else {
dataGridFunction();
so.data.name = "DKNH";
}
var row = dataGridMain.length;
//trace (row);
var column = dataGridMain.columnCount;
//trace (column);
var deleteselected = dataGridMain.selectedIndex;
this.addrow.onRelease = function() {
dataGridMain.addItem(item);
};
this.deleterow.onRelease = function() {
dataGridMain.removeItemAt(deleteselected);
//trace (row);
};
this.deleteallrows.onRelease = function() {
dataGridMain.removeAll();
};
this.close.onRelease = function() {
fscommand("quit", "");
};
this.addcolumn.onRelease = function() {
if (columnname != "" && columnname != undefined) {
dataGridMain.addColumn(columnname);
}
};
this.deletecolumn.onRelease = function() {
dataGridMain.removeColumnAt(column-1);
//trace (column);
};
this.deleteallcolumns.onRelease = function() {
dataGridMain.removeAllColumns();
};
this.a.onRelease = function() {
dataGridMain.spaceColumnsEqually();
};
this.save1.onRelease = function() {
dataGridMain.saveToSharedObj("dataset");
};
Please help me to make this work.
When I click save, I don't think it actually saves it on the SO because when I close it and then open it again, it didn't save it.
All help is appreciated!
Saving State With Local Shared Objects...Is This Right?
OK here is what I am trying to do with Shared Objects. I have a swf with the basic navigation 3 buttons (button1, button2, button3). This is called home.swf
each of these buttons calls a loadMovie action to load its respective page.
button 1 loads page1.swf
button 2 loads page2.swf
button 3 loads page3.swf
all load on level 2
All these swf files are in the same folder.
so simple enough. Now what I what to do with Shared Object code is to maintain state. So if I am in the site and reading on page 2....then quit the browser or go to another site....and then come back later ..it will load with page 2 or whatever was last on the screen.
So I am figuring that I need to place the "save" code on the individual page and the "retrieve" or "load" code on home.swf. Right?
Here is the code I have on the page#.swf files:
var local_data = SharedObject.getLocal("test", "/");
local_data.data=_level2; //not sure what goes here
local_data.flush(10000);
and on the home.swf I have:
var local_data = SharedObject.getLocal("test", "/");
local_data.data;
So tell me...am i way off here?? I understand the concept fine...but as usual the syntax stops me in my tracks....any help would be greatly appreciated....
Loading/Saving/Modifying XML Via Shared Objects
I'm trying to create a flash application which will let me load in an XML file, allow me to modify the contents of it, then save the modified data into a shared object to be loaded in later.
So far i'm able to load the XML, into a tree component. I can save the dataProvider bound to my XML tree into a shared object. I can't seem to load the saved data back into the tree though.
Does anyone have a sample application they can send me which performs the functions of saving loading and modifying data within flash using sharedobjects.
Thanks
-VinnyC
Loading/Saving/Modifying XML Via Shared Objects
I'm trying to create a flash application which will let me load in an XML file, allow me to modify the contents of it, then save the modified data into a shared object to be loaded in later.
So far i'm able to load the XML, into a tree component. I can save the dataProvider bound to my XML tree into a shared object. I can't seem to load the saved data back into the tree though.
Does anyone have a sample application they can send me which performs the functions of saving loading and modifying data within flash using sharedobjects.
Thanks
-VinnyC
Saving Live Video An Audio Shared Component
I want to know if it is possible to saver the Live Video And Audio Shared Components to HD on the server for later streaming or reporting.
What i want is to save all the conversations taken in a chatroom via Video Chat and be able to check them Later.
How's this done and where are they saved.
Saving Object Position With PHP
Hey guys, I've got two questions, any help would be greatly appreciated.. firstly about Movie Clips within Flash...
I'm in the middle of making a car racing game (very basic) where the user can edit their own map. The user can drag and drop the finish line and car to any part of the stage before the race starts. It all works untill the end when the user finishes, I want to have a "race this map again" button, but I cant work out how to save the locations of where the finishline and car were dragged in the previous frame. Any answers?
My second question is a bit more advanced and I doubt I'll get it finished in time for my deadline in 2 weeks, anyway, i also want to setup a "save my map and top scores" option that will have to be done with PHP and the same problem applies. The bulk of the map editing is done with a drawing api. I've been told that it is possible to save drawing locations (and there are a few sites that where you can save drawn images) the only thing i wasn't sure of is whether the drawn image would keep its instance name and allow other people to race a map drawn by a different person (the car hittests with the drawn lines you see).
I hope you understand my problem and can point me in the right direction... Thanks in advance,
Chris
Saving Xml Object As Xml File
Hi,
I've loaded my .xml file into an XML object using URLLoader; and URLRequest. I have transfered some of the data into an array and to a data grid, manipulated it etc.
I now have this XML object with updated records. So how do I save it back to a .xml file so the system can re-read the records/data in it when required?
Thank you
Saving Xml Object As Xml File
Hi,
I've loaded my .xml file into an XML object using URLLoader; and URLRequest. I have transfered some of the data into an array and to a data grid, manipulated it etc.
I now have this XML object with updated records. So how do I save it back to a .xml file so the system can re-read the records/data in it when required?
I have tried using the sharedObject class but this only seems to save a .sol file which isn't what I need.
Thank you
Saving Object To Server For Later Use
Hello All. I am looking for a way to save an object to the server for later use.
I have an object in my app that is basically a collection of multi-dimentional arrays.
These arrays are saving sessions data, as each 'session' is different for each user.
I would like to be able to save this object to the server, so that it can be loaded back into flash later. I dont want to use shared objects becuase it needs to be accessible anywhere.
i dont necessarily want to parse out the object to an xml or because it will have to be converted back into the object, and the arrays are pretty complicated.
is there any way to save the object as a binary file on the server, then reload it? Or is there another way to do this? Basically im looking for a shared object functionality, only the shared object is on the server not local.
Thanks for any help or insight.
Q
PS, i understand saving text and xml to a file using php, but im looking for a more direct method, like binary.
Shared Object
Hi,
Has anyone used the Shared Object in Falsh MX. I tried it but nothing seems to be saved when I restart the movie. Shared Object should store information on the users local computer like a cookie. I'm using it to store text entries in an address book application, but when I go back to the app all my entries are gone. Is there any way to see if the Shared Oblect is working fine?
Shared Object
Could some one please tell me where a good tutorial is for shared objects i want to be able to specify the location not use a cookie! or just send me the script.
Many Thanks
Michael
$ Will Pay For Shared Object Help $
I've created a standalone quiz that tallies and scores performance. I need to create a shared object element that tracks the users scores in a list box. So I can review the perfmance data. This quiz will go on a laptop and will taken between 100 and 300 times I suspect. The quiz can be viewed <a href="http://38.181.236.4/~chimes/quiz/quiz.html" >here</a> and I created a page where the list box would reside, which can be reached by pressing a hidden button in the top right corner of the quiz frame.
I'm on a 48 hour deadline and have other things to work on, and will try to complete it on my own, but would pay for help at this point, as I'm not familiar with .so stuff yet. If you're interested: chimes@subsystem.com
Thanks
Has Anybody Used The Shared Object?
Has anybody out there used the shared object yet?
We are using XML to track every activity carried out by the user in our movies and storing that in a database, but it all comes to nothing if the user refreshes the movie before we track!
I was thinking of creating the tracking XML inside the shared object so that it cannot get wiped and [potentially] the user could restart from the same place the next time they use the movie.
Anyone any thoughts on this? Anyone done anything similar and come across any problems?
Much appreciated,
Gaius
[BTW, what is that cow icon there for?]
MX Shared Object
Hi guys,
I'm looking at the new feature in MX, shared Objects..
previously I had been using fscommand"save" in an .exe mov.
so now I've converted to MX I gota change it to SObjects!
and I would like to know if anyone knows if I can assign a path to write the file..! .sol file! if you could help me with the syntax I would be very grateful.!
Nate!
Shared.object Or Something...
Hi I hope someone can help with this first step I am taking with the shared.object or something like that...
If I had a mc that could be dragged...
How could I enable the next time the flash movie is opened or accessed for the mc to still be in the position in which it was left.
There are no server technologies involved.
Thanx in advance
Shared Object
i posted this yesterday, and i am more confused about it today.
I have a drawing program. I want to save the drawings as their own swf files. in the simplest explination possible, how can i assign a button to save the drawing.
Shared Object
what is shared object?
How can i use single shared objects for two or more different swfs.
Var Name In Shared Object
Hi, I'm using MX.
I constantly have this problem:
The thing I need to refer to has a variable in it.
I want to save the items of an list so that it goes like sharedobject.data.item1.name = whatever, sharedobject.data.item2.name=another name.... saving all of the items in a list.
I read another thread in FlashKit where another user had the same problem and was answered: use something like _root[mcname]._x = #. This is my code so far:
for (i=0;i<=_parent.imagelist;i++)
{
so.data["pic"+i].name = _parent.imagelist.getItemAt([i].label)
trace(so.data["pic"+i].name)
}
I've also tried doing a simpler version of the above:
for (i=0;i<=5;i++)
{
so.data["pic"+i] = i
trace(so.data["pic"+i])
}
, but it keeps saying "undefined."
I'd appreciate any help, thanx.
Shared Object - Where Are They?
I'm using a shared object as a cookie on my site. But I cannot figure out where it is..... It's not in my browsers temp internet files.
Is there a way to make them go away after a time period or when the user clears their temp internet files?
Shared Object
I need to save the text you type in, in 20 text boxes.
Ok i have read through the tutorials and looked through the posts, but i didnt get how to do this. I did go through the tutorial on macromedia.com on shared objects and i managed to get it to work. But the problem is, i have 20 text boxes and i need it to remember the text from every one, not just one of the text boxes. I did make it work but it took 549 lines of coding. I was wondering, is there a way to use shared objects to make flash remember what the user typed it 20 different text boxes withought having to use 549 lines of code?
Shared Object
Hi all ,
Came accross this problem.
Seems , when I create a shared object in a movie , I can only recall that object in that same move.
What I want to do is , create a shared object in one move and retrieve it's data in another movie.
Is this possible , or am I missing something here?
Thank you for reading this
Regards ,
Frank Schrauwn
Shared Object HELP
Hi there, I can't seem to retreive the variable that stored in the data from another SWF by using SharedObject. Below is what I've been trying to do.
I got an A.swf and B.swf and each of them has 3 navigation buttons (button A, B and C). when I click on let say A button in A.swf, it will store the A button's variable to "buttonStatus" by using SharedObject so that this button will be hilighted as visited link.
When I close the A.swf and relaunch it again, I can see the A button is highlited (visited) but when i open B.swf, the A button is not hilighted there. I'm wondering whether it is possible to retrieve the variable that stored in "buttonStatus" from A.swf so that whatever that is highligted in A.swf will be highlited in B.swf as well.
Below is part of the script that I placed in the first frame of A.swf and B.swf
---------------------------------------------------------------------
buttonStatus_so = SharedObject.getLocal("buttonStatus");
button1_txt = buttonStatus_so.data.buttonNumber1;
//tell the buttons to go to the particular frame based on the retrieved data.
if (button1_txt==1){
hilite1_mc.gotoAndStop(2);
}else{
hilite1_mc.gotoAndStop(1);
}
---------------------------------------------------------------------anyone can help will be very much appreciated.
thanks!
Shared Object ?
hi,
I am trying to use the shared object to save the _x and _y positions of several attached MC's. The attached MC's have all been given a variable name and attached to a dynamically created MC called "world".
I need to loop through all of the MC's in _root.world to save their postions to the shared object. Here is what I have tried,.... when I trace so.flush.. it traces to true but the object postions are not saved.......
Code:
_global.initSo = function() {
_global.so = SharedObject.getLocal("marinaSave");
// if the SharedObject object created a new shared object
// then some values need to be initialized and the flush()
// method is called to make sure the object can be saved.
if (so.data.wab == undefined) {
_global.newSo = true;
for (wab in _root.world) {
so.data.wab = {x:wab._x,y:wab._y};
}
for (waw in world) {
so.data.waw = {x:waw._x,y:waw._y};
}
for (wad in world) {
so.data.wad = {x:wad._x,y:wad._y};
}
so.flush();
trace(so.flush());
}
};
// call the function
initSo();
Am I using the for... in method correctly to loop through the MC's in _root.world and save their values?
Thx
NTD
Shared Object Help
Hi,
I have a dynamically created "world" mc that I am attaching campsite MC's to. I am trying to save thier positions in the "world" MC with the shared object. I am new to useing the Shared Object but I understand how it works for one MC's properties. I am trying save multiple MC data to a Shared Object array. I am close but I cant seem to get it quite right. Right now,... the data is saved when you press a campsite.... I cant seem to get it to work if I pull that code out and place it elsewhere. I am using a var "newCS" to refer to each campsite and declaring it as a local variable. If I try to use it as a global variable,... I get SO = undefined. Here is a look at the code I have now......
Code:
// load shared object
_global.current = null;
_global.initSo = function() {
_global.so = SharedObject.getLocal("campgroundSave");
// if the SharedObject object created a new shared object
// then some values need to be initialized and the flush()
// method is called to make sure the object can be saved.
if (so.data.x == undefined) {
_global.newSo = true;
so.data.x = new Array();
so.data.y = new Array();
so.flush();
}
};
c = 0;
remove = false;
// set remove variable true or false
_root.selectremove.onPress = function() {
_root.checkbox.Play();
};
// start new code
// create campworld
createEmptyMovieClip("campWorld", 0);
_root.campsite.onPress = function() {
c = c+1;
campWorld.attachMovie("campsiteMC", "newCampsite"+c, 5000+c, {_x:_root.campWorld._xmouse, _y:_root.campWorld._ymouse});
var newCS = _root.campWorld["newCampsite"+c];
if (!newSo) {
newCS._x = so.data.x[c];
newCS._y = so.data.y[c];
_global.current = newCS;
} else {
so.data.x[c] = newCS._x;
so.data.y[c] = newCS._y;
}
newCS.index = c;
startDrag(newCS);
newCS._alpha = 50;
newCS.onPress = function() {
newCS.fire.Play();
if (_root.remove == true) {
newCS.removeMovieClip(this);
c = c-1;
} else {
startDrag(newCS);
newCS._alpha = 50;
}
newCS.onRelease = function() {
stopDrag();
newCS._alpha = 100;
_global.current = this;
so.data.x[this.index] = this._x;
so.data.y[this.index] = this._y;
so.flush();
trace(_global.newSo);
trace(SharedObject.getLocal("campgroundSave"));
trace("c count = "+c);
trace(newCS);
trace("newCS index "+newCS.index);
trace("newCS.x = "+newCS._x+" "+"newCS.y = "+newCS._y);
};
};
};
// move world
_root.onEnterFrame = function() {
if (Key.isDown(Key.LEFT)) {
_root.campWorld._x += 5;
} else if (Key.isDown(Key.RIGHT)) {
_root.campWorld._x -= 5;
} else if (Key.isDown(Key.UP)) {
_root.campWorld._y += 5;
} else if (Key.isDown(Key.DOWN)) {
_root.campWorld._y -= 5;
}
};
initSo();
trace outputs...
Code:
newSo = undefined
[object Object]
c count = 7
_level0.campWorld.newCampsite1
newCS index 1
newCS.x = 236 newCS.y = 188
How can I use data from the Shared Object to load when the "campWorld" is created? Any suggestions?
Thanks
NTD
Shared Object Help
Hi,
I have a dynamically created "world" mc that I am attaching campsite MC's to. I am trying to save thier positions in the "world" MC with the shared object. I am new to useing the Shared Object but I understand how it works for one MC's properties. I am trying save multiple MC data to a Shared Object array. I am close but I cant seem to get it quite right. Right now,... the data is saved when you press a campsite.... I cant seem to get it to work if I pull that code out and place it elsewhere. I am using a var "newCS" to refer to each campsite and declaring it as a local variable. If I try to use it as a global variable,... I get SO = undefined. Here is a look at the code I have now......
Code:
// load shared object
_global.current = null;
_global.initSo = function() {
_global.so = SharedObject.getLocal("campgroundSave");
// if the SharedObject object created a new shared object
// then some values need to be initialized and the flush()
// method is called to make sure the object can be saved.
if (so.data.x == undefined) {
_global.newSo = true;
so.data.x = new Array();
so.data.y = new Array();
so.flush();
}
};
c = 0;
remove = false;
// set remove variable true or false
_root.selectremove.onPress = function() {
_root.checkbox.Play();
};
// start new code
// create campworld
createEmptyMovieClip("campWorld", 0);
_root.campsite.onPress = function() {
c = c+1;
campWorld.attachMovie("campsiteMC", "newCampsite"+c, 5000+c, {_x:_root.campWorld._xmouse, _y:_root.campWorld._ymouse});
var newCS = _root.campWorld["newCampsite"+c];
if (!newSo) {
newCS._x = so.data.x[c];
newCS._y = so.data.y[c];
_global.current = newCS;
} else {
so.data.x[c] = newCS._x;
so.data.y[c] = newCS._y;
}
newCS.index = c;
startDrag(newCS);
newCS._alpha = 50;
newCS.onPress = function() {
newCS.fire.Play();
if (_root.remove == true) {
newCS.removeMovieClip(this);
c = c-1;
} else {
startDrag(newCS);
newCS._alpha = 50;
}
newCS.onRelease = function() {
stopDrag();
newCS._alpha = 100;
_global.current = this;
so.data.x[this.index] = this._x;
so.data.y[this.index] = this._y;
so.flush();
trace(_global.newSo);
trace(SharedObject.getLocal("campgroundSave"));
trace("c count = "+c);
trace(newCS);
trace("newCS index "+newCS.index);
trace("newCS.x = "+newCS._x+" "+"newCS.y = "+newCS._y);
};
};
};
// move world
_root.onEnterFrame = function() {
if (Key.isDown(Key.LEFT)) {
_root.campWorld._x += 5;
} else if (Key.isDown(Key.RIGHT)) {
_root.campWorld._x -= 5;
} else if (Key.isDown(Key.UP)) {
_root.campWorld._y += 5;
} else if (Key.isDown(Key.DOWN)) {
_root.campWorld._y -= 5;
}
};
initSo();
trace outputs...
Code:
newSo = undefined
[object Object]
c count = 7
_level0.campWorld.newCampsite1
newCS index 1
newCS.x = 236 newCS.y = 188
How can I use data from the Shared Object to load when the "campWorld" is created? Any suggestions?
Thanks
NTD
Shared Object
I learned that Flash can not write vaiables to a txt file for example.
Can a shared object do this function? and can anyone show me an example on how to load simple variables to a file using a shared object--thanks--Charl
Shared Object Help.
Does anyone know of any good websites for help on Shared Objects? OR if anyone would be able to explain to me basics of saving shared object files and reading them later.
Thanks,
~Bill
|