[Xerte] Loading External Content
Julian Tenney
Julian.Tenney at nottingham.ac.uk
Thu Mar 5 12:39:54 GMT 2009
You’ve got a comma in the debug statement there…
The component allows you to define an init() function that you can pass an initObject to from Xerte. That could be {filename: ‘textfiel.txt’}
Then in the component swf;
function init(obj){
debug(obj.fileName);
//do stuff here
}
I’ve just realisd I have Flash 8, not 2004, so that would explain the file format. Here’s the code from that file anyway – it’s just the first frame, nothig opn the stage:
//Component.fla
function init(initObject){
//this function is automatically called by Xerte once the component has loaded.
//Use it to initialise this component. It receives one param, initObject, passed to
//the function from Xerte. Use this object to pass init data into the component.
debug('The component has loaded and received' + initObject);
//you may want to fire an event to Xerte to let other icons know the component
//has loaded and is ready to have it's methods called. Best is ask rootIcon to broadcast
//a custom message, and have an event listener on an interaction icon handle the event,
//because you cannot register a listener to this icon (the methods for broadcasting are killed
//when this file loads).
rootIcon.broadcast('onCustomEvent');
//you get the following functions and variables, which can be called from / used in this scope:
//debug(), getTabIndex(), FileLocation. Let me know if you want others passing in from the engine.
//otherwise, youre on your own! But that's why you're here, right?
}
function myFunction(a,b,c){
//this can be directly called from Xerte script icons by IconID.myFunction(a,b,c);
}
stop();
From: xerte-bounces at lists.nottingham.ac.uk [mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of steve.frank at lucite.com
Sent: Thursday, March 05, 2009 12:14 PM
To: Xerte discussion list
Subject: RE: [Xerte] Loading External Content
There seems to be a problem with the Flash installation on this PC. I can't get debugging to work (it won't let me add any properties to the variables or watch lists).
If I use trace(_level0.engine,FileLocation) it returns 'undefined'.
So far I've been loading the .swf into a graphic icon, however creating a component might be a better solution if I can pass it the location of the text file each time it's used. I've avoided using components so far as I get an 'unexpected file format' error when I try to open the component.fla template! Probably another symptom of the Flash installation.
Steve
__________________________________________________________________________________
Lucite International Group Limited. Registered in England No. 5671799.
Registered Office: Queens Gate, 15-17 Queens Terrace, Southampton SO14 3BP, United Kingdom
Holding Company for the Lucite International Group
Julian Tenney <Julian.Tenney at nottingham.ac.uk>
Sent by: xerte-bounces at lists.nottingham.ac.uk
05/03/2009 09:32
Please respond to
Xerte discussion list <xerte at lists.nottingham.ac.uk>
To
"Xerte discussion list" <xerte at lists.nottingham.ac.uk>
cc
Subject
RE: [Xerte] Loading External Content
No, I also use 2004. It looks liie you are getitng the firs part of the path, then you must be concatenating an undefined in there between FileLocaiton and the filename,
What happens if you debug(_level0.engine.FileLocation);
Which type of icon are you using? You might be better off with a component icon if you have code in your swf, as it will get methods like debug(); FileLocation is available directly (i.e. without haing to do _level0.engine.FileLocation); it does _lockroot on the loaded swf, and a few other things to make life easier for coders in loaded swfs.
J
From: xerte-bounces at lists.nottingham.ac.uk [mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of steve.frank at lucite.com
Sent: Thursday, March 05, 2009 8:49 AM
To: xerte at lists.nottingham.ac.uk
Subject: Fw: [Xerte] Loading External Content
Thanks for the help guys..
I take the point regarding the XMLEngine.swf location and typing the full path to the text file solves the problem.
When I try to use FileLocation in the way described it returns 'undefined' i.e. Flash throws up an error opening URL "file:///....../Media/Pane1/undefinedOverview.txt"
Is this a limitation of the version of Flash that I am using (MX 2004)?
Steve
__________________________________________________________________________________
Lucite International Group Limited. Registered in England No. 5671799.
Registered Office: Queens Gate, 15-17 Queens Terrace, Southampton SO14 3BP, United Kingdom
Holding Company for the Lucite International Group
----- Forwarded by Steve J Frank/GB/ACRYLICS on 05/03/2009 08:19 -----
Julian Tenney <Julian.Tenney at nottingham.ac.uk>
Sent by: xerte-bounces at lists.nottingham.ac.uk
04/03/2009 16:32
Please respond to
Xerte discussion list <xerte at lists.nottingham.ac.uk>
To
"Xerte discussion list" <xerte at lists.nottingham.ac.uk>
cc
Subject
RE: [Xerte] Loading External Content
You need to use the FileLocation variable to get the full path to the external path.
myData.load("Overview.txt");
works in the browser, because the XMLEngine.swf is in the same folder; when in authoring mode, the XMLEngine.swf is in the Xerte application folder, so it looks in that folder when you only specify the fiename.
You can use _level0.engine.FileLocation to get the first bit of the path, i.e:
myData.load(_level0.engine.FileLocation + "Overview.txt");
HTH,
J
From: xerte-bounces at lists.nottingham.ac.uk [mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Patrick Lockley
Sent: Wednesday, March 04, 2009 4:09 PM
To: Xerte discussion list
Subject: RE: [Xerte] Loading External Content
Hi Steve,
It fails me for me when I press the f5 key – but it works fine if I publish it then look at in a web browser (via index.htm).
Might be a sandbox / security setting on your flash player?
Hope this helps.
Pat
From: xerte-bounces at lists.nottingham.ac.uk [mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of steve.frank at lucite.com
Sent: 04 March 2009 15:46
To: xerte at lists.nottingham.ac.uk
Subject: [Xerte] Loading External Content
I am attempting to load some external content into a Xerte project but I'm having difficulty getting this to work when the content itself gets data from an external file.
The project uses a custom interface and contains a couple of graphics icons together with a number of flex style accordian panes, listitems and tabs. Selecting the appropriate combination should load the required external content into the graphic icons using the loadImage() method. e.g. displayGraphic.loadImage(FileLocation + 'Media/Pane1/Graphics.swf')
The external content is always in the form of an .swf file however there are two distinct types.
One contains a number of scenes that are linked by some actionscript. All the graphics are contained within the .swf and this type of file loads and operates without issue.
The second type contains only a single dynamic text block together with a ScrollPane component. The timeline contains the following ActionScript to load the text from a plaintext file at runtime:
myData = new LoadVars();
myData.onLoad = function(success){
if (success) {
myText_txt.htmlText = this.text;
} else {
myText_txt.htmlText = "<b>Flash has failed to load the text file!<b>";
}
};
myData.load("Overview.txt");
Overview.txt is located in the same directory as the .swf and is in the form "text=Required text etc. etc. etc..."
When I test the .swf, it loads and displays the content of Overview.txt as expected, however when I try to get Xerte to load this file I get the "Flash has failed to load the text file!" message.
Displaying text from an external source file is going to be a major part of this project so I need to get this to work.
Being an Authorware refugee, I'm only just getting started with Flash and Xerte so would appreciate any help!
Steve
__________________________________________________________________________________
Lucite International Group Limited. Registered in England No. 5671799.
Registered Office: Queens Gate, 15-17 Queens Terrace, Southampton SO14 3BP, United Kingdom
Holding Company for the Lucite International Group
IMPORTANT NOTICE::- This email is confidential, may be legally privileged, and is solely for the use of the intended recipient. Access, disclosure, copying, distribution, or reliance on any of it by anyone else is prohibited and may be a criminal offence.
If you have received this e-mail by mistake, please notify the sender immediately by e-mail and delete this e-mail from your system. The sender has taken reasonable precautions to ensure no viruses are present in this e-mail however the company cannot accept
responsibility for any loss or damage arising from the use of this e-mail or attachments. Please note that this e-mail has been created in the knowledge that Internet e-mail is not a 100% secure communications medium.
We advise that you understand and consider this lack of security when e-mailing us.
Message from Lucite International EMail Administration:
This mail has been scanned for spam content and passed. If however it is actually spam please accept our apology for any inconvenience and assist us in improving our scanning system accuracy by reporting the email using the link below.
Click here <https://www.mailcontrol.com/sr/Rg+9LQ6yzJjTndxI!oX7UoH9GbmNk6!RWPNF3SG4uepBXk1ixpwObI4+1EAsVGy!4SORx0NZ4cT1lqOECv!Swg==> to report this email as spam._______________________________________________
Xerte mailing list
Xerte at lists.nottingham.ac.uk
http://lists.nottingham.ac.uk/mailman/listinfo/xerte_______________________________________________
Xerte mailing list
Xerte at lists.nottingham.ac.uk
http://lists.nottingham.ac.uk/mailman/listinfo/xerte
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20090305/72269f95/attachment.html
More information about the Xerte
mailing list