Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Community Beginner ,
Oct 19, 2015 Oct 19, 2015

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

TOPICS
ActionScript
257
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 19, 2015 Oct 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();

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 20, 2015 Oct 20, 2015

thank you. that was helpful!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 20, 2015 Oct 20, 2015
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines