|
List Info
Thread: as2 xml proxy
|
|
| as2 xml proxy |
  Belgium |
2007-10-22 10:57:24 |
|
Hi List,
I came up with a xml proxy class after reading some blogs on the net
about patterns and as3
it works nicely for view - model communications since updating data is
out of the question in this relationship
you can use it as like this:
var dataxml:XML = new XML( '<test id="1"><label>hallo
world</label><descr>very big world
indeed</descr></test>' );
var proxy ataProxy = new DataProxy( dataxml );
value = proxy.getLabel();
OR LIKE THIS
value = proxy.label;
import be.netdust.site.data.IData;
import mx.utils.XPathAPI;
dynamic class be.netdust.core.proxy.DataProxy
{
public function DataProxy( data ) {
_data = data;
};
public function __resolve( _sProxyCall:String ) {
if( _sProxyCall.indexOf("get") != -1 ) {
var field:String = _sProxyCall.substr(3).toLowerCase();
var p ataProxy = this;
return function() {
return p["_resolvexml"].apply( p, [field] );
}
}
else return _resolvexml( _sProxyCall );
};
private function _resolvexml( _sProxyCall:String ) {
var _resultset:Array = XPathAPI.selectNodeList(
_data.firstChild, "/*/"+_sProxyCall );
if( _resultset.length == 0 ) {
throw new Error( "datamodel has no field property called "+
_sProxyCall );
return null;
};
if( _resultset.length == 1 ) return
_resultset[0].firstChild.nodeValue;
// create value array from nodelist;
var _valuearray:Array = [];
while( _resultset.length ) {
_valuearray.push( _resultset.shift().firstChild.nodeValue );
};
return _valuearray;
};
private var _api;
private var _data;
};
|
| Re: as2 xml proxy |

|
2007-10-23 03:38:49 |
|
Hi there Stefan, cool stuff...just one thing, thou. The import statement throw an error, for me is import mx.xpath.XPathAPI; and not
import mx.utils.XPathAPI;
thnxs for sharing!
regards, goliatone
On 10/22/07, Stefan Vandermeulen < mail netdust.be">
mail netdust.be> wrote:
Hi List,
I came up with a xml proxy class after reading some blogs on the net
about patterns and as3
it works nicely for view - model communications since updating data is
out of the question in this relationship
you can use it as like this:
var dataxml:XML = new XML( '<test id="1"><label>hallo
world</label><descr>very big world
indeed</descr></test>9; );
var proxy ataProxy = new DataProxy( dataxml );
value = proxy.getLabel();
OR LIKE THIS
value = proxy.label;
import be.netdust.site.data.IData;
import mx.utils.XPathAPI;
dynamic class be.netdust.core.proxy.DataProxy
{
public function DataProxy( data ) {
_data = data;
};
public function __resolve( _sProxyCall:String ) {
if( _sProxyCall.indexOf("get") != -1 ) {
var field:String = _sProxyCall.substr(3).toLowerCase();
var p ataProxy = this;
return function() {
return p["_resolvexml"].apply( p, [field] );
}
}
else return _resolvexml( _sProxyCall );
};
private function _resolvexml( _sProxyCall:String ) {
var _resultset:Array = XPathAPI.selectNodeList(
_data.firstChild, "/*/"+_sProxyCall );
if( _resultset.length == 0 ) {
throw new Error( "datamodel has no field property called "+
_sProxyCall );
return null;
};
if( _resultset.length == 1 ) return
_resultset[0].firstChild.nodeValue;
// create value array from nodelist;
var _valuearray:Array = [];
while( _resultset.length ) {
_valuearray.push( _resultset.shift().firstChild.nodeValue );
};
return _valuearray;
};
private var _api;
private var _data;
};
_______________________________________________ Pixlib mailing list osflash.org">Pixlib osflash.org
http://osflash.org/mailman/listinfo/pixlib_osflash.org
-- Emiliano Burgos Flash Designer&Developer burgosemi paginaswebflash.com">burgosemi paginaswebflash.com
www.paginaswebflash.com
|
| Re: as2 xml proxy |
  Belgium |
2007-10-23 03:52:47 |
|
yes, i know, sorry about that :(
i had to change the path of the files because flashdevelop wouldn't
import mx.xpath.XPathAPI
does anybody use flashdevelop here? do you have the same problem?
i'm still working on it too, because i want a decent structure for
datamodels and xml. this way you don't need to parse the whole file
into an object when you load it ( saves some processing... ) but you
can access it as it where an object
when i have a decent structure for this i'll post it again with correct
imports 
grts
s
Emi Burgos
schreef:
mail.gmail.com"
type="cite">Hi there Stefan,
cool stuff...just one thing, thou. The import statement throw an error,
for me is
import
mx.xpath.XPathAPI;
and not
import mx.utils.XPathAPI;
thnxs for sharing!
regards, goliatone
On 10/22/07, Stefan Vandermeulen <netdust.be">
mail netdust.be> wrote:
Hi List,
I came up with a xml proxy class after reading some blogs on the net
about patterns and as3
it works nicely for view - model communications since updating data is
out of the question in this relationship
you can use it as like this:
var dataxml:XML = new XML( '<test id="1"><label>hallo
world</label><descr>very big world
indeed</descr></test>' );
var proxy ataProxy = new DataProxy( dataxml );
value = proxy.getLabel();
OR LIKE THIS
value = proxy.label;
import be.netdust.site.data.IData;
import mx.utils.XPathAPI;
dynamic class be.netdust.core.proxy.DataProxy
{
public function DataProxy( data ) {
_data = data;
};
public function __resolve( _sProxyCall:String ) {
if( _sProxyCall.indexOf("get") != -1 ) {
var field:String = _sProxyCall.substr(3).toLowerCase();
var p ataProxy = this;
return function() {
return p["_resolvexml"].apply( p, [field] );
}
}
else return _resolvexml( _sProxyCall );
};
private function _resolvexml( _sProxyCall:String ) {
var _resultset:Array = XPathAPI.selectNodeList(
_data.firstChild, "/*/"+_sProxyCall );
if( _resultset.length == 0 ) {
throw new Error( "datamodel has no field property called "+
_sProxyCall );
return null;
};
if( _resultset.length == 1 ) return
_resultset[0].firstChild.nodeValue;
// create value array from nodelist;
var _valuearray:Array = [];
while( _resultset.length ) {
_valuearray.push( _resultset.shift().firstChild.nodeValue );
};
return _valuearray;
};
private var _api;
private var _data;
};
_______________________________________________
Pixlib mailing list
osflash.org">Pixlib osflash.org
http://osflash.org/mailman/listinfo/pixlib_osflash.org
--
Emiliano Burgos
Flash Designer&Developer
paginaswebflash.com">burgosemi paginaswebflash.com
www.paginaswebflash.com
_______________________________________________
Pixlib mailing list
osflash.org">Pixlib osflash.org
http://osflash.org/mailman/listinfo/pixlib_osflash.org
__________ NOD32 2608 (20071023) Informatie __________
Dit bericht is gecontroleerd door het NOD32 Antivirus Systeem.
http://www.nod32.nl
|
| Re: as2 xml proxy |

|
2007-10-23 10:24:55 |
|
Great stuff, i will be playing a bit with it...btw, i use Flashdevelop and i do get the same error...
On 10/23/07, Stefan Vandermeulen < mail netdust.be">
mail netdust.be> wrote:
ok, i finished a structure for datamodels (attachment) using xml.I hope
it39;s useful for some and maybe you can comment on it? make it better or
maybe there are better ways to achieve this in as2.
the whole idea is not to parse the xml onload, but use it as an object
anyway! making it easy to build models and let views communicate with
it ( eventually )
grtz
stefan
Stefan Vandermeulen schreef:
yes, i know, sorry about that :(
i had to change the path of the files because flashdevelop wouldn';t
import mx.xpath.XPathAPI
does anybody use flashdevelop here? do you have the same problem?
i'm still working on it too, because i want a decent structure for
datamodels and xml. this way you don't need to parse the whole file
into an object when you load it ( saves some processing... ) but you
can access it as it where an object
when i have a decent structure for this i'll post it again with correct
imports 
grts
s
Emi Burgos
schreef:
Hi there Stefan,
cool stuff...just one thing, thou. The import statement throw an error,
for me is
import
mx.xpath.XPathAPI;
and not
import mx.utils.XPathAPI;
thnxs for sharing!
regards, goliatone
On 10/22/07, Stefan Vandermeulen < mail netdust.be" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
mail netdust.be> wrote:
Hi List,
I came up with a xml proxy class after reading some blogs on the net
about patterns and as3
it works nicely for view - model communications since updating data is
out of the question in this relationship
you can use it as like this:
var dataxml:XML = new XML( '<test id="1"><label>hallo
world</label><descr>very big world
indeed</descr></test>9; );
var proxy ataProxy = new DataProxy( dataxml );
value = proxy.getLabel();
OR LIKE THIS
value = proxy.label;
import be.netdust.site.data.IData;
import mx.utils.XPathAPI;
dynamic class be.netdust.core.proxy.DataProxy
{
public function DataProxy( data ) {
_data = data;
};
public function __resolve( _sProxyCall:String ) {
if( _sProxyCall.indexOf("get") != -1 ) {
var field:String = _sProxyCall.substr(3).toLowerCase();
var p ataProxy = this;
return function() {
return p["_resolvexml"].apply( p, [field] );
}
}
else return _resolvexml( _sProxyCall );
};
private function _resolvexml( _sProxyCall:String ) {
var _resultset:Array = XPathAPI.selectNodeList(
_data.firstChild, "/*/"+_sProxyCall );
if( _resultset.length == 0 ) {
throw new Error( "datamodel has no field property called "+
_sProxyCall );
return null;
};
if( _resultset.length == 1 ) return
_resultset[0].firstChild.nodeValue;
// create value array from nodelist;
var _valuearray:Array = [];
while( _resultset.length ) {
_valuearray.push( _resultset.shift().firstChild.nodeValue );
};
return _valuearray;
};
private var _api;
private var _data;
};
_______________________________________________
Pixlib mailing list
Pixlib osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Pixlib osflash.org
http://osflash.org/mailman/listinfo/pixlib_osflash.org
--
Emiliano Burgos
Flash Designer&Developer
burgosemi paginaswebflash.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">burgosemi paginaswebflash.com
www.paginaswebflash.com
_______________________________________________ Pixlib mailing list Pixlib osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Pixlib osflash.org
http://osflash.org/mailman/listinfo/pixlib_osflash.org
__________ NOD32 2608 (20071023) Informatie __________
Dit bericht is gecontroleerd door het NOD32 Antivirus Systeem.
http://www.nod32.nl
__________ NOD32 2608 (20071023) Informatie __________
Dit bericht is gecontroleerd door het NOD32 Antivirus Systeem.
http://www.nod32.nl
_______________________________________________ Pixlib mailing list Pixlib osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Pixlib osflash.org
http://osflash.org/mailman/listinfo/pixlib_osflash.org
__________ NOD32 2608 (20071023) Informatie __________
Dit bericht is gecontroleerd door het NOD32 Antivirus Systeem.
http://www.nod32.nl
_______________________________________________ Pixlib mailing list osflash.org">Pixlib osflash.org
http://osflash.org/mailman/listinfo/pixlib_osflash.org
-- Emiliano Burgos Flash Designer&Developer burgosemi paginaswebflash.com">
burgosemi paginaswebflash.com www.paginaswebflash.com
|
[1-4]
|
|