Is this possible?

Jul 22, 2011

Not sure if this is possible but I thought that I would ask the people that probably know a lot more about Articulate than myself.  I've built a little Flash app that uses an external .txt file.  I would know like to import the resulting .swf file into an Engage Interaction.  For the .swf file to function correctly it needs to read that .txt file.  I found the location of the resulting swf interaction once I publish my project.  I put the .txt file in that same folder...hoping that the .swf will read it...but no luck.  I'm sure the original .swf that I import into my interaction and then publish is getting modified, thus breaking the link to the .txt.  Can anyone help?

20 Replies
Brian Batt

Hi Brock and welcome to Heroes,

Articulate is unable to modify the SWF file that you import.  In fact, the only thing that we do is append some letters to the end of the file name.  If the SWF is not working as expected, it's likely you haven't followed our recommended best practices for creating SWF files:

http://www.articulate.com/support/presenter09/kb/?p=76

Brock Suska

Hi Brian, thanks for the response.  Maybe you can shed some light on how I can correctly name the path.  In my Actionscript I have this - loadVariablesNum("data.txt", 0);

My data.txt file is in the same folder as my swf and all works.  Like I said I tried copying that data.txt file into the Articulate folder and it doesn't work.  What should that path be?  or does it have something to do with loading that variable into "0"?

Brian Batt

Hi Brock,

I'd recommend playing with the link to the .txt file to see if that's the issue.  For example, try /data.txt instead of just data.txt.  Try ../data.txt and any others that you can think of.

In the meantime, I'll have one of my local Flash experts take a look at this thread and see if he recognizes anything obvious.  It'll likely be next week before he replies since he's out of the office today.

David Burton

Brock,

When referencing variables form a text file with Flash, please use the following code and formats.

AS2.0 Code:
==========
myData = new LoadVars();
myData.onLoad = function() {
myText_txt.text = this.myVariable;
};
myData.load("data.txt");

You should create a dynamic text field with an instance name of "myText_txt" in the above Flash file.

When inserting the published Flash file into Engage make sure you set the Engage Multimedia Properties --> Options --> Display to Embedded

data.txt file format:
===============
myVariable=This is text from the Data File

After publishing your Engage project, simply place the data.txt file in the root Engage folder - see below:


Process - Engage output
   engage_content
   data.txt
   engage.html
   engage.swf

I hope this helps!

Brock Suska

Hey David, thanks for the code...problem is, now the rest of my code doesn't work so hot.  I'm trying to get a progress bar to move up until it hits a number that I have stored in this external text file.

I thought I could use "this.myVariable" but no luck...

Here is my code:

myData = new LoadVars();
myData.load("data.txt");
theBox._yscale = 0;
myInterval = setInterval(preloader,30);
function preloader() {
 if (theBox._yscale == this.myVariable) {
      clearInterval(myInterval);
 }
 theBox._yscale += 1;
}

David Burton

Brock,

It's important to remember, when reference variables created inside a function,  you need to append the function name to the variable (myData.myVariable). See complete code below.


myData = new LoadVars();
myData.onLoad = function () {
myText_txt.text = this.myVariable;
};
myData.load("data.txt");

theBox._xscale = 0;

myInterval = setInterval(preloader,30);
function preloader() {
 if (theBox._xscale  == myData.myVariable) {
      clearInterval(myInterval);

      // Do something cool here when the condition is met
 }
 theBox._xscale += 1;
}
stop();

I hope this helps!

Brock Suska

Alright!  Thanks David.  It works. I had to move the data.txt file up to the root folder of my published Articulate project. 

I was looking at this portion of your earlier post - "When inserting the published Flash file into Engage make sure you set the Engage Multimedia Properties --> Options --> Display to Embedded", but I couldn't find that anywhere.  Could you elaborate a bit more and point out where I need to go exactly to modify this property?

This discussion is closed. You can start a new discussion or contact Articulate Support.