Function to get instance layer name of a Component
Dominic Nestor
As the title said, maybe you can add a function called
instanceName()
, it will only work in a component. And return the instance layer name of this component in runtime.Here is a use case for this function:
Assume we have a component named
cell
, and several instance layer of this component in one scene, named cell 1
, cell 2
, ...All of this cells are out of screen at the beginnning, maybe right side of the screen. We need to move them into the screen one by one. Each of the move animation have a short interval. A very sample interaction, but still need a lot of work for now.
So, if we have the
instanceName()
function, it will be more easier.- create a number type variable in the component, name index.
- check Use Formulafor variableindex, the formula will like this:number(right(instanceName(),length(instanceName())-indexOf(instanceName()," ")-1))
- instanceName()will return the name of current instance, for layercell 1it will be "cell 1";
- so, length(instanceName())will get 6,indexOf(instanceName()," ")will get 4, minus with 1 will get the instance index.
- with starttrigger, just add amoveresponse to move the component to x:0, and set the delay to0.5*indexor0.5*(index-1)
- add an instance of this component to the scene, copy & paste, with ProtoPie 5.5, all the instance will get a auto-increase index start from 1.
- all we need to do is to put all the layers to screen right, then adjust the y position for every layer.
- run the prototype, everything will be done automatically.
One more thing, if we have
instanceName()
the layer()
function will also be more powerful.Konstantinos Partheniadis
Working on an AutoLayout component, this would actually help me get the child's name and resize the parent layer accordingly. Please notice this ProtoPie
Alex Restuccia
+1!
n
nomi sum
i'd like the same and i would have presumed something like
$this
to reference the current root layer. which sadly is not a thing (yet).