1
2
3
4 """
5 Compatibility classes/functions for Flex.
6
7 @note: Not available in ActionScript 1.0 and 2.0.
8 @see: U{Flex on Wikipedia (external)
9 <http://en.wikipedia.org/wiki/Adobe_Flex>}
10
11 @author: U{Nick Joyce<mailto:nick@boxdesign.co.uk>}
12
13 @since: 0.1.0
14 """
15
16 import pyamf
17
18 __all__ = ['ArrayCollection', 'ObjectProxy']
19
21 """
22 I represent the ActionScript 3 based class
23 C{flex.messaging.io.ArrayCollection} used in the Flex framework.
24
25 The ArrayCollection class is a wrapper class that exposes an Array
26 as a collection that can be accessed and manipulated using the
27 methods and properties of the C{ICollectionView} or C{IList}
28 interfaces in the Flex framework.
29
30 @see: U{ArrayCollection on Livedocs (external)
31 <http://livedocs.adobe.com/flex/201/langref/mx/collections/ArrayCollection.html>}
32 """
33
35 if source is not None:
36 if isinstance(source, (list, tuple)):
37 for i in range(len(source)):
38 self[i] = source[i]
39 elif isinstance(source, (dict)):
40 for k, v in source.iteritems():
41 self[k] = v
42
44 return "<flex.messaging.io.ArrayCollection %s>" % dict.__repr__(self)
45
47 data = input.readObject()
48
49 if hasattr(data, 'iteritems'):
50 for (k, v) in data.iteritems():
51 self[k] = v
52 else:
53 count = 0
54 for i in data:
55 self[count] = i
56 count += 1
57
60
61 pyamf.register_class(ArrayCollection, 'flex.messaging.io.ArrayCollection',
62 metadata=['external', 'amf3'])
63
65 """
66 I represent the ActionScript 3 based class C{flex.messaging.io.ObjectProxy}
67 used in the Flex framework. Flex's ObjectProxy class allows an anonymous,
68 dynamic ActionScript Object to be bindable and report change events.
69
70 @see: U{ObjectProxy on Livedocs (external)
71 <http://livedocs.adobe.com/flex/201/langref/mx/utils/ObjectProxy.html>}
72 """
73
75 if object is None:
76 self._amf_object = pyamf.ASObject()
77 else:
78 self._amf_object = object
79
81 return "<flex.messaging.io.ObjectProxy %s>" % self._amf_object
82
84 if name == '_amf_object':
85 return self.__dict__['_amf_object']
86
87 return getattr(self.__dict__['_amf_object'], name)
88
90 if name == '_amf_object':
91 self.__dict__['_amf_object'] = value
92 else:
93 setattr(self._amf_object, name, value)
94
97
100
101 pyamf.register_class(ObjectProxy, 'flex.messaging.io.ObjectProxy',
102 metadata=['external', 'amf3'])
103