pseudo.Knob class
View Sample :: Return to index  
pseudo.Knob.Knob(pThis:MovieClip)
Knob constructor. You never use the constructor to create this component.

Parameters pThis The movie clip on which the new Knob will be drawn.
Returns Nothing
Example
    None


pseudo.Knob.create(pOwner:MovieClip, strName:String, nDepth:Number):pseudo.Knob
Use this static function to create new Knob on the specified movie clip. Never use constructor directly to do it.

Parameters pOwner The movie clip on which the new Knob will be drawn.
strName The new Knob instance name.
nDepth The new Knob instance depth.
Returns The reference to new Knob instance
Example
  // Create an instance of the skin look
  var look:Object = pseudo.look.AquaLook.getInstance();

  //Create an instance of the Knob component	
  knob = pseudo.Knob.create(_root, "knob", 1);

  //apply the slin to the Knob instance
  knob.setLook(look);
  knob.setSize(60, 60);

  //add listener of the "changed" to the
  knob.addListener("changed", this, onChanged);
  knob.update();
  knob.draw();

  //
  btnRadial = pseudo.RadioButton.create(_root, "btnRadial", 2);
  var lbl:pseudo.Label = pseudo.Label(btnRadial.addItem(pseudo.Label));
  lbl.setText("Radial");
  lbl.setAlign("center");
  btnRadial.addListener("mouseRelease", this, onChangeRot, 2);
  btnRadial.setLook(look);
  btnRadial.setSize(70, 24);
  btnRadial.update();
  btnRadial.draw();
  //Create three buttons to change rotation type
  btnVert = pseudo.RadioButton.create(_root, "btnVert", 3);
  lbl = pseudo.Label(btnVert.addItem(pseudo.Label));
  lbl.setText("Vert");
  lbl.setAlign("center");
  btnVert.addListener("mouseRelease", this, onChangeRot, 0);
  btnVert.setLook(look);
  btnVert.setSize(70, 24);
  btnVert.update();
  btnVert.draw();
  btnVert._y = btnRadial._y + btnRadial.getH() + 5;

  btnHorz = pseudo.RadioButton.create(_root, "btnHorz", 4);
  lbl = pseudo.Label(btnHorz.addItem(pseudo.Label));
  lbl.setText("Horz");
  lbl.setAlign("center");
  btnHorz.addListener("mouseRelease", this, onChangeRot, 1);
  btnHorz.setLook(look);
  btnHorz.setSize(70, 24);
  btnHorz.update();  
  btnHorz.draw();
  btnHorz._y = btnVert._y + btnVert.getH() + 5;
  btnRadial.setState("sunken");
  //create a field to diplay the value ot the knob
  lblPos = pseudo.Label.create(_root, "lblPos", 5);
  lblPos._y = btnHorz._y + btnHorz.getH() + 5;
  lblPos._x = 10;

  lblPos.setLook(look);
  lblPos.setSize(50, 23);
  lblPos.getData().type = "edit";
  lblPos.setText("0");
  lblPos.update();
  lblPos.draw();

  Stage.addListener(this);
  onResize();

//Function to handle "changed" event
  function onChanged():Void
  {
    lblPos.setText(String(knob.getPos()));
    lblPos.update();
    lblPos.draw();
  }

  function onResize():Void
  {
    knob._x = Math.round((Stage.width - 40) / 2);
    knob._y = Math.round((Stage.height - 40) / 2);
  }
  //Function to change the knob rotation type
  function onChangeRot(val:Number):Void
  {
    knob.setRotType(val);
  }


pseudo.Knob.setScrollLen(len:Number):Void
Sets the length in pixels for the mouse to move in order to rotate knob from min to max value (Note: only for vert/horz rotType) default scrollLen = 200.

Parameters len Number
Returns Nothing
Example
    
  //set the know rotation type to vertical or horizontal first
  knob.setRotType(0);//0 - vertical, 1 - horizontal

  knob.setScrollLen(160);//the mouse should be moved 160 pixels vetically to rotate knob
                        // from minimal value to maximal value and vice versa
		   


pseudo.Knob.getScrollLen():Number
Returns the length in pixels for the mouse to move in order to rotate knob from min to max value (Note: only for vert/horz rotType) default scrollLen = 200.

Parameters None
Returns Number value indicating the length for the mouse to move in order to rotate the knob
Example
    
  trace(knob.getScrollLen());//traces the mouse scroll length the knob
		   


pseudo.Knob.setRotRange(start:Number, stop:Number):Void
Sets the start angle for the min value and stop angle for max value. Default values: start=15; stop=360-15.

Parameters start Number
stop Number
Returns Nothing
Example
    
  knob.setRotRange(50, 250);
		   


pseudo.Knob.setRange(min:Number, max:Number):Void
Sets min and max values for the knob. Default values: min=0; max=100.

Parameters min Number
max Number
Returns Nothing
Example
    
  knob.setRange(0, 250);//sets the minimal value to 0 and the 
                        //maximal value to 250
		   


pseudo.Knob.getMin():Number
Returns the minimal value of the knob

Parameters None
Returns Number value
Example
  trace(knob.getMin());//traces the minimum value of the knob

pseudo.Knob. getMax():Number
Returns the maximal value of the knob

Parameters None
Returns Number value
Example
  trace(knob.getMax());//traces the maximum value of the knob

pseudo.Knob.setRotType(rotType:Number):Void
Sets the type of rotation

Parameters rotType Number The type of rotation: 0 - vert, 1 - horz, 2 - radial. The default value rotType=2
Returns Nothing
Example
    
  knob.setRotType(1);//Set rotation type to horizontal
				  

pseudo.Knob.getRotType():Number
Returns the number indicating he type of rotation: 0 - vert, 1 - horz, 2 - radial

Parameters None
Returns Number value
Example
    
  trace(knob.getRotType());//traces the value indicating the rotation type of the knob
				  

pseudo.Knob.setPos(pos:Number):Void
Sets the current position of the knob. The default position 0.

Parameters pos Number
Returns Nothing
Example
    
  knob.setPos(10);//Sets current position of the knob to 10				  
				  

pseudo.Knob.getPos():Number
Returns the number indicating the current position of the knob.

Parameters None
Returns Number value
Example
  trace(knob.getPos());//traces the current value of the knob

 

Flash UI Components (c)TUFaT.com, All Rights Reserved.