Re: [flexcoders] Re: Help Me for SharedObject and registerClassAlias method

2009-02-16 Thread Braam Genis
Use the metadata tag [RemoteClass(alias=WindowInfo)] above your WindowInfo
class declaration and your objects should be typed when you retrieve them
from SharedObject.

On Sun, Feb 15, 2009 at 3:59 PM, valdhor valdhorli...@embarqmail.comwrote:

   I don't think you can do that. A SharedObject is just an object. What
 you would need to do is put the WindowInfo objects you want to store
 into an array and store the array in the SharedObject. When you want
 to retrieve the WindowInfo objects, read them into an array and coerce
 each array item into a WindowInfo object.


 --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com,
 thelordsince1984 lore...@... wrote:
 
  Hi,
 
  i've yet posted this question but i can't resolve this problem..
 
  i've created a custom value object class..a simple class with private
  properties and getters methods to retrieve them.
 
  public class WindowInfo
  {
 
  private var _id:String;
 
  private var _module:String
 
  private var _xpos:int;
 
  private var _ypos:int;
 
  private var _width:int;
 
  private var _height:int;
 
  public function WindowInfo(id:String, module:String, xpos:int,
  ypos:int, width:int, height:int)
  {
  this._id = id;
  this._module = module;
  this._xpos = xpos;
  this._ypos = ypos;
  this._width = width;
  this._height = height;
  }
 
  public function get id():String {
  return _id;
  }
 
  public function get module():String {
  return _module;
  }
 
  public function get xpos():int {
  return _xpos;
  }
 
  public function get ypos():int {
  return _ypos;
  }
 
  public function get width():int {
  return _width;
  }
 
  public function get height():int {
  return _height;
  }
  }
 
  then i created an array collection where each item is an istance of
  value object.
  then i have a shared object manager that looks like this:
 
  package util{
 
  import flash.net.SharedObject;
 
  import mx.collections.ArrayCollection;
 
  public class SharedObjectApplicationManager {
 
  private var mySO:SharedObject;
  private var ac:ArrayCollection;
  private var lsoType:String;
 
  public function SharedObjectApplicationManager(s:String) {
  init(s);
  }
 
  private function init(s:String):void {
  mySO = SharedObject.getLocal(s);
  if (getf()) {
  getf();
  }
  }
 
  public function getf():ArrayCollection {
  return mySO.data.arrayc;
  }
 
  private function adda(array:ArrayCollection):void {
  mySO.data.arrayc = new ArrayCollection();
  mySO.data.arrayc = array;
  mySO.flush();
  }
  }
  }
 
  so when i try to get arraycollection with getf method i get an
  arraycollection of generic objects…not with windowinfo objects..in
  this manner i can't get value properties of value object class.
 
  so i would use registerClassAlias(Info, WindowInfo) where WindowInfo
  is the VO..but where?
 
  the architecture of my app is:
 
  -main application (verify the shared object, if full then call a
  public function of canvas to create windows with specific parameters
  saved in windowinfo class)
  –canvas (contains one or more windows)
 
  any suggestions?
 
  Thanks in advance
 
  Regards Lorenzo
 

  



Re: [flexcoders] Re: Help Me for SharedObject and registerClassAlias method

2009-02-16 Thread Johannes Nel
watch out for classes that take arguments in the constructer or java style
enums.

On Mon, Feb 16, 2009 at 12:07 AM, Braam Genis braamge...@gmail.com wrote:

   Use the metadata tag [RemoteClass(alias=WindowInfo)] above your
 WindowInfo class declaration and your objects should be typed when you
 retrieve them from SharedObject.


 On Sun, Feb 15, 2009 at 3:59 PM, valdhor valdhorli...@embarqmail.comwrote:

   I don't think you can do that. A SharedObject is just an object. What
 you would need to do is put the WindowInfo objects you want to store
 into an array and store the array in the SharedObject. When you want
 to retrieve the WindowInfo objects, read them into an array and coerce
 each array item into a WindowInfo object.


 --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com,
 thelordsince1984 lore...@... wrote:
 
  Hi,
 
  i've yet posted this question but i can't resolve this problem..
 
  i've created a custom value object class..a simple class with private
  properties and getters methods to retrieve them.
 
  public class WindowInfo
  {
 
  private var _id:String;
 
  private var _module:String
 
  private var _xpos:int;
 
  private var _ypos:int;
 
  private var _width:int;
 
  private var _height:int;
 
  public function WindowInfo(id:String, module:String, xpos:int,
  ypos:int, width:int, height:int)
  {
  this._id = id;
  this._module = module;
  this._xpos = xpos;
  this._ypos = ypos;
  this._width = width;
  this._height = height;
  }
 
  public function get id():String {
  return _id;
  }
 
  public function get module():String {
  return _module;
  }
 
  public function get xpos():int {
  return _xpos;
  }
 
  public function get ypos():int {
  return _ypos;
  }
 
  public function get width():int {
  return _width;
  }
 
  public function get height():int {
  return _height;
  }
  }
 
  then i created an array collection where each item is an istance of
  value object.
  then i have a shared object manager that looks like this:
 
  package util{
 
  import flash.net.SharedObject;
 
  import mx.collections.ArrayCollection;
 
  public class SharedObjectApplicationManager {
 
  private var mySO:SharedObject;
  private var ac:ArrayCollection;
  private var lsoType:String;
 
  public function SharedObjectApplicationManager(s:String) {
  init(s);
  }
 
  private function init(s:String):void {
  mySO = SharedObject.getLocal(s);
  if (getf()) {
  getf();
  }
  }
 
  public function getf():ArrayCollection {
  return mySO.data.arrayc;
  }
 
  private function adda(array:ArrayCollection):void {
  mySO.data.arrayc = new ArrayCollection();
  mySO.data.arrayc = array;
  mySO.flush();
  }
  }
  }
 
  so when i try to get arraycollection with getf method i get an
  arraycollection of generic objects…not with windowinfo objects..in
  this manner i can't get value properties of value object class.
 
  so i would use registerClassAlias(Info, WindowInfo) where WindowInfo
  is the VO..but where?
 
  the architecture of my app is:
 
  -main application (verify the shared object, if full then call a
  public function of canvas to create windows with specific parameters
  saved in windowinfo class)
  –canvas (contains one or more windows)
 
  any suggestions?
 
  Thanks in advance
 
  Regards Lorenzo
 


  




