Hello,
I am trying to learn how to do enumeration in a filterfunction.
Specifically, I have a datagrid that is assigned data via an array collection.
I have a text box that I call my filterfunction on to filter the array.
Now, what I would like to do is extend this to work with more than one column AND more than one array collection.
That is, let’s say I had:
myUsernamesCol
myDomainsCol
Each of those collections has different properties (is that the right word?).
I would like to be able to set my filterFunction and have the function enumerate through each of the items in that array.
As I understand it, I am passed an array of values. What it actually passes it seems is an ObjectProxy.
So this lead me down the path of trying to get code for flash_proxy working.
I read a thread here that talked about this but I can’t tweak it to get6 it to work. My package is:
package
{
import flash.utils.Proxy;
import flash.utils.flash_proxy;
import mx.collections.ArrayCollection;
import mx.utils.ArrayUtil;
public dynamic class LCProxy extends Proxy {
protected var _item:Array;
public override function LCProxy(item:Object)
{
_item = ArrayUtil.toArray(item);
//_item = ArrayUtil.toArray(item);
//_item = ArrayUtil.toArray(_item[0]);
super();
}
override flash_proxy function callProperty(name:*, ... rest):* {
trace("callProperty", name, rest);
flash_proxy::isAttribute(name);
return null;
}
override flash_proxy function deleteProperty(name:*):Boolean {
trace("deleteProperty", name);
flash_proxy::isAttribute(name);
return false;
}
override flash_proxy function getDescendants(name:*):* {
trace("getDescendants", name);
flash_proxy::isAttribute(name);
return null;
}
override flash_proxy function getProperty(name:*):* {
return _item[name];
}
override flash_proxy function hasProperty(name:*):Boolean {
trace("hasProperty", name);
flash_proxy::isAttribute(name);
return false;
}
// Don't override isAttribute(), it is a utility function
// used by methods that specify a name:* parameter
// to determine if the name argument was specified as an
// attribute. It doesn't look like there is any other
// way to determine if a name was specified as an
// attribute besides calling Proxy's isAttribute()
// implementation.
override flash_proxy function isAttribute(name:*):Boolean {
var result:Boolean = super.flash_proxy::isAttribute(name);
trace("isAttribute", name, result);
return result;
}
override flash_proxy function nextName(index:int):String {
return _item[index-1];
}
override flash_proxy function nextNameIndex(index:int):int {
if (index < _item.length)
return index +1;
else
return 0;
}
override flash_proxy function nextValue(index:int):* {
var prop:String = _item[index - 1];
return _item[prop];
}
override flash_proxy function setProperty(name:*, value:*):void {
trace("setProperty", name, value);
flash_proxy::isAttribute(name);
}
}
}
and this is the code I’ve been playing with trying to enumerate:
private function searchItem(item:ObjectProxy):Boolean
{
namespace myNamespace = "LCProxy";
var myProxy:LCProxy = new LCProxy(item);
trace(item.object);
trace (item);
//trace (item['username'];
for each (var value:* in myProxy) {
//for (var prop:String in proxy) { // nextName/nextNameIndex
// trace(prop);
// trace(proxy[prop])
//if(object.toLowerCase().search(search.text.toLowerCase()) != -1){
return true;
//}
}
return false;
}
I would really appreciate some help. I am tee totally stumped on this one!
G-Man