PDA

View Full Version : Cue point help


demerit
10-22-2007, 07:19 PM
Hi,

BACKGROUND:

I'm attempting to have embedded event cue points within audio-only .flv's (loaded into an FLVPlayback component) trigger animation changes within mainly AS-driven .swf movies (loaded into a movieclip, onstage).

The main movie listens for the cuepoint events and sends the event cue point parameter to a makechange function within the .swf. Inside the .swf, a switch statement takes care of making the animation changes (cases 1-n).

PROBLEM:

When one seeks (let's say from cue point/case 1 to cue point/case 8), the cue points/events/cases from 2-7 get skipped and the animation gets out-of-sync. Same with rewind.

WISH:

It'd be swell to have the animations automatically update post-seek.

GRIM REALITY:

Unless I merge the audio and animation, I am going to have to code each .swf so that whenever a seek is performed, the .swf knows exactly where the .flv playHead is and how the animation needs to be set up, making all the necessary animation changes instantaneous (and "invisibly"), so that the subsequent event cue points can pick up the animation from there.

Seems like a lot of extra work to code-in resets for each navigation cue point. But I don't relish the idea of going back and re-doing all these animations timeline-style... besides, I'd feel like I was dumbing it down instead of having it AS-driven (trying to push myself, you know).

WHERE I'M STUCK:

Axing the scrub bar, I'm setting up navigation cue points to limit the seek possibilities to pre-defined points where I can control setting up the animations properly.

However, the only useful property of the "rewind" or "fastForward" events is the playheadTime. But, using that seems a little sloppy considering the slight variation in the time it returns.

The following is how I've got the listener & function set up.


myFLVPlayback.addEventListener("fastForward",whichnavigationcuepoint);
whichnavigationcuepoint = function(eventObject:Object){
container.setupanimation(eventObject.playheadTime) ;
}


Is there any way to change the scope of the ffw/rew listeners to refer to the navigation cue point? So that whichnavigationcuepoint can send the navigation cue point's parameter to the setupanimation function within the .swf?

Or am I going to have to implement a series of if/then statements with conditions satisfied by slightly varying playheadTimes?




ADDITIONAL AS:

The main movie listens for the cue point events in the .flv and sends them to a function within the .swf:

import mx.video.FLVPlayback;
import mx.utils.Delegate;

//---------------------------------Initialize variables, create .swf container mc

var cfp:FLVPlayback;
var container:MovieClip = createEmptyMovieClip("container", getNextHighestDepth());

//---------------------------------Load external .swf

var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);
mcLoader.loadClip("picture004.swf",container);
function onLoadInit(mc:MovieClip) { //Add cuePoint event listener
myFLVPlayback.addEventListener("cuePoint",Delegate.create(this, fireanimation));
}

//---------------------------------Function to send animation change # to .swf

function fireanimation(oEvent:Object):Void {
container.makechange(parseInt(oEvent.info.paramete rs.whichchange));
}

Each .swf uses a switch statement to make the appropriate animation changes:


