Archive for the “Flex” Category

Incremented file image
Some software have the ability to detect the presence of files named in a sequential order.
I want to add similar functionality to some experimental scripts I'm working on.
For my purposes I'm only focusing on sequential files with numeric prefixes or suffixes in the filenames.
The function I've written returns a new filepath thats incremented. Using regular expressions I diced the filepath up into pieces I could change then concatenate into the next potential filepath. This function is for generating a possible next filepath, so testing the existence of the actual file is not my concern.

Example 1

trace(getIncrementFilePath("gallery/image01.png")); //returns gallery/image02.png

Example 2
Creating incremented filepaths in a loop.

var path:String="gallery/image01.png";

var i:int=0;
while (i < 10)
{
	path=getIncrementFilePath(path);
	trace(path);
	i++;
}

/*
trace output
===================
gallery/image02.png
gallery/image03.png
gallery/image04.png
gallery/image05.png
gallery/image06.png
gallery/image07.png
gallery/image08.png
gallery/image09.png
gallery/image10.png
gallery/image11.png
*/

Read the rest of this entry »

Vote in HexoSearch

Comments No Comments »

I wanted to create a list of Strings from only the attributes of an XMLList, and I wanted them separated with carriage returns.

The "toXMLString()" method does this automatically on attributes.
Attributes are typed as XMLList.

 
var myXmlList:XMLList=XMLList(<B><P name="Orange"/><P name="Grape"/><P name="Pear"/></B>).P;
trace(myXmlList..@name.toXMLString());
//Outputs multiple values of all "name" attributes separated with carriage returns automatically.
Orange
Grape
Pear
 

Putting the values of an XMLList as an Array might be useful also.

Being separated by carriage returns makes it easy to convert to an Array by using the String "split" method.

Wrap this into a function for easy use.

 
function xmllistToArray(list:XMLList):Array
             {
                 return list.toXMLString().split("\n");
             }
 

Vote in HexoSearch

Comments 1 Comment »

Here is some Flash Builder script that does basic text search functionality.
It will find the index of the search and scroll a TextArea component to the String.
I'm using "indexOf" and "lastIndexOf" to perform the next and previous searches. I'd like to use Regular Expressions to find the next and previous occurrences in my search, but did not figure that out or know if it's possible to apply it for this.
If anyone knows a faster way let me know.

Get Adobe Flash player


Read the rest of this entry »

Vote in HexoSearch

Comments No Comments »

Thanks for visiting www.keith-hair.net