Re: [Flashcoders] Object repository and instancing a object

2006-01-02 Thread Weyert de Boer

Pascal FODOR wrote:

Humm, looks like this is getting away from the question ;-)
The problem with:

if ( className !=  ) return false;

instance = new className( valueObject );
return instance;

Is that className is a string not a reference so new className() won't work.
He you tried eval(className) as you suggested?
Nah, I hacked it to together with a switch/case-block. Works fine. I 
dropped my Artificial Life idea and just
implementated the A* Path finding algorithm in a isometric game field. 
:-) Works nice and easy.


Yours,
Weyert de Boer

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Object repository and instancing a object

2006-01-02 Thread Weyert de Boer

Hello Alan,


You initialize a TileFactory; the TileFactory loads this XML; then if 
I call TileFactory.getTile(uniqueName), it scans the XML for the 
matching tile entry and draws the tile properties from that. Build 
and assist values for the tile, and return it, and you're all set -- 
without having to worry about instantiating classes from a string.
Yes, this sounds like a better idea. Thanks. I have to admit that the 
current code is one big hack.


Coming from Java, I was used to having a lot more freedom to 
instantiate classes dynamically, with Class.forName, but Flash is more 
friendly to other approches.

Same here ;=)

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] Caret position coords

2006-01-02 Thread Andreas Rønning
Is there a decent way of getting the _x / _y position of a caret in a 
text box? Somehow compare the x/y of the textfield with the caret index..?

Have a hard time getting an exact value from this.

- Andreas
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Caret position coords

2006-01-02 Thread Weyert de Boer

Easy...  get the x,y in characters of the memo

function getCharacterPosition( aMemo: TMemo ): TPoint
begin
 Result.X := LongRec( SendMessage( aMemo.Handle, EM_GETSEL, 0, 0 ) ).Hi;
 Result.Y := SendMessage( aMemo.Handle, EM_LINEFROMCHAR, Result.X, 0 );
 Result.X := Result.X - SendMessage(aMemo.Handle, EM_LINEINDEX, -1, 0);
   return Result;
end;

and get the x,y in pixels of the memo

function getCharPositionInPixels( aMemo: TMemo ): TPoint
var result: TPoint;
begin
   result := aMemo.Perform( EM_POSFROMCHAR, WPARAM(@result), 
aMemo.SelStart);

   return result;
end

Not sure if the code is error free, though but are these api messages ;-)

Yours,
Weyert de Boer
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Caret position coords

2006-01-02 Thread Weyert de Boer

Ooh, this is the flashcoders mailing list. This code is useless! sorry.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Caret position coords

2006-01-02 Thread Michael Bedar
To answer the original question - there is no direct way to do this,  
although you can use the text-extent to get the x offset of the caret  
fairly easily in a single line textfield.



On Jan 2, 2006, at 9:47 AM, Andreas Rønning wrote:

Is there a decent way of getting the _x / _y position of a caret in  
a text box? Somehow compare the x/y of the textfield with the caret  
index..?

Have a hard time getting an exact value from this.

- Andreas
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Flash Player 8.5 - Illegal Operation caused by ?

2006-01-02 Thread Derek Vadneau
Firefox 1.0.6 also reports many syntax errors:

Error: syntax error
Source File: 
http://www.ericd.net/new_css/sections/aspcomments/aspcomments.asp?blogid=113621728008762265count=1
Line: 1
Source Code:
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN

Error: syntax error
Source File: 
http://www.ericd.net/new_css/sections/aspcomments/aspcomments.asp?blogid=113597757803253823count=1
Line: 1
Source Code:
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN

.. etc.


Derek Vadneau


-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of Adrian 
Lynch
Sent: Monday, January 02, 2006 12:06 PM
To: Flashcoders mailing list
Subject: RE: [Flashcoders] Flash Player 8.5 - Illegal Operation caused by 
?


Not sure about the Flash, but that page is full of JS errors on IE6.

Ade


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Flash Player 8.5 - Illegal Operation caused by ?

2006-01-02 Thread eric dolecki
Not quite sure what those errors are yet, but I am more concerned with Flash
barfing.

