//!-- UTF8 /** * Slider class for Jerlov * @author Johannes Axner */ class se.jerlov.jerlov.Slider extends MovieClip { /** * A reference to the target MovieClip */ private var target_mc:MovieClip; private var parent_mc:MovieClip; var sliderHandle_mc:MovieClip; var sliderLine_mc:MovieClip; var dragTest_bool:Boolean = false; var x_txt:Object; var lastJob_num:Number; /** * Class constructor * @param target Target MovieClip */ function Slider() { this._x = Math.round((Stage.width/2)-(this._width/2)); this._y = 580; } function init( target_mc:MovieClip, parent_mc:MovieClip ) { this.target_mc = target_mc; this.parent_mc = parent_mc; var self = this; this.sliderHandle_mc.onMouseDown = function() { trace (this) startDrag(self.sliderHandle_mc, false, 0, 0, self.sliderLine_mc._width, 0); self.dragFlag_bool = true; } this.sliderHandle_mc.onMouseMove = function() { var newJob_num:Number = Math.round(this._x/(self.sliderLine_mc._width/(self.parent_mc.jobs.length-1))) if ( newJob_num != self.lastJob_num ) { self.parent_mc.focusJob( self.parent_mc.jobs[newJob_num] ); } self.x_txt.text = newJob_num+1; self.lastJob_num = Math.round(this._x/(self.sliderLine_mc._width/(self.parent_mc.jobs.length-1))); } this.sliderHandle_mc.onRelease = function() { this.stopDrag(); } this.sliderHandle_mc.onLoad = onMouseMove; this.sliderHandle_mc.onReleaseOutside = this.sliderHandle_mc.onRelease; } function test() { this.parent_mc.unfocusJob( this.parent_mc.jobs[0] ); this.parent_mc.focusJob( this.parent_mc.jobs[1] ); } }