-- 
j:pn
\\no comment


Re: [flexcoders] Re: Help Me for SharedObject and registerClassAlias method

2009-02-16 Thread Peter Hall
I'm not sure what you mean about casting in this context. Also, I
guess you meant AMF3 when you said AMF2? (with AMF0/ AS2, you can use
Object.registerClass() for the same effect).

In AS3, registerClassAlias() is the way to make this work. But, as
Braam said, [RemoteClass] is the simplest way: it will insert the
registerClassAlias() code for you, so you don't have to worry about
where to put it, and will make sure it is ready when you need it.


Peter


On Mon, Feb 16, 2009 at 4:16 PM, djepyon i...@auricom.com wrote:
 What you're saying here works, but you can definitely use
 RegisterClassAlias to get strongly typed objects when
 storing/retrieving data from a SharedObject or anything else AMF2
 based (LocalConnection for example). This would prevent the need to
 cast any objects.

 --- In flexcoders@yahoogroups.com, valdhor valdhorli...@... wrote:

 I don't think you can do that. A SharedObject is just an object. What
 you would need to do is put the WindowInfo objects you want to store
 into an array and store the array in the SharedObject. When you want
 to retrieve the WindowInfo objects, read them into an array and coerce
 each array item into a WindowInfo object.


 --- In flexcoders@yahoogroups.com, thelordsince1984 loreboa@ wrote:
 
  Hi,
 
  i've yet posted this question but i can't resolve this problem..
 
  i've created a custom value object class..a simple class with private
  properties and getters methods to retrieve them.
 
  public class WindowInfo
  {
 
  private var _id:String;
 
  private var _module:String
 
  private var _xpos:int;
 
  private var _ypos:int;
 
  private var _width:int;
 
  private var _height:int;
 
  public function WindowInfo(id:String, module:String, xpos:int,
  ypos:int, width:int, height:int)
  {
  this._id = id;
  this._module = module;
  this._xpos = xpos;
  this._ypos = ypos;
  this._width = width;
  this._height = height;
  }
 
  public function get id():String {
  return _id;
  }
 
  public function get module():String {
  return _module;
  }
 
  public function get xpos():int {
  return _xpos;
  }
 
  public function get ypos():int {
  return _ypos;
  }
 
  public function get width():int {
  return _width;
  }
 
  public function get height():int {
  return _height;
  }
  }
 
  then i created an array collection where each item is an istance of
  value object.
  then i have a shared object manager that looks like this:
 
  package util{
 
  import flash.net.SharedObject;
 
  import mx.collections.ArrayCollection;
 
  public class SharedObjectApplicationManager {
 
  private var mySO:SharedObject;
  private var ac:ArrayCollection;
  private var lsoType:String;
 
  public function SharedObjectApplicationManager(s:String) {
  init(s);
  }
 
  private function init(s:String):void {
  mySO = SharedObject.getLocal(s);
  if (getf()) {
  getf();
  }
  }
 
  public function getf():ArrayCollection {
  return mySO.data.arrayc;
  }
 
  private function adda(array:ArrayCollection):void {
  mySO.data.arrayc = new ArrayCollection();
  mySO.data.arrayc = array;
  mySO.flush();
  }
  }
  }
 
  so when i try to get arraycollection with getf method i get an
  arraycollection of generic objects…not with windowinfo objects..in
  this manner i can't get value properties of value object class.
 
  so i would use registerClassAlias(Info, WindowInfo) where WindowInfo
  is the VO..but where?
 
  the architecture of my app is:
 
  -main application (verify the shared object, if full then call a
  public function of canvas to create windows with specific parameters
  saved in windowinfo class)
  –canvas (contains one or more windows)
 
  any suggestions?
 
  Thanks in advance
 
  Regards Lorenzo
 


 




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Alternative FAQ location: 
https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! 
Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* Your email settings:
Individual Email | Traditional

* To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)

* To change settings via email:
mailto:flexcoders-dig...@yahoogroups.com 
mailto:flexcoders-fullfeatu...@yahoogroups.com

* To unsubscribe from this group, send an email to:
flexcoders-unsubscr...@yahoogroups.com

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/