Viewpoint Forums
Viewpoint Forums
Viewpoint ZoomView & Flash Authoring
Actionscript - for(... in ..) loop|
Go
![]() |
New
![]() |
Find
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
|
Member |
Hi there,
I had to determine that for-in-loops do not function in Actionscript under VMP. Perhaps I must consider something with the definition. Does someone know more about it? thanks in advance |
||
|
|
Member |
Please could somebody help me?
This is urgent! I have to write a complete elaboration until June 30. It covers all of viewpoint's scripting-possibilities and problems. And this Board is the only way to confirm my experiences. |
|||
|
|
Member |
Hello,
As long as you're using Flash 5 syntax, and publishing a Flash 5 swf, I don’t know of any issues with for loops… the attached example has one in it on the first frame. Regards This message has been edited. Last edited by: Admin, flash_scripting_v2.zip (17 KB, 43 downloads) |
|||
|
|
Member |
I made a own sample to show the issue.
I was suprised, seeing that the loop seems to work well, because it never worked before. But there's still something wrong with the key's. Could you please take a look over the sample's code. The .fla is a flash-mx-2004 file, but the .swf was exported as flash 5. for_in_issue.zip (40 KB, 38 downloads) |
|||
|
|
Member |
Sorry, you are correct, there is a bug here, but there is a work around. you can modify your code like so to get the same results/functionality.
mvp = [ { name: 'weight', val: '212 lbs.' }, { name: 'height', val: '6-4' }, { name: 'position', val: 'Guard' }, { name: 'fname', val: 'Dwyane' }, { name: 'name', val: 'Wade' } ]; of course the disadvantage here is that this is an array of 'anonymous' objects accessible via index rather than name, so a helper function would be needed to get an object by name. Note: This cannot be prototyped in our player yet, sorry. mvp.GetArrayObject = function(name) { for (var i = 0; i < this.length; i++) { if (name == this[i].name) return this[i]; } } // example trace(mvp.GetArrayObject("weight").val); // then slightly modify your loop for (var i = 0; i < mvp.length; i++) { textfield1_var += mvp[i].name+':\n'; textfield2_var += mvp[i].val+'\n'; } |
|||
|
| Powered by Eve Community |
| Please Wait. Your request is being processed... |
|
Viewpoint Forums
Viewpoint Forums
Viewpoint ZoomView & Flash Authoring
Actionscript - for(... in ..) loop
