Packageorg.wiiflash
Classpublic final class Nunchuk
Implementsflash.events.IEventDispatcher

The Nunchuk class represents a Nunchuk. A Nunchuk object can not be created manually. The only access to a Nunchuk is by using the nunchuk property of a Wiimote object.


Example
This example shows how to check if the Nunchuk has been plugged to the Wiimote :
  
  var wiimote:Wiimote = new Wiimote();
  myWiimote.addEventListener( WiimoteEvent.NUNCHUK_CONNECT, onNunchukConnected );
  myWiimote.addEventListener( WiimoteEvent.NUNCHUK_DISCONNECT, onNunchukDisconnected );
  
This example shows how to listen for events from the C button:
  
  myWiimote.nunchuk.addEventListener ( ButtonEvent.C_PRESS, onCPress );
  myWiimote.nunchuk.addEventListener ( ButtonEvent.C_RELEASE, onCRelease );
  

See also

Nunchuk description on wiili.org
org.wiiflash.Wiimote


Public Properties
 PropertyDefined by
  c : Boolean
[read-only] Indicates if button C is pressed.
Nunchuk
  pitch : Number
[read-only] Pitch angle of the Wiimote in radians.
Nunchuk
  roll : Number
[read-only] Roll angle of the Wiimote in radians.
Nunchuk
  sensorX : Number
[read-only] Value of the x acceleration sensor.
Nunchuk
  sensorY : Number
[read-only] Value of the y acceleration sensor.
Nunchuk
  sensorZ : Number
[read-only] Value of the z acceleration sensor.
Nunchuk
  stickX : Number
[read-only] Value of the x stick-axis.
Nunchuk
  stickY : Number
[read-only] Value of the y stick-axis.
Nunchuk
  yaw : Number
[read-only] Yaw angle of the Nunchuk in radians.
Nunchuk
  z : Boolean
[read-only] Indicates if button Z is pressed.
Nunchuk
Public Methods
 MethodDefined by
  
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with a Nunchuk object so that the listener receives notification of an event.
Nunchuk
  
dispatchEvent(event:Event):Boolean
Dispatches an event into the event flow.
Nunchuk
  
hasEventListener(type:String):Boolean
Checks whether the Nunchuk object has any listeners registered for a specific type of event.
Nunchuk
  
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the Nunchuk object.
Nunchuk
  
toString():String
Returns the string representation of the specified object.
Nunchuk
  
willTrigger(type:String):Boolean
Checks whether an event listener is registered with this Nunchuk object or any of its ancestors for the specified event type.
Nunchuk
Property detail
cproperty
c:Boolean  [read-only]

Indicates if button C is pressed.

Implementation
    public function get c():Boolean
pitchproperty 
pitch:Number  [read-only]

Pitch angle of the Wiimote in radians. This value is scaled by the calibration data that has been read from the Nunchuk.

Implementation
    public function get pitch():Number
rollproperty 
roll:Number  [read-only]

Roll angle of the Wiimote in radians. This value is scaled by the calibration data that has been read from the Nunchuk.

Implementation
    public function get roll():Number
sensorXproperty 
sensorX:Number  [read-only]

Value of the x acceleration sensor. This value is scaled by the calibration data that has been read from the Nunchuk.

Implementation
    public function get sensorX():Number
sensorYproperty 
sensorY:Number  [read-only]

Value of the y acceleration sensor. This value is scaled by the calibration data that has been read from the Nunchuk.

Implementation
    public function get sensorY():Number
sensorZproperty 
sensorZ:Number  [read-only]

Value of the z acceleration sensor. This value is scaled by the calibration data that has been read from the Nunchuk.

Implementation
    public function get sensorZ():Number
stickXproperty 
stickX:Number  [read-only]

Value of the x stick-axis. This value is scaled by the calibration data that has been read from the Nunchuk.

Implementation
    public function get stickX():Number
stickYproperty 
stickY:Number  [read-only]

Value of the y stick-axis. This value is scaled by the calibration data that has been read from the Nunchuk.

Implementation
    public function get stickY():Number
yawproperty 
yaw:Number  [read-only]

Yaw angle of the Nunchuk in radians. This value is scaled by the calibration data that has been read from the Nunchuk.

Implementation
    public function get yaw():Number
zproperty 
z:Boolean  [read-only]

Indicates if button Z is pressed.

Implementation
    public function get z():Boolean
Method detail
addEventListener()method
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void

Registers an event listener object with a Nunchuk object so that the listener receives notification of an event.

Parameters
type:String — The type of event.
 
listener:Function — The listener function that processes the event.
 
useCapture:Boolean (default = false) — Determines whether the listener works in the capture phase or the target and bubbling phases.
 
priority:int (default = 0) — The priority level of the event listener.
 
useWeakReference:Boolean (default = false) — Determines whether the reference to the listener is strong or weak.

See also

dispatchEvent()method 
public function dispatchEvent(event:Event):Boolean

Dispatches an event into the event flow.

Parameters
event:Event — The Event object dispatched into the event flow.

Returns
Boolean

See also

hasEventListener()method 
public function hasEventListener(type:String):Boolean

Checks whether the Nunchuk object has any listeners registered for a specific type of event.

Parameters
type:String — The type of event.

Returns
Boolean — A value of true if a listener of the specified type is registered; false otherwise.

See also

removeEventListener()method 
public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void

Removes a listener from the Nunchuk object.

Parameters
type:String — The type of event.
 
listener:Function — The listener object to remove.
 
useCapture:Boolean (default = false) — Specifies whether the listener was registered for the capture phase or the target and bubbling phases.

See also

toString()method 
public function toString():String

Returns the string representation of the specified object.

Returns
String — A string representation of the object.
willTrigger()method 
public function willTrigger(type:String):Boolean

Checks whether an event listener is registered with this Nunchuk object or any of its ancestors for the specified event type.

Parameters
type:String — The type of event.

Returns
Boolean — A value of true if a listener of the specified type will be triggered; false otherwise.

See also