FORUMS: list search recent posts

Having trouble dynamically setting cuepoints for an FLV....

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
blkhwks19
Having trouble dynamically setting cuepoints for an FLV....
on Feb 14, 2007 at 9:18:09 pm

I have an FLV whose instance name is "vid" (the contentPath property is set in the component inspector, so its available right away). I added my code to add cuepoints:

vid.addASCuePoint(0.1, "1");
vid.addASCuePoint(5, "2");
vid.addASCuePoint(10, "3");
vid.addASCuePoint(22, "4");
vid.addASCuePoint(27, "5");


Then I added my code for the listener object, which listens for a cuepoint event. In other words, every time a cuepoint is reached, it triggers my listener object, which in turns triggers a block of code to be executed (currently that block of code is only a trace command, to test that it's working). Here's that code (I copied and pasted the whole thing from Flash's help document, with the exception of inserting my own FLV instance name in the last line):

var listenerObject:Object = new Object();
listenerObject.cuePoint = function(eventObject:Object):Void {
trace("cue point reached at: " + eventObject.info.time);
};
vid.addEventListener("cuePoint", listenerObject);



So far everything works flawlessly. Now I would like to add the cue points automatically, pulling the times from an external TXT file. Ive loaded that text file in and put the times into an array (cparray), using a for loop, so it will load in however many times there are in the TXT file. So now cparray holds the following:

0.1,5,10,22,27 (Those are my 5 times for now, for testing purposes)

Here's the for loop I wrote to take each of those times and add it as a cue point:

for (t=0; t<=cparray.length-1; t++) {
vid.addASCuePoint(cparray[t], t);
}

For some reason, this works, but not correctly. I can play back the video all the way through and the cuepoints do not register to the output window until the very last cuepoint hits. Then all cuepoitns display, but they are not in sequential order. Its very bizarre and I cant figure out why its doing this.

Any thoughts? Might be easier to take a look at my file directly, let me know.

Thanks in advance!!!



Return to posts index

grafxflow
Re: Having trouble dynamically setting cuepoints for an FLV....
on Feb 14, 2007 at 10:01:21 pm

Hi,

Try instead of a text file using a xml file. When flash loads a text file it carries on playing/actionscript regardless of whether the txt file has fully loaded or not. But when using an xml file it pauses all actions until it has loaded.

grafxflow

grafx that flow!


Return to posts index

blkhwks19
Re: Having trouble dynamically setting cuepoints for an FLV....
on Feb 14, 2007 at 10:08:41 pm

Could it really be taking that long to load in the text file? The text file only contains the following:

&cp1=0&
&cp2=5&
&cp3=10&
&cp4=22&
&cp5=27&

SO what youre saying is that its taking nearly 30 seconds to load that much data in. Just making sure Im clear on this.



Return to posts index


grafxflow
Re: Having trouble dynamically setting cuepoints for an FLV....
on Feb 14, 2007 at 10:35:45 pm

Hi,

No, what I am saying is that when your text file is loading, instead of flash waiting until that data is fully loaded and separating the array into chapters, it is actualy jumping and playing the movie flv.

But when loading an xml file it will wait for the file to be fully loaded before splitting the data into arrays and chapters. Before carrying on to the next action of playing the flv.

This is why the actionscript when loading xml is as follows:

function loadXML(loaded) {
if (loaded)

grafxflow

grafx that flow!


Return to posts index

blkhwks19
Re: Having trouble dynamically setting cuepoints for an FLV....
on Feb 14, 2007 at 10:41:48 pm

Ok I get it. But with that load function you described, where does the code go for actually loading in the file? Here's the code I'm using below, is this good enough?

myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(success) {
if (success) {
//actions to put data from XML file into array in flash
} else {
trace("Error loading data.");
}
}
myXML.load("data.xml");



Return to posts index

grafxflow
Re: Having trouble dynamically setting cuepoints for an FLV....
on Feb 14, 2007 at 11:35:04 pm

Hi,

I would do it like this myself.

var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.load("data.xml");
myXML.onLoad = function (success:Boolean) {
if (success) {
//actions to put data from XML file into array in flash
trace("data loaded.");
} else {
trace("Error loading data.");
};
}

But I think yours should work just as well.

grafxflow

grafx that flow!


Return to posts index


Thumbslinger
Re: Having trouble dynamically setting cuepoints for an FLV....
on Feb 15, 2007 at 4:35:53 am

I'm not sure why you're setting cue points via an external file? Unless the video itself contains so many scenes that you have future plans to jump to different parts, why not just embed them during the flv conversion?

Less code, less overhead, fewer chances to type something wrong, etc.

The total traning for advanced Actionscript talks about cue points for captioning and navigation and suggests that embedding are more accurate anyway rather than setting via AS.

But, I'd like to know the thinking behind using a text file whether text or xml as if the video has to change, it defeats the purpose. Perhaps I may just be missing something?




Return to posts index

blkhwks19
Re: Having trouble dynamically setting cuepoints for an FLV....
on Feb 15, 2007 at 3:13:48 pm

Basically we have to create long presentations (18-20 hours worht of video, i plan to split this up into much smaller manageable chunks though), but each video is goingt o have at least 50 cue points (and slides that correspond to these cue points). The equipment we have will allow us to do a straight conversion from a digibeta tape to flv, but it does not allow for embedding cue poitns at that time, so Im restricted to AS cue points. I dont care about accuracy because I dont need to be within a tenth of a second, if i am a second or two off, its not a huge deal. In any case, ive discovered that nav cuepoints are good for seeking and AS cuepoints are good for triggering other flash events (like slides in a movie clip). So Ive found that using a text file I can write a loop to pull the time codes and put them in an array that will allow me to seek to those timecode points. However, when placing cuepoints with the text file, it begins playing the video before thet ext file is done loading and the cuepoints are done being added, so it throws everything off. XML will finish loading before the video plays, therefore my cuepoints will be set before the video plays, but with the way flash pulls data from xml in a nested format, writing a loop to do that is near impossible, well at least beyond my actionscripting knowledge.

So it seems every direction I go in, there is a snag. Im still working on it.



Return to posts index

grafxflow
Re: Having trouble dynamically setting cuepoints for an FLV....
on Feb 15, 2007 at 5:06:07 pm

Hi,

If you are trying to sync footage with slides then just do a flash slide presentation. With this you can import the flv and actually add the markers inside flash then add actionscript to tell it to add a slide at the particular marker. No need for external xml.

grafxflow

grafx that flow!


Return to posts index


flash_learner
Re: Having trouble dynamically setting cuepoints for an FLV....
on Mar 16, 2007 at 12:58:42 pm

Hi, I have been trying to do the same thing. I have one tutorial that brings the List box items in, and loads items(JPG, SWF, etc.) via XML, into another area, but I can't get AS cue points on the FLV to talk to the listbox.connects with a FLV. Then, 1 tutorial, links Video to slide, or labels, but I am using a list box, sort of like a Table of contents. I would love to do it the way you suggests, using actionscript, jumps to cue points, triggers actions, and the list box, also can jump to the cue points. I know that this is not a new ideal that i have but finding tutorials on this with listbox is almost impossible, so I am trying to rewrite the code from all the other tutorials to make one, which has increased my knowlege of actionsript in the is area, but no luck with the project. So if you guys run across any tutorials with FLV listbox, and other events happening (and not using NAVigation, but AS for cue points) please pass it on.

Thanks.



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]