How do I Send Stored Info Between Two or More Construct 3 Projects on My Website?

0 favourites
  • 5 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • Edit: I changed the title of this post so that it better describes what I'm trying to achieve:

    I'm working on a project that switches between web pages and separate construct "projects" embedded in iframes. It's a fairly large and complex treasure hunt game relying heavily on streamed video (Vimeo), which is why I have separate Construct projects on separate pages loading in iframes. The type of the stored information I'm trying to send and access is about which objects a Player has found or used up or lost.

    When I used Construct 2, I was able to send stored information back and forth between the Construct windows using localstorage. The Player would click an object in one window and set a localstorage key. Then somewhere down the line, another Construct window (a separate "project") on another page would check if that key existed, then set a variable to LocalStorage.ItemValue, etc.

    I tested the same process on my new Construct 3 pages, but it doesn't work anymore. It does work for storing information that can be used later by the same project, but it isn't sharing it with other Construct projects on other pages.

    During my Construct 2 days I noticed that localstorage didn't seem to work for communicating between the Construct projects and the .html pages, and I'm wondering if this is a similar issue.

    Thanks for your help!

  • I was just looking at the Storage Script Interface page in the manual and found this paragraph:

    "As with the Local Storage plugin, the storage is unique to the specific project. It is not shared with any other projects or other website storage, even on the same origin."

    If local Storage won't work between projects, is there anything that can work? I've seen postmessage mentioned, but I'm not sure if it can be used in this way.

    I think I'm starting to answer my own question. I might be able to communicate between an iframe-embedded Construct project to a parent Construct project using the postmessage method. Rex Rainbow had created an addon for Construct 2 that allowed for communication between iframe and parent, and I'm wondering if he used postmessage for it to work?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'm starting to answer my own question:

    Now I'm thinking of passing information more directly, between iframe-embedded project and parent project, using postMessage method--and I'm in the process of learning about it. RainbowRex used to have an addon for Construct 2 that could pass information in this way, and I'm wondering if he or she used postMessage to do it. it was a great addon, but I couldn't find a version of it that's compatible with Construct 3. I think it was called FrameMessage....

  • I'm wondering if he or she used postMessage to do it.

    You need to use postmessage and yes rex_FrameMessage plugin uses postmessage api

    developer.mozilla.org/en-US/docs/Web/API/Window/postMessage

  • Thanks, Eren. I'm in the process of learning postMessage. I looked inside Rex's addon, too, and saw that postMessage was used. I have to rethink the structure of my game, but at least I don't have to dump the whole thing, as I feared yesterday, lol.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)