I am working with some AS classes trying to become more OOP in nature, and so I am testing keeping everything organized in separate folders according to tasks. You know the drill I like to keep the AS classes in my com folder and inside their separate different classes by what they might do. Shapes in one folders, text in another and so on.

I have been trying this shapes example I came up with with calls another AS class. This works fine when they are both in com, but when they are bother in their own separate folder I get an error.

This is the example when everything is in the same folder


package {

	import flash.display.Sprite;

	import flash.filters.GlowFilter;

	import flash.filters.DropShadowFilter;

	import flash.filters.BlurFilter;

	import Triangles;

	public class InheritingClasses extends Triangles {

		public function InheritingClasses() {

			triangle1.filters = [new GlowFilter(0xFF6699, .75, 25, 25, 2, 2, false, false)];

			triangle2.filters = [new DropShadowFilter(5, 45, 0x666666, 1, 5, 5, 1, 1, false, false, false)];

			triangle3.filters = [new BlurFilter(5, 5, 2)];





package {

	import flash.display.Sprite;

	import flash.display.Shape;

	public class Triangles extends Sprite{

		internal var triangle1:Shape = new Shape();

		internal var triangle2:Shape = new Shape();

		internal var triangle3:Shape = new Shape();

		public function Triangles(){

			triangle1.graphics.lineStyle(2, 0x000000);

			triangle1.graphics.beginFill(0xFF0000, 1);

			triangle1.graphics.moveTo(200, 100);

			triangle1.graphics.lineTo(200, 100);

			triangle1.graphics.lineTo(275, 225);

			triangle1.graphics.lineTo(125, 225);



			triangle2.graphics.lineStyle(2, 0x000000);

			triangle2.graphics.beginFill(0x00FF00, 1);

			triangle2.graphics.moveTo(375, 50);

			triangle2.graphics.lineTo(375, 50);

			triangle2.graphics.lineTo(525, 50);

			triangle2.graphics.lineTo(450, 175);



			triangle3.graphics.lineStyle(2, 0x000000);

			triangle3.graphics.beginFill(0x0000FF, 1);

			triangle3.graphics.moveTo(275, 375);

			triangle3.graphics.lineTo(275, 375);

			triangle3.graphics.lineTo(400, 250);

			triangle3.graphics.lineTo(100, 350);






of course I set the doc class to “InheritingClasses”

Now when I create the com folder, and put the InheritingClasses.as in “classes and triangles.as in “Shapes” I got a weird error.

Attempted access of inaccessible property triangle1 through a reference with static type com.classes:InheritingClasses.

Attempted access of inaccessible property triangle2 through a reference with static type com.classes:InheritingClasses.

Attempted access of inaccessible property triangle3 through a reference with static type com.classes:InheritingClasses.

Now why would this fail when I separate the as files into com/shapes for triangles.as and com/classes for the main class? Of course I updated everything to reflect this change.

I asked this question on Linkedin and Jeff Fall tells me to use public static in the function,and I will try this tonight.

By |2009-03-26T01:57:16+00:00March 26th, 2009|