makechange = function (b:Number) {
switch (b) {
case 1 :
fadein("buckingham_mc");
break;
case 2 :
fadein("aerodynamicforceheader_mc");
break;
case 3 :
fadein("aerodynamicforceequation_mc");
break;
case 4 :
makered("aerodynamicforceequation_mc",1);
break;
case 5 :
makered("aerodynamicforceequation_mc",2);
break;
case 6 :
makered("aerodynamicforceequation_mc",3);
break;
case 7 :
//Dynamic Pressure
makered("aerodynamicforceequation_mc",4,0,"finis");
fadeout("buckingham_mc");
fadeout("aerodynamicforceheader_mc");
fadeout("aerodynamicforceequation_mc");
fadein("dynamicpressureheader_mc",.5);
break;
case 8 :
//Show equation
for (c=3; c<11; c++) {
itemname = "change"+c;
aerodynamicforceequation_mc[itemname]._alpha = 0;
}
fadein("dynamicpressureequation_mc");
break;
.
. (etc)
.
default:
break;
}

wvxvw
10-23-2007, 02:58 AM
"oEvent.info.parameters.whichchange" is this something MM invented, or is it the way you wish it to work? (if the 1st, it seems like it should work).
Sorry, you've made so detailed explanation, but, somehow you've missed the main poin. What do you want this 2 weirdest creations of MM (FLV-component and Delegate %) to do?
Wouldn't it be much easier to create your own class, that'd handle video stream and broadcast the event onCuePoin in the way, you find more proper for your purposes?

upd..........
"oEvent.info.parameters.whichchange" or do you fill this parameter manualy every time you convert your sound to FLV? Should be tonns of handwork...

demerit
10-23-2007, 02:31 PM
I'm editing my soundfiles in Soundbooth where I'm adding the markers, and yes, hand-coding the parameter, whichchange, for each marker

So, the "oEvent.info.parameters.whichchange" bit is sending that parameter value to the .swf to make the corresponding animation changes.

If we're on the "same page", could you explain to me (in a general fashion) why creating a custom class would be be beneficial?

Are you saying that by creating a custom class, I'd be standardizing the way the animations are taking place? So, I'd have to create a class that covers every possible animation and have the class be the intermediary between the .flv and .swf?

Thanks so much for your input,

-D

wvxvw
10-23-2007, 03:09 PM
To be quick, you custom class will work with onCuePoint event (which is the basic event, like onPress), so you will be able to get all the info possible about this event, to modify it before transmitting further as well, as you will be able to configure subscription/unsubsubscription/listeners list in the way you like.
here's the scetch for the class:
class MyConnector {
private var __ns:NetStream;
function MyConnector(){
_global.AsBroadcaster.initialize(this);
// some code....
var __t:MyConnector = this;
__ns.onCuePoint = function(o:Object):Void {
__t["broadcastMessage"]("myDarlingCuePoint",o.info.parameters.whichchange);
}
}
public function __addListener(o:Object):Number {
this["_listeners"].push(o);
return this["_listeners"].length;
}
public function __removeListener(n:Number):Void {
this["_listeners"].splice(n,1,null);
}
}
Somewhere further in your code:
var mync:MyConnector = new MyConnector();
var _l:Object = {};
_l.myDarlingCuePoint = function(s:String):Void {
_root.someAnimation_mc.gotoAndStop(parseInt(s,10)) ;
}
var shouldUnsubscribeSomeDay:Number = mync.__addListener(_l);
mync.__removeListener(shouldUnsubscribeSomeDay);

demerit
10-23-2007, 07:55 PM
I'm starting to understand custom classes, so let me see if I have this straight.

This custom class will allow me to create a new NetStream connector, on the fly, in my main movie.

When this happens, it adds a listener and the onCuePoint event (set up by the custom class) sends the cue point's parameter, whichchange, to the myDarlingCuePoint property of the _l object...

... which then gets sent to my animation via _root.someAnimation_mc.gotoAndStop(parseInt(s,10)) ;

Then, at some point (further in my code), I remove the listener.


Am I getting it?
:confused:

wvxvw
10-23-2007, 11:39 PM
Mostly like it, however myDarlingCuePoint is an event (not a property).
One of the benefits you get when creating your custom event is that you may sort your listeners in grupps by defining event-handler functions for them.
Like, you may want to have 2 different records in the info-object of cuePoint, so that you may check which of the 2 is defined, and according to it fire some certain event. Say, half of you clips should move to the right on even cuePoin, and the other half should move left on the odd cuePoint. So, you may create 1 method, which will move clips depending on the parameter passed to it, or you may create 2 different methods for moving left and right, and to call them when needed. (I would certanly prefer the second, because it uses less resources).
My example is a simplified version of what the FLVPlayback component does. But it is customised to broadcast only valuable data, and it gives an option to create multiple events depending on the data received.

demerit
10-25-2007, 02:32 PM
I see what you're saying, that will probably come in handy at some point.

I think my immediate need is to figure out a way to update the animation after seeking (scrub bar, ffw, rew) so that the animation can be "staged" when seeking has stopped, inbetween two cuepoints.

So I guess I would need to use the event "scrubFinish" to send the playHead time to a "reset" function. Then, using a series of "if" statements, the function would then reset the .swf animation to be "staged" according to the playhead's time.

-------------
UPDATE
-------------

After others have sat on this project for 4 years, I'm getting the brunt of the pressure to get this done. So there's really no more time for R&D. I've decided to animate in the timeline, export as a .mov, and encode that as an .flv in order to merge the audio & animation. Now, there's no need for "reset" functions and the rew/ffw/scrub can take place without further ado.

Thanks for your help, wvxvw.

-D

wvxvw
10-25-2007, 03:56 PM
You're welcome %)
It seems like you may be looking for it soon =) AviScreen, Fraps, Vegas... I mean some program that'll record whatever is going on the screen =)