This Actionscript 3 function returns some properties that are about a line-to-polygon intersection.
It's useful for knowing all intersection points of a segment intersecting with a polygon, and knowing if the end points of the segment are inside the polygon.

Read the rest of this entry »

Comments No Comments »

Here is an ActionScript 3 function that will return intersection information between a segment and circle.
It's useful to me to know if a segment is partially intersecting with a circle or going completely through.


Read the rest of this entry »

Comments No Comments »

The intersection Point of two lines is useful to know. This is a function to find it in AS3.


Read the rest of this entry »

Comments No Comments »

One year ago I accidently left this particular  USB Flash Drive in my pants pocket and washed it in my washing machine for an 18 minute hot/cold water cycle...and it still works like new.

One of my USB Flash Drives

Today I accidentally left this same model in my pants and washed it on that same cycle...plus dried it it for 40 minutes on HOT in a  dryer machine...and it still works like new.

That's so awesome!

Comments No Comments »

Here is a Flex UI component I've been writing. Click the image to play with what I have made so far.
You can change a variety of properties. The dial and mark are runtime skinnable by setting its "dialBackgroundSkin" or "dialMarkSkin" property to a url with an image. 

Knobs and dials just look cool...I don't know anything about audio editing but I like the site of a sound studio. This is the "Reason" I decided to make a knob component.

Nice Knobs

Comments No Comments »

Here is a scrolling background and keyboard control test for some AS3 classes I been working on. I used the image of superman from some sprite graphics I found on the web. The images for his flight positions are loaded dynamically. This is for allowing me to load other images for different characters without changing too much script.

Superman Flash test

Comments No Comments »

When creating a new symbol for MovieClips and other instances you must give them a name a second time again in the Properties panel. For me this can be annoying sometimes. (I name my instances the name I plan to later identify them with actionscript.)

Here is a modification of the "findObjects" I posted earlier. This is handy if you are the type of person that names your symbol items with names you intend to use as their instance name as well.

Maybe you will find this useful or know improvements, either way let me know your thoughts.
Read the rest of this entry »

Comments No Comments »

Here's a JSFL function for returning an Array of all elements with a given instance name in whole Flash Document.
I was trying to make something like JavaScript's "getElementsById()" method.
My intent was to make this compatible with both Flash 8 and CS3 IDEs.

Note: Unfortunately, this method will not find elements that are grouped.
Let me know if this is helpful or if there is a better way to do this.

Example:

 
fl.outputPanel.clear();
var items=findObjects("mybox");
var n=0;
while(n < items.length){
	items[n].rotation=45;
	n++;
}
alert("Found "+items.length+" items.");
 

Read the rest of this entry »

Comments 1 Comment »

When I'm writing a script to read XML data, I personally like the identification of node names and attributes to be case-insensitive. Its one less thing to worry about when others are modifying the XML data that my script will have to read and render, and I think they feel modifying the XML to be more user-friendly this way. :)

Here, the example scripts pull a list of all the nodes with the name "MEDIA".
Using Regular Expressions, you can identify each "MEDIA" node regardless of its letter case.

 
var doc:XML=
<DATA>
	<CATEGORY>
		<MEDIA>A.jpg</MEDIA>
		<MEDIA>B.jpg</MEDIA>
	</CATEGORY>
	<CATEGORY>
		<MEDIA>C.jpg</MEDIA>
	</CATEGORY>
	<CATEGORY>
		<MEDIA>D.jpg</MEDIA>
	</CATEGORY>
	<CATEGORY>
		<MEDIA>E.jpg</MEDIA>
	</CATEGORY>
</DATA>;
 
var findName:String="media";
trace(doc..*.(new RegExp(findName,"i")["test"](name())).toXMLString());
 

:( "Error #1069: Property lowerCase not found on QName"

 
trace(doc..*.(name().lowerCase()=="media").toXMLString());
 

:( Letter case must be same for this to work.

 
trace(doc..*.(name()=="MEDIA").toXMLString());
 

Used a regular expression to do case-insensitive filter
:| Works, letter case does not matter...but the expression is too "hardcoded".

 
trace(doc..*.(/media/i.test(name())).toXMLString());
 

:-? Works, but compiler does not like it:
"Warning: 3594: test is not a recognized method of the dynamic class RegExp."
This is an attempt to allow variables and expressions.

 
var findName:String="media";
trace(doc..*.(new RegExp(findName,"i").test(name())).toXMLString());
 

:jumping: Works!
"[" and "]" keeps the compiler from warning when using the RegExp "test()" method.
Now letter case does not matter, and RegExp constructor allows variables or expressions.

 
var findName:String="media";
trace(doc..*.(new RegExp(findName,"i")["test"](name())).toXMLString());
 

Comments No Comments »

The XML examples represent a book in a library. However the book has several bookworms in it.
Using E4X we can find these bookworms.

 
<library>
	<book>
<page id="one"/>
		<worm name="Eddy" />
<page id="two"/>
<page id="three">
			<worm name="Lisa"/>
			<worm name="Pete" />
		</page>
<page id="four"/>
	</book>
</library>
 

There are some E4X operators and XML methods to help use do this when combined together:

.. Access all descendants of the XML object.
. Access a property of an Object or XML.
* Wildcard, match any part of the XML.
childIndex() Index number of an XML object relative to its parent node.
name() Name of the XML node.

Read the rest of this entry »

Comments No Comments »

Thanks for visiting www.keith-hair.com