a Tuesday feature

by William Hurley

Some Questions About a Section of the Transition Code

In answer to the questions I've received from several readers, this week we take a further look at one more section of the code from Macromedia's transition Xtra. So here is the code in question along with some short explanation about what the code does. Next week we will need to move on since we do need to stick to the subject of Shockwave and we don't want to digress down the C programming path to far.

Let's look at each part of the code you have asked questions about an answer some of your questions. To do this we will break the code into four main sections and give a quick overview of each section. We will also comment out some of the features. The additional comments are denoted by the use of the /* and */ in the code.

Section Number One

STDMETHODIMP
CStretchActor_IMoaMmXTransitionActor_Notify(CStretchActor_Imoa
MmXTransitionActor FAR * This,
MoaLong msgCode,
PMoaVoid refCon)

This section of code (and the code that follows it in the complete example above) is called by Director and tells the transition that we are about to execute it. I wish it did more, but it is very strait forward. You should not have to change anything in this section of the code for your custom Xtras.

Section Number Two

STDMETHODIMP
CStretchActor_IMoaMmXTransitionActor_Cue(CStretchActor_IMoaMm
XTransitionActor FAR * This,
PIMoaMmGC pDestGC,
PIMoaMmGC pSrcGC,
ConstPMoaRect pRect,
ConstPMoaMmTransInfo pTransInfo)
{
X_ENTER
MoaError err = kMoaErr_NoErr;

/* Nothing to do. */

X_RETURN(MoaError, err);
X_EXIT
}

This section of code sets the cue for the transition to the beginning. In other words it tells the transition that we will be starting at the first point of the transition not at any other point.

Section Number Three

This section is the meat of the code. In this segment of code, the transition actually occurs. Let's pick apart the contents of this section a little further. My simple comments are in bold to help, but they are short and simple. If you need further help you may want to pick up a good book on C (or C++).

STDMETHODIMP
CStretchActor_IMoaMmXTransitionActor_Continue(Cstretch
Actor_IMoaMmXTransitionActor FAR * This,
PIMoaMmGC pDestGC, /*Graphic context (GC) output of transition*/
PIMoaMmGC pSrcGC, /*graphics context input of transition*/
ConstPMoaRect pRect, /*the size of the graphics context in pixels*/
ConstPMoaMmTransInfo pTransInfo,
MoaBoolParam FAR * pFinished) /*this tells Director that the transition is finished*/
{
X_ENTER

MoaError err = kMoaErr_NoErr;
MoaRect curRect;

/* Do it all in one big step. This isn't normally recommended, because it prevents the end user from being able to export the transition. */

curRect = *pRect; /*First assign the size of the source GC to curRect*/
curRect.right = curRect.left; /* Make width of GC 0 to begin*/

while (curRect.right < pRect->right)
{
pDestGC->lpVtbl->Blit( /* Blit takes the source picture and puts it into an output GC of the size that is provided to this function by curRect*/
pDestGC, /*this is the output of the Blit function*/
&curRect, /* size of the output GC*/
pSrcGC, /* input GC to the Blit function*/
pRect, /* the size of the Input GC*/
kMoaMmInk_Copy, /*strait copy command*/
NULL /* ink Params */, /*NULL= not used*/
NULL /* clipRegion */); /*NULL= not used*/
curRect.right += 24; /* adds 24 pixels to the right side of our rectangle*/
}

/* Transition is done, ensure we have the final destination image. */

pDestGC->lpVtbl->Blit( /*executes Blit command to make the GC output the same size as the GC input*/
pDestGC,
pRect,
pSrcGC,
pRect,
kMoaMmInk_Copy,
NULL /* ink Params */,
NULL /* clipRegion */);

*pFinished = TRUE; /*tells Director that the transition is finished*/

X_RETURN(MoaError, err);
X_EXIT
}

Section Number Four

The finish function is called by Director to do the final cleanup work after a transition is executed (such as memory reallocation).

STDMETHODIMP
CStretchActor_IMoaMmXTransitionActor_Finish(CStretchActor_IMoaMmXTransitionA
ctor FAR * This,
PIMoaMmGC pDestGC,
PIMoaMmGC pSrcGC,
ConstPMoaRect pRect,
ConstPMoaMmTransInfo pTransInfo)
{
X_ENTER
MoaError err = kMoaErr_NoErr;

/* Nothing to do. */

X_RETURN(MoaError, err);
X_EXIT
}

I hope the comments I've added have put an end to some of your questions on transitions. If for some reason there are more questions, I will try to answer them on a case-by-case basis via e-mail. For now its time to move the column on. Until next week . . .

Past installments of Simply Shocking

http://www.internet.com/