You are not logged in.

Anoril

Trainee

  • "Anoril" started this thread

Posts: 69

Location: Paris, France

Occupation: Game Developer and Photographer

  • Send private message

1

Saturday, February 2nd 2019, 5:02pm

Nested arrays and Tween. A Bug or a Feature?

Hi there!
I'm working on some stuff and I have to efficietly parse children of Layers. Because I got a lot of layers and children, I decided to store the children nodes into a parent array instead of having a loop through all layers available. (That may be inconsistent, just tell me if you have better idea ;-) ).

OK, to get you see, Here is the expected structure:

Source code

1
2
3
4
5
<layer name="Parent">
   <layer name="Child0" />
   <layer name="Child1" />

</laver>
This structure is created by an action:

Source code

1
2
3
4
5
6
7
8
9
addLayer("Parent");

set(  layer[%1].onclick, showSubItems );

for( set(i,0), i LT 2, inc(i),
   txtadd(childName, "Child", get(i));
   addLayer(get(childName));   set( layer[get(childName)].parent, layer["Parent"]);
   copy( layer["Parent"].subItems[get(i)].item, layer[get(tagName)]);
);
This works like a charm.

The point is that the "showSubItem" action acts correctly with a direct "show" command:

Source code

1
2
3
4
5
6
<action name="showSubItem">
   for( set(i, 0), i LT subItems.count, inc(i),

  	set( subItems[get(i)].item.alpha, 1.0 );
  );
</action>


But when using a TWEEN command, it works [i]ONLY[/i] for the items with index greater than 0... i.e. the first item (idx=0) does not show.

Source code

1
2
3
4
<action name="showSubItem">
for( set(i, 0), i LT subItems.count, inc(i),
   tween( subItems[get(i)].item.alpha, 1.0, 3.0 );
  );</action>

Note that I found a workarround by modifying the index reference (saying it's a nonsense, as the index will ever be 0-N, but anyway, there is here a black-magic trick):

Source code

1
2
3
4
5
6
7
8
9
10
addLayer("Parent");

set(  layer[%1].onclick, showSubItems );

for( set(i,1), i LE 3, inc(i),
				
   txtadd(childName, "Child", get(i));
   addLayer(get(childName));   set( layer[get(childName)].parent, layer["Parent"]);
   copy( layer["Parent"].subItems[get(i)].item, layer[get(tagName)]);
);



I guess it is something about item-array naming convention or somewhat...

Regards,

Paul
« Quidquid latine dictum sit, altum sonatur »
Pentax stuff.

Anoril

Trainee

  • "Anoril" started this thread

Posts: 69

Location: Paris, France

Occupation: Game Developer and Photographer

  • Send private message

2

Saturday, February 2nd 2019, 7:24pm

Hoy!
I tried to fix by giving an actual name to the sub-item using txtadd(subName, "sub", get(i)) but I had the same behaviour.
A magic moment :)
Regards
« Quidquid latine dictum sit, altum sonatur »
Pentax stuff.