Viewpoint Developer Central    Viewpoint Forums    Viewpoint Forums  Hop To Forum Categories  Viewpoint ZoomView & Flash Authoring    Actionscript - for(... in ..) loop

Moderators: e_phoenix13
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Member
Posted
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
 
Posts: 48 | Registered: November 28, 2005Reply With QuoteEdit or Delete MessageReport This Post
Member
Posted Hide Post
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.
 
Posts: 48 | Registered: November 28, 2005Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Admin
Posted Hide Post
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,

Zip/GZ archiveflash_scripting_v2.zip (17 KB, 43 downloads)
 
Posts: 1188 | Registered: January 08, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Posted Hide Post
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.

Zip/GZ archivefor_in_issue.zip (40 KB, 38 downloads)
 
Posts: 48 | Registered: November 28, 2005Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Admin
Posted Hide Post
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';
}
 
Posts: 1188 | Registered: January 08, 2003Reply With QuoteEdit or Delete MessageReport This Post
  Powered by Eve Community  
 

Viewpoint Developer Central    Viewpoint Forums    Viewpoint Forums  Hop To Forum Categories  Viewpoint ZoomView & Flash Authoring    Actionscript - for(... in ..) loop