edolecki

On 1/2/06, Derek Vadneau [EMAIL PROTECTED] wrote:

 Firefox 1.0.6 also reports many syntax errors:

 Error: syntax error
 Source File:

 http://www.ericd.net/new_css/sections/aspcomments/aspcomments.asp?blogid=113621728008762265count=1
 Line: 1
 Source Code:
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN

 Error: syntax error
 Source File:

 http://www.ericd.net/new_css/sections/aspcomments/aspcomments.asp?blogid=113597757803253823count=1
 Line: 1
 Source Code:
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN

 .. etc.


 Derek Vadneau


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Adrian
 Lynch
 Sent: Monday, January 02, 2006 12:06 PM
 To: Flashcoders mailing list
 Subject: RE: [Flashcoders] Flash Player 8.5 - Illegal Operation caused by
 ?


 Not sure about the Flash, but that page is full of JS errors on IE6.

 Ade


 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Caret position coords

2006-01-02 Thread Kalle Thyselius, inlovewith
i remember doing this a few years ago, using

— a loop (filling the textfield) and autoSize=true to determine if
there was a line break (you could determine this in other ways)
— and if _height  old_height in the loop, do
— letterCurrentY += LINE_HEIGHT

then use getTextExtent() to get _x.

i remember there was some margins and stuff inside the text field to
take into account, but it worked. the problem is it can be hard to
find out the constant LINE_HEIGHT.

good luck,

kalle


On 1/2/06, Michael Bedar [EMAIL PROTECTED] wrote:
 To answer the original question - there is no direct way to do this,
 although you can use the text-extent to get the x offset of the caret
 fairly easily in a single line textfield.


 On Jan 2, 2006, at 9:47 AM, Andreas Rønning wrote:

  Is there a decent way of getting the _x / _y position of a caret in
  a text box? Somehow compare the x/y of the textfield with the caret
  index..?
  Have a hard time getting an exact value from this.
 
  - Andreas
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



--
inlovewith.com
inlovewith ltd.
kalle thyselius
linnégatan 76, stockholm, sweden
+ 46 707 602 600
inlovewith you
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Caret position coords

2006-01-02 Thread Alias
Whoa - dude, is that MFC or something?

Alias

On 1/2/06, Weyert de Boer [EMAIL PROTECTED] wrote:
 Easy...  get the x,y in characters of the memo

 function getCharacterPosition( aMemo: TMemo ): TPoint
 begin
   Result.X := LongRec( SendMessage( aMemo.Handle, EM_GETSEL, 0, 0 ) ).Hi;
   Result.Y := SendMessage( aMemo.Handle, EM_LINEFROMCHAR, Result.X, 0 );
   Result.X := Result.X - SendMessage(aMemo.Handle, EM_LINEINDEX, -1, 0);
 return Result;
 end;

 and get the x,y in pixels of the memo

 function getCharPositionInPixels( aMemo: TMemo ): TPoint
 var result: TPoint;
 begin
 result := aMemo.Perform( EM_POSFROMCHAR, WPARAM(@result),
 aMemo.SelStart);
 return result;
 end

 Not sure if the code is error free, though but are these api messages ;-)

 Yours,
 Weyert de Boer
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Object repository and instancing a object

2006-01-02 Thread Jim Kremens
You guys know that you can instantiate classes dynamically (sort of) in
Flash, right?

class ClassFactory {

 public static function getClass(name:String, args:Object):Object {
   return new Function(eval(name))(args ? args : []);
 }
}

/* USAGE
 * //can be any referenced class
 * var myClass = ClassFactory.getClass(org.flashcodersny.style.GradientFill,
args);
*/

As long as the class you're trying to instantiate exists in the _global
namespace, the above will work.  To make sure it exists, just say its name:

class DeclareClassNames {

  function DeclareClassNames() {
 org.myClass1;
 org.myClass2;
 //and so on...
  }
}

There have been a few threads on this subject recently...

Jim Kremens



On 1/2/06, Weyert de Boer [EMAIL PROTECTED] wrote:

 Hello Alan,
 
  You initialize a TileFactory; the TileFactory loads this XML; then if
  I call TileFactory.getTile(uniqueName), it scans the XML for the
  matching tile entry and draws the tile properties from that. Build
  and assist values for the tile, and return it, and you're all set --
  without having to worry about instantiating classes from a string.
 Yes, this sounds like a better idea. Thanks. I have to admit that the
 current code is one big hack.
 
  Coming from Java, I was used to having a lot more freedom to
  instantiate classes dynamically, with Class.forName, but Flash is more
  friendly to other approches.
 Same here ;=)

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




--
Jim Kremens
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] dataProvider questions

2006-01-02 Thread JesterXL
A dataProvider is a getter/setter property.  It is typically an Array, but 
can be an Object.  Array's have their prototype changed when you use the v2 
component framework.  They have methods added to them, and these methods 
make up the DataProvider API.  This API is used to add data to the array, 
and broadcast changes so components who use the dataProvider know what to do 
when changes occur.

DataProviders are created to allow many different Views to show and operate 
on data in the dataProvider.

Example:

a = [one, two, three];
my_list.dataProvider = a;

Your List on the stage called my_list will now show the 3 items in the 
list.

If you threw that at a DataGrid, and the DataGrid was editable, you could 
actually edit the items in the array.  Additionally, those changes would be 
broadcast to any other View that used a as the dataProvider.  You cannot do 
this with normal arrays, since doing this:

a.push(four);

Does nothing other than add data.  This, however:

a.addItem(four);

Broacasts an event using EventDispatcher so all UIComponents who implement 
the DataProvider API know what to do.

If you want to create compoenents that utilize the DataProvider, you have 2 
chocies:
- implement a getter/setter property of dataProvider, and register for a 
modelChanged event.  When that occurs, redraw your component.  Optionally, 
you can support DataProvider API methods via proxy.  Example:

public function addItemAt(index:Number, o:Object):Void
{
dataProvider.addItemAt(index, o);
}

The API is discussed heavily in the updated MX 2004 (7.2) documentation.

- The 2nd, and best way, is to utilize DataSelector.  DataSelector is a 
mixin, but I highly suggest you instead create an abstract base class 
(meaning only created for the sake of extending it), use the DataSelector 
mixin on the base class, and then extend the base class.  The reason for 
this is 2 fold: first, you have a LOT less code in your extended class since 
the DataSelector mixin adds A LOT; second, you can listen for modelChanged 
without using hacks.

DataSelector will do a bunch of things.  Mainly:
- give your component dataProvider powers
- your component automatically implements the DataProvider API
- you get properties like selectedItem, selectedIndex, etc.

For more info, check out:
http://www.jessewarden.com/archives/2005/06/dataselector_da.html
http://www.jessewarden.com/archives/2005/10/using_dataselec.html

http://www.jessewarden.com/archives/2004/07/how_to_get_data.html

- Original Message - 
From: Rich Rodecker [EMAIL PROTECTED]
To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com
Sent: Monday, January 02, 2006 4:55 PM
Subject: [Flashcoders] dataProvider questions


I'm having a little trouble with dataProviders.  I'm trying to search around
for info but I'm getting a little confused.  I'm going to try and ask some
q's... if anyone can help me out, that would be great.  I used to work with
it back in flash mx, but it looks like its changed a lot.

First, does anyone know of anyplace I can get some good solid info on
DataProvider?  the documentation in mx04 doesnt really do it for me.

I am creating a custom component, and would like it to be data-aware.  Looks
like I need to create a dataProvider property in my components class,
right?  Now, how do I go about binding the dataProvider property to a
separate Model class (I want to bind it to a property of ModelLocator in
ARP, if anyone is familiar) -- am I actaully talking about two different
things here?. I would also like to be able to set the dataProvider from an
xml object too (in other instances of the component).
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders 

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] dataProvider questions

2006-01-02 Thread JesterXL
Sorry G, missed your 2nd question.

Unfortunately, an Array is the ONLY thing you can bind to using a 
ModelLcoator approach (al la Cairngorm/ARP).  So, this is technically the 
de-facto way to do binding in Flash.

