Created
January 17, 2013 15:41
-
-
Save fro/4556848 to your computer and use it in GitHub Desktop.
This is a simplified pseudo-code example of my main Class which extend the (fl5) Player class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package { | |
// [ ... ] | |
// simplified pseudo-code to show the mecanism... | |
public class MyCustomPlayer extends Player { | |
// [ ... ] | |
private function setComponents():void { | |
_components_array = new Array(); | |
// populate _components_array here with texts, arrows & shapes objects... | |
// a component is something like {cue_point_in_position:null, cue_point_out_position:null, type:'text', data:'Hello world'} | |
_components_array_length = _components_array.length; | |
} | |
private function onInterfaceLoaded(evt:InterfaceEvent):void { | |
// [ ... ] | |
addEventListener(MediaEvent.JWPLAYER_MEDIA_TIME, mediaTime); | |
// [ ... ] | |
} | |
// here's my main problem... mediaTime function is not "called enough" :-( | |
// I need a highest framerate, but how ? | |
private function mediaTime(evt:MediaEvent):void { | |
// the current playhead position when mediaTime function is called | |
var position:Number = evt.position; | |
var components_to_show:Array = new Array(); | |
var components_to_hide:Array = new Array(); | |
// [ ... ] | |
// let's loop through the components array | |
for (var i:uint=0 ; i<_components_array_length ; i++) { | |
var id:String = _components_array[i].id; | |
var cue_point_in_position:Number = _components_array[i].cue_point_in_position; | |
var cue_point_out_position:Number = _components_array[i].cue_point_out_position; | |
// show the object ? | |
if (position >= cue_point_in_position && position <= cue_point_out_position) { // yes, it's in the range | |
components_to_show.push(id); | |
} else { // no, hide it | |
components_to_hide.push(id); | |
} | |
} | |
// let's dispatch an event | |
var lh:uint = components_to_hide.length; | |
for (var ih:uint=0 ; ih<lh ; ih++) { | |
dispatchEvent(new ExtendedPlayerEvent(ExtendedPlayerEvent.WMPLAYER_HIDE, components_to_hide[ih])); | |
} | |
var ls:uint = components_to_show.length; | |
for (var ish:uint=0 ; ish<ls ; ish++) { | |
dispatchEvent(new ExtendedPlayerEvent(ExtendedPlayerEvent.WMPLAYER_SHOW, components_to_show[ish])); | |
} | |
// [ ... ] | |
} | |
// [ ... ] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment