Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
I edited the doLater extension to allow for any amount of time delay to be run as needed based off coppercube variable ('delay'). Its helped tidy up my javascript into neat sections this way. // This is a scripted coppercube action. // It does an action after variable 'delay' received /* <action jsname="action_DoLaterVar" description="Do later with variable delay"> <property name="ActionToDo" type="action" /> </action> */ action_DoLaterVar = function(){}; action_DoLaterVar.prototype.execute = function(currentNode) { var me = this; var wait = ccbGetCopperCubeVariable("delay"); this.registeredFunction = function() { me.variableWait(); }; ccbRegisterOnFrameEvent(me.registeredFunction); this.startTime = (new Date()).getTime(); this.endTime = this.startTime-(-wait); this.currentNode = currentNode; } action_DoLaterVar.prototype.variableWait = function() { var now = (new Date()).getTime(); if (now > this.endTime) { ccbInvokeAction(this.ActionToDo, this.currentNode); ccbUnregisterOnFrameEvent(this.registeredFunction); } } |
||||
|
Hey Robo, thanks for the code quick question...how does this extension exactly work? can you explain a scenario or example where you would use this? thanks CF |
||||
|
All you have to do is create a variable called 'delay' and give it a value in milliseconds to match the time delay you want for a once off time delay action. Its an action extension that you need to create - just copy and paste the above and change name to 'action_DoLaterVar'. The delay variable must be setup before running this action. Reload and verify extensions inside CC and you then have this in the list that can be selected as an available action. Why have this ? - I needed this a few times when playing different music tracks with different lengths or when I needed to play different sound effects with different lengths depending on size of container being opened, and once played do something afterwards. Stay tuned to next video coming soon - will show this off in the video.. |
||||
|
Robo wrote: All you have to do is create a variable called 'delay' and give it a value in milliseconds to match the time delay you want for a once off time delay action. Its an action extension that you need to create - just copy and paste the above and change name to 'action_DoLaterVar'. Thanks bunches, Robo! we appreciate your knowledge and contributions. Going to try this out! best, CF |
|