Re: [Flashcoders] creating variable names dynamically in AS3

2007-08-31 Thread eka
Hello :)

for me your notation in AS2 is false too... you can't use the 'var' keyword
and the 'this' keyword after. The compiler throw an error.

If you want use dynamic variables ... for me the best way it's an HashMap or
an Object :

# Use an Object :

var items = {} ;

for (var i:Number = 0 ; i10 ; i++)
{
  var item:Type = new Type() ; // you can test the type of your object
with a local variable in your loop
  items[ my_var + i] = item ;
}

# Use an HashMap implementation like my implementation in VEGAS :
http://code.google.com/p/vegas/

Documentation : http://vegas.ekameleon.net/docs/vegas/data/map/HashMap.html
Example :

import vegas.data.map.HashMap ;

var map:HashMap = new HashMap() ;

for (var i:Number = 0 ; i10 ; i++)
{
  var value:Type = new Type() ; // you can test the type of your object
with a local variable in your loop
  var name:String = key + i ;
  map.put( key, value ) ;
}

trace( map.get( 'key2' ) ) ;
trace( map.containsKey('key3') ) ;
trace( map.isEmpty() ) ;
// etc..

EKA+ :)

2007/8/30, Geografiek [EMAIL PROTECTED]:

 Hi,
 In AS2 in a for loop I would create a variable dynamically with:
 var this[nsPrefix + NS]:Namespace = new Namespace(ns.uri);

 In AS3 I get an error:
 1084: Syntax Error: expecting identifier before this.
 How would I name this variable dynamically in AS3?
 thanks,
 Willem van den Goorbergh


 =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 Geografiek is a Dutch, Utrecht-based map and chart design company.
 Willem van den Goorbergh can be contacted by telephone: (+31)
 30-2719512 or cell phone: (+31)6-26372378
 or by fax: (+31)302719687
 snail mail: Hooghiemstraplein 89 3514 AX UTRECHT
 Visit our website at: http://www.geografiek.nl
 =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=


 ___
 Flashcoders@chattyfig.figleaf.com
 To change your subscription options or search the archive:
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 Brought to you by Fig Leaf Software
 Premier Authorized Adobe Consulting and Training
 http://www.figleaf.com
 http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] creating variable names dynamically in AS3

2007-08-31 Thread Geografiek

Hi Eka,
Works like a charm. Thanks.
Willem van den Goorbergh

Op 31-aug-2007, om 10:14 heeft eka het volgende geschreven:


Hello :)

for me your notation in AS2 is false too... you can't use the 'var'  
keyword

and the 'this' keyword after. The compiler throw an error.

If you want use dynamic variables ... for me the best way it's an  
HashMap or

an Object :

# Use an Object :

var items = {} ;

for (var i:Number = 0 ; i10 ; i++)
{
  var item:Type = new Type() ; // you can test the type of your  
object

with a local variable in your loop
  items[ my_var + i] = item ;
}

# Use an HashMap implementation like my implementation in VEGAS :
http://code.google.com/p/vegas/

Documentation : http://vegas.ekameleon.net/docs/vegas/data/map/ 
HashMap.html

Example :

import vegas.data.map.HashMap ;

var map:HashMap = new HashMap() ;

for (var i:Number = 0 ; i10 ; i++)
{
  var value:Type = new Type() ; // you can test the type of  
your object

with a local variable in your loop
  var name:String = key + i ;
  map.put( key, value ) ;
}

trace( map.get( 'key2' ) ) ;
trace( map.containsKey('key3') ) ;
trace( map.isEmpty() ) ;
// etc..

EKA+ :)

2007/8/30, Geografiek [EMAIL PROTECTED]:


Hi,
In AS2 in a for loop I would create a variable dynamically with:
var this[nsPrefix + NS]:Namespace = new Namespace(ns.uri);

In AS3 I get an error:
1084: Syntax Error: expecting identifier before this.
How would I name this variable dynamically in AS3?
thanks,
Willem van den Goorbergh



=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Geografiek is a Dutch, Utrecht-based map and chart design company.
Willem van den Goorbergh can be contacted by telephone: (+31) 
30-2719512 or cell phone: (+31)6-26372378

or by fax: (+31)302719687
snail mail: Hooghiemstraplein 89 3514 AX UTRECHT
Visit our website at: http://www.geografiek.nl
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] creating variable names dynamically in AS3

2007-08-30 Thread Geografiek

Hi,
In AS2 in a for loop I would create a variable dynamically with:
var this[nsPrefix + NS]:Namespace = new Namespace(ns.uri);

In AS3 I get an error:
1084: Syntax Error: expecting identifier before this.
How would I name this variable dynamically in AS3?
thanks,
Willem van den Goorbergh


=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Geografiek is a Dutch, Utrecht-based map and chart design company.
Willem van den Goorbergh can be contacted by telephone: (+31) 
30-2719512 or cell phone: (+31)6-26372378

or by fax: (+31)302719687
snail mail: Hooghiemstraplein 89 3514 AX UTRECHT
Visit our website at: http://www.geografiek.nl
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com