
Welcome Guest
|
|
|
#1
|
|||
|
|||
|
I have a real tester for you flash gurus out there. Or at least, I hope so and its not just a bug in Flash.
My problem is that in the code below which is a symplified version of what I am trying to do is that the property (x) is not created when the object obj is local. It works when if is global but I can't have that since I am using a recursibe routine. I would really appreciate it if someone could give me a tip on this one. Thanks a million in advance. Stephen function rec(x,level){ var obj = new Object(); obj.value=x; varname="obj."+x; set(varname,new Array()); if(x<5){ eval(varname)[0]=rec(x+1,level+1); }else{ return eval(varname); } } trace(rec(1,1)); |
|
#2
|
||||
|
||||
|
Hi dear_stephen,
Welcome to FlashMove !!To be honnest I can't understand what you are trying to do. What I can say is that if you need to refer to a common object in all the recursive calls, you can either make it global as you mentionned or pass it as a parameter at each call, but you have to be careful if each call modify your object. Recursion is difficult to debug. Please provide more information. If the original stuff you are doing is not too big, consider posting entirely. Tim.
__________________
n=4102746880;s="";do{s=String.fromCharCode((n&15)+ 101)+s}while(n>>>=4);trace(s); |
|
#3
|
||||
|
||||
|
Oh, and I did not see the connection between the title of the thread and the code. So to create a dynamic property, use the array operator:
Actionscript:
o = new Object(); myPropName = "hello"; o[myPropName] = "This is value of the property"; trace(o.hello); Your syntax with "set" was a bit weird. Ceers, Tim.
__________________
n=4102746880;s="";do{s=String.fromCharCode((n&15)+ 101)+s}while(n>>>=4);trace(s); |
«
Previous Thread
|
Next Thread
»
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Object property dump? | cdb0324 | Flash CS3 / Flash 9 |
1 | 10-01-2007 06:53 PM |
| turning dynamic text field into a variable for use inside xml object, need help | webjedikungfu | Actionscript 2.0 |
1 | 02-14-2007 01:54 PM |
| Class Object Property and Function.call() Error | dv8 | Advanced Flash | 8 | 09-16-2003 05:06 AM |
| Dynamic object reference | Shockwaver | Flash MX ActionScript |
7 | 04-02-2003 02:32 PM |
| how to load XML object to dynamic text field??? | neurowave | XML & Sockets | 1 | 08-09-2001 04:03 PM |


!!
