Skip to main content
Participant
October 19, 2015
Question

Make a new object, use for naming event.currentTarget.name

  • October 19, 2015
  • 1 reply
  • 275 views

Hi,

within a drawing app I have an inventory of graphic symbols (all button mc's). On click the user can place an instance of a symbol with same shape on the drawing board.

Calls should use the same procedures for all present symbols.

Naming of these buttons is such (i.e. circle_but) that I can extract the name of the corresponding symbol mc (circle) via event.currentTarget.name. All fine so far.

How do I get with this string information (circle) the symbol mc (circle) now on stage?

Regards

Thomas

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
October 19, 2015

assign classes to your objects and use the 'new' constuctor to create instances.

use addChild() to add to the display.

assign instance names to suit your needs.

eg,

var circle_0:Circle=new Circle();

circle_0.name='circle_0''

or more generally,

var circle_0:Circle=Circle(createObject("CircleClass"));

circle_0.name="circle_0";

function createObject('className:String):*{

var C:Class=Class(getDefinitionByName(className));

return new C();

}

Participant
October 20, 2015

thank you. that was helpful!

kglad
Community Expert
Community Expert
October 20, 2015

you're welcome.