11-20-2008, 02:23 PM
|
#1
|
|
Registered User
Join Date: Aug 2008
Location: Chicago
Posts: 2
|
setInterval not triggering events based on FLV
Hello,
This is my first post to the forum so, I apologize for any mistakes. I've inherited a project that plays an FLV that streams and events are triggered when certain points are reached based on the video by using the "switch" method. As the FLV is played, a "setInterval" function checks the time every second to see how many seconds have elapsed, which then triggers certain events to happen. The issue is that certain events aren't being triggered; however, there have been instances where all of the events are triggered. Is there a way to create some kind of check to guarantee that every event is triggered? The alternative solution that I have come up with would be to tween all of the needed "events" frame-by-frame, as oppose to how it is now, which is using only 2 frames. Thank you in advance.
ActionScript Code:
var time_interval:Number = setInterval (checkTime, 1000, netStrm);
// Function to check time based on "time_interval" variable
function checkTime (myVideo_ns:NetStream) {
var ns_seconds:Number = myVideo_ns.time;
var minutes:Number = Math.floor (ns_seconds / 60);
var seconds = Math.floor (ns_seconds % 60);
var totalSeconds = (minutes * 60) + seconds;
if (seconds < 10) {
seconds = ("0" + seconds);
}
time_mc.timeTextBox_txt.text = minutes + ":" + seconds;
// Trigger animations based on seconds elapsed
switch (totalSeconds) {
case 1 :
//loadAnim_mc._visible = false;
cctbLogo_mc._visible = false;
myVideo_mc.alphaTo (100,(animSpeed * 2),animType);
loadAnim_mc.alphaTo (0,animSpeed,animType);
updateAfterEvent ();
break;
case 23 :
//netStrm.pause ();
myVideo_mc.alphaTo (0,(animSpeed * 1.5),animType);
updateAfterEvent ();
break;
case 24 :
myVideo_mc._x = 665;
myVideo_mc._y = 155;
myVideo_mc.alphaTo (100,(animSpeed * 2),animType);
//netStrm.pause ();
updateAfterEvent ();
break;
case 29 :
animScrnIn (hmPg_mc,315,155,100,100);
updateAfterEvent ();
break;
case 42 :
animScrnOut (hmPg_mc);
updateAfterEvent ();
break;
case 45 :
mrktGuidesTxt_mc.gotoAndPlay ("anim");
textIn (mrktGuidesTxt_mc,xForText,yForText - 90);
updateAfterEvent ();
break;
case 47 :
//textOut (mrktGuidesTxt_mc);
templatesTxt_mc.gotoAndPlay ("anim");
textIn (templatesTxt_mc,xForText,yForText - 30);
updateAfterEvent ();
break;
case 48 :
//textOut (templatesTxt_mc);
elementsTxt_mc.gotoAndPlay ("anim");
textIn (elementsTxt_mc,xForText,yForText + 30);
updateAfterEvent ();
break;
case 49 :
chiContentTxt_mc.gotoAndPlay ("anim");
textIn (chiContentTxt_mc,xForText,yForText + 90);
updateAfterEvent ();
break;
case 60 :// Clear text call-outs
textOut (mrktGuidesTxt_mc);
textOut (templatesTxt_mc);
textOut (elementsTxt_mc);
textOut (chiContentTxt_mc);
updateAfterEvent ();
break;
case 64 :
richBaseTxt_mc.gotoAndPlay("anim");
textIn (richBaseTxt_mc,xForText,yForText - 40);
updateAfterEvent ();
break;
case 69 :
textOut (richBaseTxt_mc);
webcastsTxt_mc.gotoAndPlay ("anim");
textIn (webcastsTxt_mc,xForText,yForText - 90);
updateAfterEvent ();
break;
case 75 :
webcastsTxt_mc.xSlideTo (xForText - 80,animSpeed,animType);
textIn (emailTxt_mc,xForText - 130,yForText - 50);
updateAfterEvent ();
break;
case 77 :
textIn (womTxt_mc,xForText - 130,yForText - 0);
updateAfterEvent ();
break;
case 79 :
textIn (andMoreTxt_mc,xForText - 130,yForText + 50);
updateAfterEvent ();
break;
case 85 :
textOut (webcastsTxt_mc);
textOut (emailTxt_mc);
textOut (womTxt_mc);
textOut (andMoreTxt_mc);
updateAfterEvent ();
break;
case 90 :
animScrnIn (hmPg2_mc,280,170,100,75);
updateAfterEvent ();
break;
case 96 :
animBtnIn (hmPg2_mc.ad_mc,-264,-40);
updateAfterEvent ();
break;
case 98 :
animBtnIn (hmPg2_mc.web_mc,-132,-40);
updateAfterEvent ();
break;
case 100 :
animBtnIn (hmPg2_mc.mar_mc,0,-40);
updateAfterEvent ();
break;
case 102 :
animBtnIn (hmPg2_mc.pr_mc,132,-40);
updateAfterEvent ();
break;
case 104 :
animBtnIn (hmPg2_mc.city_mc,264,-40);
updateAfterEvent ();
break;
case 106 :
placeClip (hmPg2_mc.ad_mc,0,-40);
hmPg2_mc.ad_mc.gotoAndPlay ("boxIn");
placeClip (hmPg2_mc.web_mc,152,-40);
placeClip (hmPg2_mc.mar_mc,264,-40);
placeClip (hmPg2_mc.pr_mc,-264,-40);
placeClip (hmPg2_mc.city_mc,-152,-40);
updateAfterEvent ();
break;
case 115 :
hmPg2_mc.ad_mc.gotoAndPlay ("boxOut");
placeClip (hmPg2_mc.ad_mc,0,-40);
placeClip (hmPg2_mc.web_mc,132,-40);
placeClip (hmPg2_mc.mar_mc,264,-40);
placeClip (hmPg2_mc.pr_mc,-264,-40);
placeClip (hmPg2_mc.city_mc,-132,-40);
updateAfterEvent ();
break;
case 117 :
placeClip (hmPg2_mc.web_mc,0,-40);
hmPg2_mc.web_mc.gotoAndPlay ("boxIn");
placeClip (hmPg2_mc.mar_mc,152,-40);
placeClip (hmPg2_mc.pr_mc,264,-40);
placeClip (hmPg2_mc.city_mc,-264,-40);
placeClip (hmPg2_mc.ad_mc,-152,-40);
updateAfterEvent ();
break;
case 125 :
hmPg2_mc.web_mc.gotoAndPlay ("boxOut");
placeClip (hmPg2_mc.ad_mc,-132,-40);
placeClip (hmPg2_mc.web_mc,0,-40);
placeClip (hmPg2_mc.mar_mc,132,-40);
placeClip (hmPg2_mc.pr_mc,264,-40);
placeClip (hmPg2_mc.city_mc,-264,-40);
updateAfterEvent ();
break;
case 127 :
placeClip (hmPg2_mc.mar_mc,0,-40);
hmPg2_mc.mar_mc.gotoAndPlay ("boxIn");
placeClip (hmPg2_mc.pr_mc,152,-40);
placeClip (hmPg2_mc.city_mc,264,-40);
placeClip (hmPg2_mc.ad_mc,-264,-40);
placeClip (hmPg2_mc.web_mc,-152,-40);
updateAfterEvent ();
break;
case 131 :
hmPg2_mc.mar_mc.gotoAndPlay ("boxOut");
placeClip (hmPg2_mc.ad_mc,-264,-40);
placeClip (hmPg2_mc.web_mc,-132,-40);
placeClip (hmPg2_mc.mar_mc,0,-40);
placeClip (hmPg2_mc.pr_mc,132,-40);
placeClip (hmPg2_mc.city_mc,264,-40);
updateAfterEvent ();
break;
case 133 :
placeClip (hmPg2_mc.pr_mc,0,-40);
hmPg2_mc.pr_mc.gotoAndPlay ("boxIn");
placeClip (hmPg2_mc.city_mc,152,-40);
placeClip (hmPg2_mc.ad_mc,264,-40);
placeClip (hmPg2_mc.web_mc,-264,-40);
placeClip (hmPg2_mc.mar_mc,-152,-40);
updateAfterEvent ();
break;
case 145 :
hmPg2_mc.pr_mc.gotoAndPlay ("boxOut");
placeClip (hmPg2_mc.ad_mc,264,-40);
placeClip (hmPg2_mc.web_mc,-264,-40);
placeClip (hmPg2_mc.mar_mc,-132,-40);
placeClip (hmPg2_mc.pr_mc,0,-40);
placeClip (hmPg2_mc.city_mc,132,-40);
updateAfterEvent ();
break;
case 147 :
placeClip (hmPg2_mc.city_mc,0,-40);
hmPg2_mc.city_mc.gotoAndPlay ("boxIn");
placeClip (hmPg2_mc.ad_mc,152,-40);
placeClip (hmPg2_mc.web_mc,264,-40);
placeClip (hmPg2_mc.mar_mc,-264,-40);
placeClip (hmPg2_mc.pr_mc,-152,-40);
updateAfterEvent ();
break;
case 155 :
hmPg2_mc.city_mc.gotoAndPlay ("boxOut");
placeClip (hmPg2_mc.ad_mc,152,-40);
placeClip (hmPg2_mc.web_mc,264,-40);
placeClip (hmPg2_mc.mar_mc,-264,-40);
placeClip (hmPg2_mc.pr_mc,-132,-40);
placeClip (hmPg2_mc.city_mc,0,-40);
updateAfterEvent ();
break;
case 156 :
animScrnOut (hmPg2_mc);
updateAfterEvent ();
break;
case 158 :
animScrnIn (hmPg_mc,315,155,100,100);
updateAfterEvent ();
break;
case 160 :
mostPopDL_mc._visible = true;
mostPopDL_mc.gotoAndPlay (2);
updateAfterEvent ();
break;
case 161 :
hmPg_mc._visible = false;
updateAfterEvent ();
break;
case 166 :
animScrnOut (mostPopDL_mc);
myVideo_mc.alphaTo (0,(animSpeed * 2),animType);
updateAfterEvent ();
break;
case 167 :
myVideo_mc._x = 405;
myVideo_mc._y = 155;
myVideo_mc.alphaTo (100,(animSpeed * 2),animType);
updateAfterEvent ();
break;
case 194 :
netStrm.pause ();
netStrm.seek (0);
playback_mc.gotoAndStop ("paused");
playBoolean = false;
myVideo_mc.alphaTo (0,(animSpeed * 2),animType);
cctbLogo_mc._visible = true;
cctbLogo_mc.alphaTo (100,(animSpeed * 2),animType);
updateAfterEvent ();
break;
}
updateAfterEvent ();
}
// Play NetStream
netStrm.play (_root.flvFile);
stop ();
|
|
|
11-20-2008, 03:30 PM
|
#2
|
|
Senior Member
Join Date: Jul 2007
Posts: 216
|
Not sure if this is going to help you or not (since I haven't worked a whole lot with the switch method - or - setInterval). However, I'm interested in learning about your code. So... Is it true that your code will re-check itself every 1 second - based on the initial time interval var? Is it also true that the number following case corresponds to a second? If that's the case then I think the problem is you need to have the setInterval check every 1/10 of a second - otherwise it might miss the case "trigger" - Yes?
One other note: Some of your animations happen over a 1.5 second elapsed time (see case 23) - but, then the next case (case 24) happens in under that 1.5 second time (again assuming the number after case corresponds to seconds). Won't that cause a problem?
Finally, if you can recreate the .FLV - you can add cue-points to the .FLV file itself - then you'll know each and every event associated with a cue-point will be triggered.
Alternatively, you can look to adding cue-points dynamically through actionscript.
You should look at the following. (I've done this before and it's pretty easy)...
http://livedocs.adobe.com/flash/8/ma...=00001574.html
|
|
|
11-20-2008, 04:13 PM
|
#3
|
|
Registered User
Join Date: Aug 2008
Location: Chicago
Posts: 2
|
Thank you RefreshGFX for your reply  Some of the animations that are triggered are independent from the FLV that's played. I had the setInterval check every 1/10 of a second, but because of the way the triggers are currently set, the events would be triggered, in this case, 10 times.
I'm looking through the livedocs on adobe, and am trying to get my hands on the original video file to encode again with cue points, which would mean I'd have to rewrite some code. Basically, I'm looking at my possible solutions and timeline to figure out what to do.
Thanx again.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 12:39 AM.
///
|
|