- Original Message - 
From: JesterXL [EMAIL PROTECTED]
To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com
Sent: Monday, January 02, 2006 5:08 PM
Subject: Re: [Flashcoders] dataProvider questions


A dataProvider is a getter/setter property.  It is typically an Array, but
can be an Object.  Array's have their prototype changed when you use the v2
component framework.  They have methods added to them, and these methods
make up the DataProvider API.  This API is used to add data to the array,
and broadcast changes so components who use the dataProvider know what to do
when changes occur.

DataProviders are created to allow many different Views to show and operate
on data in the dataProvider.

Example:

a = [one, two, three];
my_list.dataProvider = a;

Your List on the stage called my_list will now show the 3 items in the
list.

If you threw that at a DataGrid, and the DataGrid was editable, you could
actually edit the items in the array.  Additionally, those changes would be
broadcast to any other View that used a as the dataProvider.  You cannot do
this with normal arrays, since doing this:

a.push(four);

Does nothing other than add data.  This, however:

a.addItem(four);

Broacasts an event using EventDispatcher so all UIComponents who implement
the DataProvider API know what to do.

If you want to create compoenents that utilize the DataProvider, you have 2
chocies:
- implement a getter/setter property of dataProvider, and register for a
modelChanged event.  When that occurs, redraw your component.  Optionally,
you can support DataProvider API methods via proxy.  Example:

public function addItemAt(index:Number, o:Object):Void
{
dataProvider.addItemAt(index, o);
}

The API is discussed heavily in the updated MX 2004 (7.2) documentation.

- The 2nd, and best way, is to utilize DataSelector.  DataSelector is a
mixin, but I highly suggest you instead create an abstract base class
(meaning only created for the sake of extending it), use the DataSelector
mixin on the base class, and then extend the base class.  The reason for
this is 2 fold: first, you have a LOT less code in your extended class since
the DataSelector mixin adds A LOT; second, you can listen for modelChanged
without using hacks.

DataSelector will do a bunch of things.  Mainly:
- give your component dataProvider powers
- your component automatically implements the DataProvider API
- you get properties like selectedItem, selectedIndex, etc.

For more info, check out:
http://www.jessewarden.com/archives/2005/06/dataselector_da.html
http://www.jessewarden.com/archives/2005/10/using_dataselec.html

http://www.jessewarden.com/archives/2004/07/how_to_get_data.html

- Original Message - 
From: Rich Rodecker [EMAIL PROTECTED]
To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com
Sent: Monday, January 02, 2006 4:55 PM
Subject: [Flashcoders] dataProvider questions


I'm having a little trouble with dataProviders.  I'm trying to search around
for info but I'm getting a little confused.  I'm going to try and ask some
q's... if anyone can help me out, that would be great.  I used to work with
it back in flash mx, but it looks like its changed a lot.

First, does anyone know of anyplace I can get some good solid info on
DataProvider?  the documentation in mx04 doesnt really do it for me.

I am creating a custom component, and would like it to be data-aware.  Looks
like I need to create a dataProvider property in my components class,
right?  Now, how do I go about binding the dataProvider property to a
separate Model class (I want to bind it to a property of ModelLocator in
ARP, if anyone is familiar) -- am I actaully talking about two different
things here?. I would also like to be able to set the dataProvider from an
xml object too (in other instances of the component).
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders 

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] dataProvider questions

2006-01-02 Thread Rich Rodecker
thanks for all that info.

so, I can't bind to a recordset? that kinda sucks.  I guess i'd need to
convert the recordset or xml into an array of objects, then set that as the
dp for the component, right?


Side question..whats up with the Binding classes in the flash help?  would
they be of any use here?  I looked for them in the mx.data.binding package
but didnt see the actualy class files in there.









On 1/2/06, JesterXL [EMAIL PROTECTED] wrote:

 Sorry G, missed your 2nd question.

 Unfortunately, an Array is the ONLY thing you can bind to using a
 ModelLcoator approach (al la Cairngorm/ARP).  So, this is technically the
 de-facto way to do binding in Flash.

 - Original Message -
 From: JesterXL [EMAIL PROTECTED]
 To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com
 Sent: Monday, January 02, 2006 5:08 PM
 Subject: Re: [Flashcoders] dataProvider questions


 A dataProvider is a getter/setter property.  It is typically an Array, but
 can be an Object.  Array's have their prototype changed when you use the
 v2
 component framework.  They have methods added to them, and these methods
 make up the DataProvider API.  This API is used to add data to the array,
 and broadcast changes so components who use the dataProvider know what to
 do
 when changes occur.

 DataProviders are created to allow many different Views to show and
 operate
 on data in the dataProvider.

 Example:

 a = [one, two, three];
 my_list.dataProvider = a;

 Your List on the stage called my_list will now show the 3 items in the
 list.

 If you threw that at a DataGrid, and the DataGrid was editable, you could
 actually edit the items in the array.  Additionally, those changes would
 be
 broadcast to any other View that used a as the dataProvider.  You cannot
 do
 this with normal arrays, since doing this:

 a.push(four);

 Does nothing other than add data.  This, however:

 a.addItem(four);

 Broacasts an event using EventDispatcher so all UIComponents who implement
 the DataProvider API know what to do.

 If you want to create compoenents that utilize the DataProvider, you have
 2
 chocies:
 - implement a getter/setter property of dataProvider, and register for a
 modelChanged event.  When that occurs, redraw your component.  Optionally,
 you can support DataProvider API methods via proxy.  Example:

 public function addItemAt(index:Number, o:Object):Void
 {
 dataProvider.addItemAt(index, o);
 }

 The API is discussed heavily in the updated MX 2004 (7.2) documentation.

 - The 2nd, and best way, is to utilize DataSelector.  DataSelector is a
 mixin, but I highly suggest you instead create an abstract base class
 (meaning only created for the sake of extending it), use the DataSelector
 mixin on the base class, and then extend the base class.  The reason for
 this is 2 fold: first, you have a LOT less code in your extended class
 since
 the DataSelector mixin adds A LOT; second, you can listen for modelChanged
 without using hacks.

 DataSelector will do a bunch of things.  Mainly:
 - give your component dataProvider powers
 - your component automatically implements the DataProvider API
 - you get properties like selectedItem, selectedIndex, etc.

 For more info, check out:
 http://www.jessewarden.com/archives/2005/06/dataselector_da.html
 http://www.jessewarden.com/archives/2005/10/using_dataselec.html

 http://www.jessewarden.com/archives/2004/07/how_to_get_data.html

 - Original Message -
 From: Rich Rodecker [EMAIL PROTECTED]
 To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com
 Sent: Monday, January 02, 2006 4:55 PM
 Subject: [Flashcoders] dataProvider questions


 I'm having a little trouble with dataProviders.  I'm trying to search
 around
 for info but I'm getting a little confused.  I'm going to try and ask some
 q's... if anyone can help me out, that would be great.  I used to work
 with
 it back in flash mx, but it looks like its changed a lot.

 First, does anyone know of anyplace I can get some good solid info on
 DataProvider?  the documentation in mx04 doesnt really do it for me.

 I am creating a custom component, and would like it to be
 data-aware.  Looks
 like I need to create a dataProvider property in my components class,
 right?  Now, how do I go about binding the dataProvider property to a
 separate Model class (I want to bind it to a property of ModelLocator in
 ARP, if anyone is familiar) -- am I actaully talking about two different
 things here?. I would also like to be able to set the dataProvider from an
 xml object too (in other instances of the component).
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 ___
 Flashcoders mailing 

Re: [Flashcoders] dataProvider questions

2006-01-02 Thread JesterXL
Well, some things can, sure.  A RecordSet follows a subset of the 
DataProvider API.  If you look in mx.remoting.RecordSet, you can see he 
dispatchers modelChanged, and that's really all you need for dataProviders 
to work with the v2 components.

All of the binding stuff comes with the remoting classes:

MX 2004
http://download.macromedia.com/pub/flashremoting/mx2004/components/actionscript_2.0/flashremoting_comp_sourcecode.zip

Flash 8
http://www.macromedia.com/software/flashremoting/downloads/components/

