Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 3.0 (http://www.flasher.ru/forum/forumdisplay.php?f=83)
-   -   security exception (http://www.flasher.ru/forum/showthread.php?t=138582)

KOLANICH 11.04.2010 14:42

security exception
 
Код AS3:

import flash.external.ExternalInterface;
//import flash.filesystem.File;
//import XMLGetter;
import flash.net.SharedObject;
import flash.system.Security;
import flash.system.SecurityPanel;
 
//Security.showSettings();
//Security.allowDomain("*");
 
var so:SharedObject;
function makeSO(namespace:String="JSFlashStorage"){
    so= SharedObject.getLocal(namespace);
    trace("Shared object created\nNamespace is "+namespace);
}
//so = SharedObject.getLocal("JSFlashStorage");
 
makeSO();
function setVar(varname:String,val:String)
{
    so.setProperty(varname,val);
    so.flush();
}
function getVar(varname:String):Object{
        trace(so.data[varname]);
        return so.data[varname];
}
 
function allVars():Object{
    return so.data;
}
//var mass:Object=allVars();
//for(
function clearVars(){
    so.clear();
}
 
 
/////////////setting js interfaces/////////////////////////////
ExternalInterface.addCallback("setVar", setVar);
ExternalInterface.addCallback("getVar", getVar);
ExternalInterface.addCallback("allVars", allVars);

бросает исключение безопасности

Добавлено через 2 минуты
как побороть?

wvxvw 11.04.2010 15:09

Цитата:

Although the localPath parameter is optional, you should give some thought to its use, especially if other SWF files need to access the shared object. If the data in the shared object is specific to one SWF file that will not be moved to another location, then use of the default value makes sense. If other SWF files need access to the shared object, or if the SWF file that creates the shared object will later be moved, then the value of this parameter affects how accessible the shared object will be. For example, if you create a shared object with localPath set to the default value of the full path to the SWF file, no other SWF file can access that shared object. If you later move the original SWF file to another location, not even that SWF file can access the data already stored in the shared object.
Это? И вообще, Вы уверены, что пишете на AS3? - в AS3 у функций и переменных всегда есть тип.

KOLANICH 11.04.2010 15:47

не это

mickfallout 11.04.2010 15:56

Штатный телепат в отпуске, так что расскажите - какое именно?

wvxvw 11.04.2010 16:28

Так в вашем коде всего одна строчка... и там ошибка может быть только одна связаная с безопасностью...

Mur4ik 12.04.2010 05:36

KOLANICH, вы если хотите внятные ответы, то задавайте, пожалуйста, внятные вопросы с внятными примерами.

из того чуда что вы привели в качестве примера, выполняется только
Код AS3:

var so:SharedObject = SharedObject.getLocal("JSFlashStorage");

а это вообще шедевр
Код AS3:

function getVar(varname:String):Object{
                trace(so.data[varname]);
                return [varname];
}

передаем строку и получаем в итоге туже строку но уже в массиве из одного элемента.

Как уже было выше отмечено, судя по вашему коду ошибка может быть только в одном месте - в 7 строчке, если вообще ошибка именно в приведенном куске, ибо выполняется он без проблем (если отключить стриктмод :) )

KOLANICH 13.04.2010 17:54

поправил немного
теперь исключение не бросает
и доступ из javascript пропал


Часовой пояс GMT +4, время: 22:42.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.