简体   繁体   English

从swf访问SharedObject到另一个swf

[英]Access SharedObject from swf to another swf

Can anyone help me how to access a sharedobject from an swf to another swf? 谁能帮我从一个瑞士法郎到另一个瑞士法郎访问共享对象? I have a swf file wherein in its second frame, I saved a value through "sharedObject". 我有一个swf文件,其中在第二帧中,我通过“ sharedObject”保存了一个值。 I have also a .as file wherein I call that value I saved, and pass it to another swf file. 我还有一个.as文件,在其中我调用保存的值,并将其传递给另一个swf文件。 I successfully pass the value if I save it in the first frame on the first swf. 如果将值保存在第一个swf的第一帧中,则可以成功传递该值。 But the problem is this: If I save it on its second frame, I can't pass the value anymore. 但是问题是这样的:如果我将其保存在第二帧中,则无法再传递该值。 I have an idea of just calling the "sharedobject" instead of calling the "Level1.swf"(the name of the 1st swf) but I have no idea how to do it. 我有一个想法,只是调用“ sharedobject”,而不是调用“ Level1.swf”(第一个swf的名称),但是我不知道该怎么做。 I don't want to just save the value on the 1st frame either. 我也不想只将值保存在第一帧上。 I really need help. 我真的需要帮助 Any help is very much appriciated. 任何帮助都非常有用。

Here's my .as file because I think this is the problem, but I can also post my other codes if requested: 这是我的.as文件,因为我认为这是问题所在,但是如果需要,我也可以发布其他代码:

package  
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;


public class Reward1 extends Sprite 
{
   public var loader:Loader;

   public function Reward1()
{
     loader = new Loader();
     loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
     loader.load(new URLRequest("Level1.swf"));

}

public function onLoaded(e:Event):void 
    {
        trace("Child Loaded");
        trace(loader.content['SaveReward1']);

    }

    public function go0():int{

        return loader.content['SaveReward1'];
    }


}
}

Just in case you did not founded the answer, I had the same problem, and got the solution here . 以防万一您没有找到答案,我遇到了同样的问题,并在此处找到了解决方案。

At the page I founded the image very useful. 在页面上,我建立了非常有用的图像。 All I had to do was to set the secure parameter to false. 我要做的就是将安全参数设置为false。 Example: 例:

var mySharedObject:SharedObject = SharedObject.getLocal("local_name", "/path", false);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM