I blame myself for typing typos, but the cause of this typo is harder to spot.
The compiler throws the error saying either "Internal Build Error" or "Classes Must Not Be Nested".
Knowing "gotchas" is helpful so I'm posting this.

For most errors we take the compiler for granted and it will tell you where you wrote some misspelled keyword or syntax because someone called you on the phone while you was in the middle of writing script. You get back to your code and run the compiler and bam! You can't figure out the cause of the error. You're already up late and tired while you read each line looking for the cause.

With my situation the compiler couldn't tell me where exactly I failed in life. I knew what classes I was working on before the error occurred. In each of them I commented out each class member declaration till the error disappeared. This let me know which class was potentially the problem.
Then in the suspect class I proofread each line of code and saw my very stupid mistake.
Here's a minimized example of the bad syntax...

package net.keithhair
{
	import flash.geom.Point;
	
	public class SomeInnocentClass
	{
		private var _x:Number = 0;
		private var _y = Number = 0; // Offending syntax.
		
		public function SomeInnocentClass()
		{
		
		}
	}
}

(Oh yea, if you're using Flash Builder, make sure you run "clean" after correcting the syntax)

I googled the error and read some comments here. The cause of the error is varied so It's a good thing when others post their causes too. It's easier to debug when you know "gotchas" to look out for.
http://rjowen.wordpress.com/2007/06/21/internal-build-error-or-classes-must-not-be-nested-error

Comments Leave a comment »

I've been using Arrays where I need to test how both sets of Arrays match each other. The Arrays are created dynamically from human input, so the content, order and length of Arrays to match are most often arbitrary.
A good example is the following multiple choice question:
AEIOU and sometimes Y or W maybe?

AEIOU and Y would be considered the correct answers, depending on the question.
You may want the user to score correctly if his/her choices are "AEIOU", even if they leave out "Y", but fail if they include "W".

The logic in deciding if a question is true can be complicated so I wrote a class to help me in these situations. This has been helpful to me not only in quiz programming, but when situations where I need to compare Arrays consisting of Objects other than Strings. Application logic or game logic, as long as I can avoid hard-coding a lot of "If statements" this is useful.

The ArrayLogic class has 5 methods for doing Boolean operations to test if or how a pair of Arrays share content or not.
There are also 2 more methods for returning Arrays of matching or non-matching items. What I'm trying to do is work with Arrays similar to how I can use Regular Expressions, how ever Regular Expressions are used for Strings. I am working with all kinds of data types.

//----------------------------------
// These methods return true/false
//----------------------------------
var testResult:Boolean;

//true if some elements match in both Arrays.
testResult = ArrayLogic.hasSome(sourceArry, contentArry);

//true if sourceArry includes all elements of contentArry, even if sourceArry has non matching other elements.
testResult = ArrayLogic.hasAll(sourceArry, contentArry);

//true if sourceArry has all the same elements of contentArry and no other non matching elements. 
testResult = ArrayLogic.hasSame(sourceArry, contentArry);

//true if sourceArry has NO element at all from contentArry.
testResult = ArrayLogic.hasNone(sourceArry, contentArry);

//true if sourceArry has all the elements of contentArry, also accepting any elements include in the "allowedArry".
testResult = ArrayLogic.hasEveryAndAllows(sourceArry, contentArry, allowedArry);

//----------------------------------
// These methods return Arrays
//----------------------------------
var items:Array;
items = ArrayLogic.getMatchingItems(sourceArry, contentArry); //returns Array of items matching contentArry.
items = ArrayLogic.getNonMatchingItems(sourceArry, contentArry); //returns Array of items that contentArry does not have.

Below is a live example to help explain and see the result of each ArrayLogic method in use.

It is an easy way to visualize if there is a "hasSome", "hasAll", "hasSame", "hasNone", or "hasEveryAndAllows" relationship between the 2 example Arrays...
Read the rest of this entry »

Comments Leave a comment »


Wrap It Up!

When you grow or decrease a Number value continuously it will fall out of preferable range at some point and you might want to reset the value so that it stays "in range".
You can write "IF" statements to do this but having a function is more reusable.

The "rotation" property of an ActionScript DisplayObject returns values from 0 through 180 and -179.9999 through -0.0001. I'm sure there is a reason it's like that but I'm not a math expert. I like looking at angles being 0 through 360. Please tell me why the rotation property value is like that, I would love to know.

The wrapRange function corrected my rotation value to always be 0 through 360. At first I made this "wrapRange" function hard-coded to return values from 0 through 360 specifically. Lots of other tasks I work on involve growing numbers pass different limits for different reasons so furthermore, I decided to make the function more dynamic to handle any minimum and maximum value.

No matter how far my Number travels on the 1-dimensional Number line, it will stay in the range I specify. This way I can keep my values in pattern while also preventing values from going near "unstable" operating limits or whatever the positive and negative Number limits are for ActionScript.

Wrapping my value to stay between 0 through 360...

var a:Number=360+180;
a=wrapRange(a,0,360);
trace(a); //Returns 180


You can see the original rotation value changes versus the value return from the "wrapRange" function...

Read the rest of this entry »

Comments Leave a comment »

Thanks for visiting www.keith-hair.net