Be a Supporter!

actionscript 3.0 sample question...

  • 255 Views
  • 4 Replies
New Topic Respond to this Topic
america190
america190
  • Member since: May. 3, 2012
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
actionscript 3.0 sample question... May. 3rd, 2012 @ 06:42 AM Reply

=====================
var object:Object = {};
object[ 158 ] = "String";
=====================
How do I use the "String" to get 158...........thank you help me

milchreis
milchreis
  • Member since: Jan. 11, 2008
  • Offline.
Forum Stats
Member
Level 26
Programmer
Response to actionscript 3.0 sample question... May. 3rd, 2012 @ 06:57 AM Reply

At 5/3/12 06:42 AM, america190 wrote: =====================
var object:Object = {};
object[ 158 ] = "String";
=====================
How do I use the "String" to get 158...........thank you help me

It's possible but not easy to do. If "String" is your key in your hash, use it as a key:

object["String"] = 158;

If you have to insist on using 158 as key and "String" as value, please elaborate more on what you want to do.

america190
america190
  • Member since: May. 3, 2012
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to actionscript 3.0 sample question... May. 3rd, 2012 @ 07:07 AM Reply

At 5/3/12 06:57 AM, milchreis wrote:
At 5/3/12 06:42 AM, america190 wrote: =====================
var object:Object = {};
object[ 158 ] = "String";
=====================
How do I use the "String" to get 158...........thank you help me
It's possible but not easy to do. If "String" is your key in your hash, use it as a key:

object["String"] = 158;

If you have to insist on using 158 as key and "String" as value, please elaborate more on what you want to do.

============================================================
=========================

thank you very much!
this is my writ code

var object:Object = {};
object[ 0 ] = "goto1";
object[ 1 ] = "goto2";
object[ 2 ] = "goto3";
object[ 3 ] = "goto4";

when I know this value, i want get the value corresponding to the position.

milchreis
milchreis
  • Member since: Jan. 11, 2008
  • Offline.
Forum Stats
Member
Level 26
Programmer
Response to actionscript 3.0 sample question... May. 3rd, 2012 @ 08:01 AM Reply

At 5/3/12 07:07 AM, america190 wrote: this is my writ code

var object:Object = {};
object[ 0 ] = "goto1";
object[ 1 ] = "goto2";
object[ 2 ] = "goto3";
object[ 3 ] = "goto4";

when I know this value, i want get the value corresponding to the position.

Why do you use Object and not Array?
It's still not enough information, what do you want to achieve in the end?

You could substring the last character of the String, but your code looks like you're doing something very wrong.

america190
america190
  • Member since: May. 3, 2012
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to actionscript 3.0 sample question... May. 3rd, 2012 @ 09:38 PM Reply

when I know this value, i want get the value corresponding to the position.
Why do you use Object and not Array?
It's still not enough information, what do you want to achieve in the end?

You could substring the last character of the String, but your code looks like you're doing something very wrong.

ouï¼OE i understand... use for ( var b* in Object )..

===code
public function getRaidMapId( raidId:int ):int
{
for ( var pi:* in _raidMap )
{
for each( var pj:RaidVO in _raidMap[pi] )
{
if ( pj.id == raidId )
return pi;
}
}
return 0;
}