Skip to main content
Known Participant
January 19, 2013
Answered

phidget and AS3

  • January 19, 2013
  • 2 replies
  • 776 views

Hi all,

I am trying to move my game characters using phidgets.

I have the following code but got these error messages when I run it.

1119: Access of possibly undefined property data through a reference with static type com.phidgets.events:PhidgetDataEvent.

1119: Access of possibly undefined property index through a reference with static type com.phidgets.events:PhidgetDataEvent.

Cant figure out where the problem is from. I need help

Another question is: How can i access the sensors connected to a phidget?

package{

import com.phidgets.events.*;

          import com.phidgets.*

public class spacegame extends MovieClip

{

public var phid:PhidgetInterfaceKit;

public function spacegame()

{

phid = new PhidgetInterfaceKit();

                              phid.open("localhost", 5001);

                              phid.addEventListener(PhidgetDataEvent.SENSOR_CHANGE, onSensorChange);

}

public function onSensorChange(evt:PhidgetDataEvent):void

                    {

                              trace (evt.data);

                              trace(evt.index);

                    }

}

}

This topic has been closed for replies.
Correct answer moccamaximum

Here it says the Syntax should be:

                              trace (evt.Data);

                              trace(evt.Index);

2 replies

sinious
Legend
January 19, 2013

A static class reference means you don't need to make an instance of a class and you can directly use the class.

e.g. a class isntantiation (not what you need:

var someClass:aClass = aClass();

someClass.propertyName = 123;

That's accessing normal NON-static properties.

Your errors are saying your properties are static. Therefore you'd access them via:

var myNumber:Number = SomeClass.someStaticNumber;

var myString:String = SomeClass.someString;

var myObject:Object = SomeClass.someObject;

Chance the class and tyoe names to your taste.

chiggy83Author
Known Participant
January 20, 2013

I have sorted it  out. Now I can move my game character.  Thanks to you both.

Will definitely give you a shout out if im stuch again.

sinious
Legend
January 20, 2013

You're welcome and good luck!

moccamaximumCorrect answer
Inspiring
January 19, 2013

Here it says the Syntax should be:

                              trace (evt.Data);

                              trace(evt.Index);