I have an array textFromXml, containing text and start position from an
imported XML. These will be loaded when reaching the corresponding time in a
movieclip placeholder (currentframe divided on framerate).
I have the AS2-code attached.
This gives an output looking like this;
[i](...)
i = 0
No match; 0.0666666666666667 does not match 0.1
i = 1
No match; 0.0666666666666667 does not match 1.2
i = 2
No match; 0.0666666666666667 does not match 8.5
i = 3
No match; 0.0666666666666667 does not match 13.5
i = 4
No match; 0.0666666666666667 does not match 18.5
i = 5
No match; 0.0666666666666667 does not match 23.5
i = 6
No match; 0.0666666666666667 does not match 28.5
i = 7
No match; 0.0666666666666667 does not match 33.0
i = 0
MATCH! Text: This is the text from the XML.
i = 1
No match; 0.1 does not match 1.2
i = 2
No match; 0.1 does not match 8.5
i = 3
No match; 0.1 does not match 13.5
i = 4
No match; 0.1 does not match 18.5
i = 5
No match; 0.1 does not match 23.5
i = 6
No match; 0.1 does not match 28.5
i = 7
No match; 0.1 does not match 33.0
i = 0
(...)[/i]
However, one strange problem. The loop freezes at 1.23333333333333 secs, i.e.
at the 37th frame, and just repeats the check at this frame over and over...
[i]i = 0
No match; 1.23333333333333 does not match 0.1
i = 1
No match; 1.23333333333333 does not match 1.2
i = 2
No match; 1.23333333333333 does not match 8.5
i = 3
No match; 1.23333333333333 does not match 13.5
i = 4
No match; 1.23333333333333 does not match 18.5
i = 5
No match; 1.23333333333333 does not match 23.5
i = 6
No match; 1.23333333333333 does not match 28.5
i = 7
No match; 1.23333333333333 does not match 33.0[/i]
I've tried dividing on a different number, but still the same frame causes the
error. The imported SWF is 900 frames, and keeps running without problems, so
it's only the onEnterFrame-function that gets a hickup. I don't understand why
it would freeze here. Any suggestions?
__________
this.onEnterFrame = function(){
for(var i:Number = 0; i < textFromXml.length; i++) {
trace("i = " + i);
if( (_root.screen._currentframe/30) ==
textFromXml[i].attributes.start) {
trace("MATCH! Text: " + textFromXml[i].firstChild.nodeValue);
} else {
trace("No match; " + (_root.screen._currentframe/30) + " does not
match " + textFromXml[i].attributes.start);
}; // end if
}; // end for
}; // end onEnterFrame
kglad - 16 Jul 2008 21:20 GMT
a string will never match a number so you're never going to see "MATCH...".
and the loop's not freezing if you repeatedly see "No match..." statements.
you can infer _root.screen is no longer changing frames if you repeatedly see
"... 1.2333333333333...".
erlendbv - 16 Jul 2008 21:36 GMT
Hi kglad. Thanks for replying.
Actually, the match does come up, as I pasted this text from the Output-window
in Flash. I was also worried about strings vs. numbers, but I guess I was lucky
this time. ;-)
I agree with you, that if the loop repeats frame 37, that must mean that the
_root.screen doesn't progress. However, I am loading up a "debug-SWF" into
_root.screen that shows it's own frame-progress. The strange thing is that
while the for-loop gets stuck on frame 37, the loaded SWF keeps running frames.
So even though the output keeps posting the traces from the for-loop at frame
37, I can see the SWF-preview running the entire playback.
Please give your suggestions.
Thanks in advance.
kglad - 16 Jul 2008 22:00 GMT
the main timeline of the swf loaded into _root.screen must stop on frame 37 or repeatedly return to frame 37.
erlendbv - 16 Jul 2008 22:24 GMT
It doesn't seem like it, because the movieclip clearly plays back without any visible jumping. Is there some way it could be tested?
kglad - 16 Jul 2008 23:03 GMT
you could place the following in frame 37 of that swf's main timeline:
if(!timesPlayed){
timesPlayed=1;
} else {
timesPlayed++;
}
trace(this._currentframe+" played: "+timesPlayed);
erlendbv - 17 Jul 2008 01:36 GMT
Nice. Thanks for the suggestion. I will test this and get back to you. :)
kglad - 17 Jul 2008 04:01 GMT
erlendbv - 18 Jul 2008 01:51 GMT
Ah. After hours of trial and error, I finally remembered...
The SWF was created with Captivate, which does not respond very well to
_currentframe. The issue is solved by using the variable rdinfoCurrentFrame.
Thanks for your time kglad. You helped me on the right path. :)
kglad - 18 Jul 2008 06:17 GMT
you're welcome. glad you found the issue.