Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Flash > Сохранение дфнных


Автор: IvanB 23.5.2005, 11:03
Есть программа...
В ней получается массив (числовой).
Так вот: необходимо записать этот массив в документ (например XML) так, чтобы они оставались там после окончания работы программы и чтобы потом можно было извлечь элемент массива с нужным номером. smile smile

Автор: AntonioBanderaz 23.5.2005, 11:09
Какая программы?
Добавлено @ 11:09
Какая программа?

Автор: AlDev 23.5.2005, 13:10
если flash отпаблишен в exe, то используй fscomand,
если нет, то используй серверным скриптом (например php) и методы классов XML или LoadVars.
PS: Посмотри методы send и sendAndLoad и того и другого классов

Автор: Jlekc 23.5.2005, 17:40
SharedObject
Добавлено @ 17:42
есе програмка, то я понимаю для работы на данном компе

Автор: IvanB 24.5.2005, 08:20
Не только... smile

Автор: AlDev 24.5.2005, 09:07
Цитата(IvanB @ 24.5.2005, 13:20)
Не только... smile

Где будет использоваться? На локальном компьютере, в сети.... ?

Автор: IvanB 24.5.2005, 13:25
В сети...

Автор: AlDev 24.5.2005, 13:49
Данные хранить надо на стороне сервера или на стороне клиента?

Автор: IvanB 25.5.2005, 13:45
И там и там (всегда иметь две копии...).
Чтобы программа могла работать и при отключении от сети.

Автор: AlDev 25.5.2005, 14:03
тогда SharedObject - для клиента
серверный скрипт - для сервера.

Только вот объясни мне, зачем такое надобно и что ты такое страшное пишешь?

Автор: IvanB 26.5.2005, 09:41
вопрос такой:
Как занести этот массив и туда и туда...
Код-то показать можешь? А то всё остальное я сам... smile

Автор: AlDev 26.5.2005, 10:05
для SharedObject:
Код

//set values for shared object
var my_so:SharedObject = SharedObject.getLocal('data_array');
my_so.data.values = [10,30,20];
my_so.flush();

как получить оттуда значения:
Код

//get values from shared object
var my_so:SharedObject = SharedObject.getLocal('data_array');
trace (my_so.data.values);


для сервера:

отправить данные:
Код

var my_lv:LoadVars = new LoadVars();
var my_gv:LoadVars = new LoadVars();
my_gv.onLoad = function(success)
{
    if (success)
    {
        if (my_gv.result==true)
        {
            trace ('Данные записаны');
        }
    }
}
my_lv.values = [10,30,20];
my_lv.sendAndLoad('write.php',my_gv,'POST');


получить данные:
Код

var my_xml_data:XML = new XML();
my_xml_data.ignoreWhite = true;
my_xml_data.load('read.php');
my_xml_data.onLoad = function(success)
{
  if (success)
  {
    var i:Number;
    for (i=0;i<this.firstChild.childNodes.length;i++)
    {
      trace (this.firstChild.childNodes[i].nodeValue);
    }
  }
}


ну и про php спрашивай в php.
Передаём мы данные как массив, и смотрим, записаны они или нет.
Читаем их как XML.

Автор: PROCESSOR 26.5.2005, 21:21
А какой размер может иметь Shared Object ? Любой ?

А если exe , то используй fscommand ? поподробнее плиз.

Автор: AlDev 27.5.2005, 06:54
Цитата(PROCESSOR @ 27.5.2005, 02:21)
А какой размер может иметь Shared Object ? Любой ?

RTFM smile
из help-a:
Цитата

Local disk space considerations
Local shared objects are always persistent on the client, depending on available memory and disk space.

By default, Flash can save locally persistent remote shared objects as large as 100K. When you try to save a larger object, Flash Player shows the Local Storage dialog box, which lets the user allow or deny local storage for the domain that is requesting access. (Ensure that your Stage size is at least 215 x 138 pixels; this is the minimum size Flash requires to display the dialog box.)

If the user clicks Allow, the object is saved and SharedObject.onStatus is invoked with a code property of SharedObject.Flush.Success; if the user clicks Deny, the object is not saved and SharedObject.onStatus is invoked with a code property of SharedObject.Flush.Failed.

The user can also specify permanent local storage settings for a particular domain by right-clicking (Windows) or Control-clicking (Macintosh) while a SWF file is running, selecting Settings, and then opening the Local Storage panel.

You can’t use ActionScript to specify local storage settings for a user, but you can display the Local Storage panel for the user by using System.showSettings(1).

The following list summarizes how the user’s disk space choices interact with shared objects:

If the user selects Never, objects are not saved locally and all SharedObject.flush() commands issued for the object return false.
If the user selects Unlimited (moves the slider all the way to the right), objects are saved locally, as available disk space allows.
If the user selects None (moves the slider all the way to the left), all SharedObject.flush() commands issued for the object return "pending", and the player asks the user if additional disk space can be allotted to make room for the object.
If the user selects 10K, 100K, 1 MB, or 10 MB, objects are saved locally and SharedObject.flush() returns true if the object fits within the specified amount of space. If more space is needed, SharedObject.flush() returns "pending", and the player asks the user if additional disk space can be allotted to make room for the object.
Additionally, if the user selects a value that is less than the amount of disk space currently being used for locally persistent data, the player warns the user that any locally saved shared objects will be deleted.

Note: There is no size limit in Flash Player that runs from the authoring environment.



Цитата(PROCESSOR @ 27.5.2005, 02:21)
А если exe , то используй fscommand ? поподробнее плиз.

fscommand("exec","path");
и пишешь небольшое приложение на чём-нибудь, которое будет сохранять данные в файл.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)