[SOLVED] Loading an external XML file through AJAX Plugin

Get help using Construct 2

Post » Mon Dec 29, 2014 12:34 am

Hey, hello everybody !

I'm using the FREE version of Construct 2. (I tested both last STABLE and last BETA versions).

It seems my event code not working as expected!
By the way I read how doing it on page which I can't show you the links since the forum don't permit me to add them
the official manual page for loading an XML file through an AJAX call of the AJAX Plugin.
and the tutorial page for know how using the XML Plugin and then make node get/set through the XPATH Syntax.
Nothing seems working for me, all I got is 404 NOT FOUND when debugging the AJAX result content.. :(

My XML file must be dynamically loaded through RUNTIME (and so it's not good to include it at EDITTIME in Included Files to my Construct 2 project.

I tested also with an other XML file instead mine, so, aswell this XML code:
Code: Select all
<?xml version='1.0' ?>
   <chapter1>
      <hint id='intro1'>Good morning Mr Bond, how did you sleep ?</hint>
      <hint id='intro2'>I have prepared your breakfast for you</hint>
      <hint id='intro3'>Come find me when you're finished</hint>
   </chapter1>


seems not loaded through my project.

This is like my OBJECTS are:

I have three objects:
  1. object type: "AJAX Plugin", named as: utility_AJAX
  2. object type: "XML Plugin", named as: utility_XMLDoor
  3. object type: "MultilineBox Plugin", named as: MultilineBox (object found at: )

This is like my EVENTS are:
Code: Select all
CONDITION: (SYSTEM) -> On start of layout
ACTION 1: [utility_AJAX] Set request header "Access-Control-Allow-Origin" to "http://localhost:50000/"
ACTION 2: [utility_AJAX] Override MIME Type with ".xml files: text/xml"
ACTION 3: [utility_AJAX] Request "pop.xml" (tag: "tmp")

 NOTE: don't work even if I don't add Action 1, 2  to action event's line)

CONDITION: [utility_AJAX] -> On "tmp" completed
ACTION 1: [utility_XMLDoor] Load XML Document from string utility_AJAX.LastData
ACTION 2: [MultilineBox] Set text to utility_AJAX.LastData



My pop.xml (test file) is located in : "%ROOT_Construct2_InstallationDirectory%\mesProjets\dynacoGame\pop.xml"

So... Is it impossible to what I want achieve in FREE Version (if yes, I will buy the Personal Edition), if not, what I'm doing wrong?

Also, is it possible to load my XML file if I locate in there path: "%ROOT_Construct2_InstallationDirectory%\mesProjets\dynacoGame\_gameRes\Level1\pop.xml" ?

THANKS for all answer, since I'm just stuck in a way I can't unstuck me myself..

ps: I tested each times in Construct 2 HTML5 preview mode (and both Chrome or Firefox or even IE)
Last edited by Atanacius on Tue Dec 30, 2014 1:39 am, edited 1 time in total.
B
10
S
1
Posts: 10
Reputation: 537

Post » Mon Dec 29, 2014 4:47 am

I want add that with the Node-Webkit preview, I get the 404 error too.. So..

Please, tell me...

Is will working in a Personal purchased version ?
B
10
S
1
Posts: 10
Reputation: 537

Post » Mon Dec 29, 2014 6:21 am

Okay.. just went and built a capx that loads a local xml file using node-webkit.
this is my first time doing this sort of thing.
localxmlload.jpg

You'll need to export the project to node-webkit and put the document.xml file in the app's folder.
Then run the program and it'll load it. It won't work in preview.
You do not have the required permissions to view the files attached to this post.
B
47
S
22
G
65
Posts: 1,127
Reputation: 38,395

Post » Mon Dec 29, 2014 10:52 pm

Thanks a bunch for your help !

So...
Ok like I said, (and I'm afraid to discover that), the free version is limited to do that (Exporting a Node-Webkit project), but the problem is that the PREVIEW MODE won't work with external local loaded files through both Paid Construct 2 version/Free Construct 2 version.

So my question is now reallocated to Ashley (and any Construct 2 software developpers):

Why we can't locally load files in Preview Mode in Node-Webkit ??
* Is it a thing already submitted as a bug?
** When this will be fixed ?

Thanks for answer.
B
10
S
1
Posts: 10
Reputation: 537

Post » Tue Dec 30, 2014 12:41 am

Why we can't locally load files in Preview Mode in Node-Webkit ??

We can though. In node-webkit preview if you use "document.xml" as the file it will look here:
"http://localhost:50000/document.xml"

If you want to get the file from the same folder as the capx you need to type it in explicitly:
"C:\Users\rojo\Documents\c2projects\document.xml"

And to make it work in preview or in export you could use a global like this:

global text AppPath = "C:\Users\rojo\Documents\c2projects\"
Start of layout
System: [NEGATE] is in preview
--- set AppPath to NodeWebkit.AppFolder

And then request any files with:
AppPath & "document.xml"
You do not have the required permissions to view the files attached to this post.
B
94
S
33
G
113
Posts: 5,356
Reputation: 73,273

Post » Tue Dec 30, 2014 1:12 am

R0j0hound:

I want thank you carefully, you unstucked me!

AND even given me an ability to have an autoswitchable way to debug the game !

Must say, I was knowing that the "NodeWebkit.AppFolder" was fixed to the path where Node-Webkit for Construct 2 has been installed.

But even by playing with "..\" strings for goback in directory it won't work!

So, with your method all work as intended an like a charm !!

THANK YOU CAREFULLY !
(Can't upvote your answer due to my not enough Reputation points on the forum, but yes, will do that in one day !)

Also, now I'm unstucked with this behavior, I can continue to design my game, next way is going to give to my game an ability to multiload EVERY XML files through a precises folders (and subfolders too), do you know a Plugin able to doing that ?

Or way better a CapX sample for learn how?
B
10
S
1
Posts: 10
Reputation: 537


Return to How do I....?

Who is online

Users browsing this forum: raptor0555, Syazanie Amirin and 41 guests