[Xerte] Re: event failing on second call

Julian Tenney Julian.Tenney at nottingham.ac.uk
Fri Mar 30 09:08:36 BST 2012


Here's the engine code, which makes the problem obvious:

ICON.prototype.loadVars = function(url){
     this.loadVars = new LoadVars(); //overriding the function with the object. Duh. But maybe there is a good reason for this?

     this.loadVars.icon = this;
     this.loadVars.load(url);
     this.loadVars.onData = function(src){
           this.icon.rawData = src;
           this.icon.broadcast('onLoadVarsData');
           this.onLoad();
     }
     this.loadVars.onLoad = function(success){
           this.icon.broadcast('onLoadVars');
     }
}

I can change it to this - which will break existing code that only fires once and works. To fix it I either change the function name or the object name... either way something breaks.

ICON.prototype.loadVars = function(url){
     this.lv = new LoadVars();
     this.lv.icon = this;
     this.lv.load(url);
     this.lv.onData = function(src){
           this.icon.rawData = src;
           this.icon.broadcast('onLoadVarsData');
           this.onLoad();
     }
     this.lv.onLoad = function(success){
           this.icon.broadcast('onLoadVars');
     }
}

From: xerte-bounces at lists.nottingham.ac.uk [mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Dave Burnett
Sent: 29 March 2012 16:09
To: Xerte list
Subject: [Xerte] Re: event failing on second call


Paul, I can't get that far.
The event will only fire once.
It's as Jules mentioned, the function seems to be destroyed after a successful first load.



________________________________
Date: Thu, 29 Mar 2012 07:20:36 -0700
From: Paul.Swanson at harlandfs.com
To: xerte at lists.nottingham.ac.uk
Subject: [Xerte] Re: event failing on second call
Try parsing rawData:

rawInfoArray = rootIcon.rawData.split ('&'); // save string pairs into an array
for (i=0; i<rawInfoArray.length; i++) { // break pairs into smaller arrays and parse
  tempArray = rawInfoArray[i].split ('=');
  debug(tempArray[0] = ': ' + tempArray[1]);
}

From: xerte-bounces at lists.nottingham.ac.uk [mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Dave Burnett
Sent: Thursday, March 29, 2012 7:00 AM
To: Xerte list
Subject: [Xerte] Re: event failing on second call

I tried myIcon.readFile and that seems to be able to be called repeatedly without issue.
Must just be something with loadVars.
Odd.


________________________________
From: Julian.Tenney at nottingham.ac.uk
To: xerte at lists.nottingham.ac.uk
Date: Thu, 29 Mar 2012 14:54:57 +0100
Subject: [Xerte] Re: event failing on second call
If you load a swf into a movieclip, you lose any custom methods / properties of that clip after the load.

So you can do

mc.someFunction = function(){ //blah  }
mc.loadMovie('some.swf', blah)

and then in some.swf's timeline call this.somefunction. It doesn't exist. Maybe I was thinking of that.

Not sure what's going with loadVars, I've never used them, but either debug things in the engine, or send me a simple example and I'll see what's happening.

From: xerte-bounces at lists.nottingham.ac.uk [mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Dave Burnett
Sent: 29 March 2012 14:52
To: Xerte list
Subject: [Xerte] Re: event failing on second call

The load wipes stuff out?
Is it true for all the methods of sending/loading external data?


________________________________
From: Julian.Tenney at nottingham.ac.uk
To: xerte at lists.nottingham.ac.uk
Date: Thu, 29 Mar 2012 12:50:42 +0100
Subject: [Xerte] Re: event failing on second call
I think its like loading XML where the load wipes out methods / properties on the object.

Can you build a new icon for each load vars call?

i.e.

INT
  BUT
    TXT // a dummy loadVars
   SCR //kick off the loadvars

    INT
      EVT
        //handle the loadvars

From: xerte-bounces at lists.nottingham.ac.uk [mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Dave Burnett
Sent: 29 March 2012 12:37
To: Xerte list
Subject: [Xerte] Re: event failing on second call


OK, here's the trace of 2 consecutive calls with
debug(rootIcon.loadVars);

//first call
top debug //directly under button
[type Function]
load //directly under loadVars call
[type Function]
loaded //success

//second call

top debug
onLoad=%5Btype%20Function%5D&onData=%5Btype%20Function%5D&icon=%5Flevel0%2Eengine%2EIFC
load
onLoad=%5Btype%20Function%5D&onData=%5Btype%20Function%5D&icon=%5Flevel0%2Eengine%2EIFC

What is happening to the loadVars  function?

________________________________
From: d_b_burnett at hotmail.com
To: xerte at lists.nottingham.ac.uk
Subject: event failing on second call
Date: Thu, 29 Mar 2012 06:43:54 -0400

I click a button to pop up a scrolling text window which is populated with a loadVars call to a text file.

rootIcon.loadVars('http://www.myserver.com/common/revisions.txt?nt=' + (new Date()).getTime());

followed by an Event interaction

onLoadVars
rootIcon


It works the first time, but if I click the button again, the event will not fire again.
I ran into this once before but can't remember what the issue was.


This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.
This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.

_______________________________________________ Xerte mailing list Xerte at lists.nottingham.ac.uk<mailto:Xerte at lists.nottingham.ac.uk> http://lists.nottingham.ac.uk/mailman/listinfo/xerte This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham. This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.

_______________________________________________ Xerte mailing list Xerte at lists.nottingham.ac.uk<mailto:Xerte at lists.nottingham.ac.uk> http://lists.nottingham.ac.uk/mailman/listinfo/xerte This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham. This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.

_______________________________________________ Xerte mailing list Xerte at lists.nottingham.ac.uk http://lists.nottingham.ac.uk/mailman/listinfo/xerte This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham. This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20120330/a2c722c6/attachment-0001.html>


More information about the Xerte mailing list