I never used them, nor saw many people talk about them, but hey... it's says 
Binding so maybe it works, right?  Good luck.

- Original Message - 
From: Rich Rodecker [EMAIL PROTECTED]
To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com
Sent: Monday, January 02, 2006 7:24 PM
Subject: Re: [Flashcoders] dataProvider questions


thanks for all that info.

so, I can't bind to a recordset? that kinda sucks.  I guess i'd need to
convert the recordset or xml into an array of objects, then set that as the
dp for the component, right?


Side question..whats up with the Binding classes in the flash help?  would
they be of any use here?  I looked for them in the mx.data.binding package
but didnt see the actualy class files in there.









On 1/2/06, JesterXL [EMAIL PROTECTED] wrote:

 Sorry G, missed your 2nd question.

 Unfortunately, an Array is the ONLY thing you can bind to using a
 ModelLcoator approach (al la Cairngorm/ARP).  So, this is technically the
 de-facto way to do binding in Flash.

 - Original Message -
 From: JesterXL [EMAIL PROTECTED]
 To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com
 Sent: Monday, January 02, 2006 5:08 PM
 Subject: Re: [Flashcoders] dataProvider questions


 A dataProvider is a getter/setter property.  It is typically an Array, but
 can be an Object.  Array's have their prototype changed when you use the
 v2
 component framework.  They have methods added to them, and these methods
 make up the DataProvider API.  This API is used to add data to the array,
 and broadcast changes so components who use the dataProvider know what to
 do
 when changes occur.

 DataProviders are created to allow many different Views to show and
 operate
 on data in the dataProvider.

 Example:

 a = [one, two, three];
 my_list.dataProvider = a;

 Your List on the stage called my_list will now show the 3 items in the
 list.

 If you threw that at a DataGrid, and the DataGrid was editable, you could
 actually edit the items in the array.  Additionally, those changes would
 be
 broadcast to any other View that used a as the dataProvider.  You cannot
 do
 this with normal arrays, since doing this:

 a.push(four);

 Does nothing other than add data.  This, however:

 a.addItem(four);

 Broacasts an event using EventDispatcher so all UIComponents who implement
 the DataProvider API know what to do.

 If you want to create compoenents that utilize the DataProvider, you have
 2
 chocies:
 - implement a getter/setter property of dataProvider, and register for a
 modelChanged event.  When that occurs, redraw your component.  Optionally,
 you can support DataProvider API methods via proxy.  Example:

 public function addItemAt(index:Number, o:Object):Void
 {
 dataProvider.addItemAt(index, o);
 }

 The API is discussed heavily in the updated MX 2004 (7.2) documentation.

 - The 2nd, and best way, is to utilize DataSelector.  DataSelector is a
 mixin, but I highly suggest you instead create an abstract base class
 (meaning only created for the sake of extending it), use the DataSelector
 mixin on the base class, and then extend the base class.  The reason for
 this is 2 fold: first, you have a LOT less code in your extended class
 since
 the DataSelector mixin adds A LOT; second, you can listen for modelChanged
 without using hacks.

 DataSelector will do a bunch of things.  Mainly:
 - give your component dataProvider powers
 - your component automatically implements the DataProvider API
 - you get properties like selectedItem, selectedIndex, etc.

 For more info, check out:
 http://www.jessewarden.com/archives/2005/06/dataselector_da.html
 http://www.jessewarden.com/archives/2005/10/using_dataselec.html

 http://www.jessewarden.com/archives/2004/07/how_to_get_data.html

 - Original Message -
 From: Rich Rodecker [EMAIL PROTECTED]
 To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com
 Sent: Monday, January 02, 2006 4:55 PM
 Subject: [Flashcoders] dataProvider questions


 I'm having a little trouble with dataProviders.  I'm trying to search
 around
 for info but I'm getting a little confused.  I'm going to try and ask some
 q's... if anyone can help me out, that would be great.  I used to work
 with
 it back in flash mx, but it looks like its changed a lot.

 First, does anyone know of anyplace I can get some good solid info on
 DataProvider?  the documentation in mx04 doesnt really do it for me.

 I am creating a custom component, and would like