On Frame Change Event

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

On Frame Change Event // Scriptorium

1  |  

Post by ivampretti // Aug 28, 2008, 2:26pm

ivampretti
Total Posts: 151
pic
Is there an way to create a onFrameChangeEvent()?? or it alredy exists??

Post by Norm // Aug 29, 2008, 3:05am

Norm
Total Posts: 862
pic
It is possible to create what is called a "custom event handler". Custom event handler is part of the Advanced Handler scenario in Script Editor. You can click on the Advanced Handler Icon in the Script Editor toolbar. It is the right-most icon on the Script Editor toolbar.

You can delete all the added Advanced Handlers and leave only the OnCustomEvent(params) function.


function OnCustomEvent(params)
{
var eventData = params.Param('vtEventData');
}


This advanced handler would be located in a script somewhere. In another script where you are catching a frame change, you utilize another piece of code from the Script Editor. When you begin to type in "RsApp.", autocomplete shows list ..... and you find following:


RsApp.SendCustomEvent(str, var);


The string part of the call is the path to the script hosting the OnCustomEvent() function.
The variable part is a number. You can start with "1" as it may be the only custom event you use. If you had more than one custom event you were going to call, you expand the OnCustomEvent() function to handle multiple scenarios.

When you send the custom event trigger to the script hosting the OnCustomEvent() function, it runs the code for that event handle.

I attached 2 examples I created some time ago for beta testing. They work ok in ts7.6 and show a couple of different ways to handle the custom events. Once uses a set of "case" statements to handle different events, while the other "if" statements to differentiate between custom events.

I named them in pairs sort of :)

jScustomEvent.RsObj & jScustEvTrig.RsObj
jScustomEventCase.RsObj & jScustEvTrigCase.RsObjIt is an interesting way to show custom events happening. You can see how the control works as the scenario plays out.

So you just trap the change of frame and call a custom event.

HTH :)

Post by ivampretti // Aug 29, 2008, 9:01am

ivampretti
Total Posts: 151
pic
Thanks very much Norm! I'm going to test it!
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2020. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn