Archive

Archive for December, 2009

New site content

December 15th, 2009

Hi all,

I’ve just uploaded two new two new projects to the site.

The first is a little physics simulation I did last week.

The second is an application framework for DirectX that provides a basic scene along with camera setup and manipulation, logging, mesh loading and rendering support and direct input support.

You can get them in my downloads section of the site.

Cheers,
Eddie

admin C/C++

Really annoying ActionScript error

December 12th, 2009

Hi,

I’ve been working with ActionScript for the first time and created a really simple class with a couple of getters and setters and wanted to instantiate the class and use a few setters.

So the original class was:

package MyPackage
{
import mx.core.UIComponent;

public class AClass extends UIComponent
{
public function AClass()
{
super();
}

public function get AValue():Number
{
return _aValue;
}

public function set AValue(_newAValue:Number):void
{
_aValue = _newAValue;
}

private var _aValue:Number;
}
}

That looks fine right?

So in my class I call
import MyPackage.AClass at the top of the file.

Next in another class I called

var myClass:AClass = new AClass();

myClass.AValue(20.0);

I figured that this looked fine, you want to call the function AValue with the value 20.0 passed in. However I was getting the cryptic error:

1195: Attempted access of inaccessible method AValue through a reference with static type MyPackage:AClass

Took me a while to figure this one out I thought I had defined the functions incorrectly or wasn’t importing the class right. However the solution is a simple one. When you use get and set you are essentially saying that you can use the assignment operator but for some weird reason you can’t call the functions directly.
So the solution was to do:

var myClass:AClass = new AClass();

myClass.AValue = 20.0;

Use the assignment operator instead of calling the set function directly.

admin Flex