Re: [flexcoders] Flex2 flash_proxy/Proxy getProperty and Binding
Well, I was just in this classroom the other day. If I get your question correctly.. Add; use namespace flash_proxy; right under the import flash.util.flash_proxy. If you got this code from an example, it was missing the use statement. I missed this also!, Once the use is in there it works great! Peace, MikeOn 3/15/06, Renaun Erickson [EMAIL PROTECTED] wrote: The sample code is located below. I am trying to find a way to bind dynamic attributes (when using Proxy class). I can't get the dynamic properties to bind, any suggestions or help would be appreciated. Renaun Proxy Class: package { import flash.util.flash_proxy; import flash.util.Proxy; dynamic public class SomeClass extends Proxy { public var _dynamicAttributeArray:Array; public function SomeClass() { _dynamicAttributeArray = new Array(); } flash_proxy override function getProperty( name : * ) : * { return _dynamicAttributeArray[ name ]; } flash_proxy override function setProperty(name:*, value:*):void { _dynamicAttributeArray[ name ] = value; } } } Now if I have: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.macromedia.com/2005/mxml xmlns=* creationComplete=initApplication() mx:VBox width=100% height=100% mx:TextArea width=100% height=50% id=output text={ SomeClass(someClass).newAttribute }/ mx:Button label=Change click=someClass.newAttribute = '' + new Date();/ /mx:VBox mx:Script ![CDATA[ import SomeClass ; public var someClass:SomeClass; public function initApplication() { someClass = new SomeClass(); someClass.newAttribute = I am New; //output.text = someClass.newAttribute; } ]] /mx:Script /mx:Application -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group flexcoders on the web. To unsubscribe from this group, send an email to: [EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. -- What goes up, does come down. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to:[EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
AW: [flexcoders] Flex2 flash_proxy/Proxy getProperty and Binding
Hi, you have to use namespace as well. Here is an example of a SortedList I use in testproject. You can enumerate the ListKeys with for in and the Items with for each in. Harald package Helper { import flash.util.Proxy; import flash.util.flash_proxy; use namespace flash_proxy; public class SortedList extends Proxy { private var _Values:Object; private var _Keys:Array; private var _Sorted:Boolean; private var _Count:int; public function Add(key:String, value:Object):void { if( _Values.hasOwnProperty(key) ) throw new Error(Key allready exists.); _Values[key] = value; _Count++; _Sorted = false; } public function Clear():void { _Values = new Object(); _Sorted = false; _Count = 0; } public function ContainsKey(key:String):Boolean { return _Values.hasOwnProperty(key); } public function get Count():int { return _Count; } public function Item(keyindex:Object):Object { return this.getProperty(_GetKey(keyindex)); } public function Key(index:int):String { if( index 0 || index = this.Count ) throw new RangeError(); return this.Keys[index]; } public function get Keys():Array { if( !_Sorted ) { _Keys = new Array(); for(var _Key:String in _Values) { _Keys.push(_Key); } _Keys.sort(); } return _Keys; } public function Remove(keyindex:Object):void { var _Key:String = _GetKey(keyindex); if( !_Values.hasOwnProperty(_Key) ) _ThrowError(); delete _Values[_Key]; _Sorted = false; _Count--; } override flash_proxy function getProperty(name:*):* { if( name is QName ) { return _Values[name]; } else { var key:String = _GetKey(name); if( !_Values.hasOwnProperty(key) ) _ThrowError(); return _Values[key]; } } override flash_proxy function setProperty(name:*, value:*):void { if( name is QName ) { _Values[name] = value; } else { var key:String = _GetKey(name); if( !_Values.hasOwnProperty(key) ) _ThrowError(); _Values[key] = value; } } override flash_proxy function nextNameIndex(index:int):int { if( index _Count ) { return index + 1; } else { return 0; } } override flash_proxy function nextName(index:int):String { return this.Keys[index -1]; } override flash_proxy function nextValue(index:int):* { return getProperty(this.Keys[index-1]); } //Private private function _ThrowError():void { throw new Error(Item doesn't exists.); } private function _GetKey(keyindex:Object):String { if( isNaN(Number(keyindex)) ) { return (keyindex as String); } else { var _index:int = int(Number(keyindex)); if( _index 0 || _index = this.Count ) throw new RangeError(); return this.Keys[_index]; } } // Constructor public function SortedList() { _Values = new Object(); _Sorted = false; _Count = 0; } } } Von: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] Im Auftrag von Renaun Erickson Gesendet: Mittwoch, 15. März 2006 08:49 An: flexcoders@yahoogroups.com Betreff: [flexcoders] Flex2 flash_proxy/Proxy getProperty and Binding The sample code is located below. I am trying to find a way to bind dynamic attributes (when using Proxy class). I can't get the dynamic properties to bind, any suggestions or help would be appreciated. Renaun Proxy Class: package { import
[flexcoders] Flex2 flash_proxy/Proxy getProperty and Binding
The sample code is located below. I am trying to find a way to bind dynamic attributes (when using Proxy class). I can't get the dynamic properties to bind, any suggestions or help would be appreciated. Renaun Proxy Class: package { import flash.util.flash_proxy; import flash.util.Proxy; dynamic public class SomeClass extends Proxy { public var _dynamicAttributeArray:Array; public function SomeClass() { _dynamicAttributeArray = new Array(); } flash_proxy override function getProperty( name : * ) : * { return _dynamicAttributeArray[ name ]; } flash_proxy override function setProperty(name:*, value:*):void { _dynamicAttributeArray[ name ] = value; } } } Now if I have: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.macromedia.com/2005/mxml; xmlns=* creationComplete=initApplication() mx:VBox width=100% height=100% mx:TextArea width=100% height=50% id=output text={ SomeClass(someClass).newAttribute }/ mx:Button label=Change click=someClass.newAttribute = '' + new Date();/ /mx:VBox mx:Script ![CDATA[ import SomeClass ; public var someClass:SomeClass; public function initApplication() { someClass = new SomeClass(); someClass.newAttribute = I am New; //output.text = someClass.newAttribute; } ]] /mx:Script /mx:Application -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/