I'd assumed that function calls worked the same as other actions in an event. It seems that this isn't the case though.
As the actions above and below the function call are invoked for each instance of SpriteA that's created, I thought the function call would be as well.
It turns out that it's only called once though, only one instance of SpriteB is created.
Develop games in your browser. Powerful, performant & highly capable.
You've asked it to run once. On loader complete is a trigger event which happens once and then you run the function once. To run it for every instance you would have to use for each instance, which you should probably do in this case, your function will not pick the Sprite A correctly there.
It is creating SpriteA instances as expected, one per play area.
It spawns all of the sprites before the function and then the function runs once. A better idea than for each here might actually be to use 'on sprite A created' : function. Because it will run for each sprite A spawned and correctly pick the sprite A information for the function.
That's a good idea, I'll do that. Thanks.