Return to Starling Playback Library

How to get object by Instance name?

Questions related to Starling playback library should be asked here.

How to get object by Instance name?

Postby anatoly.norenko » July 2nd, 2014, 4:05 am

And is there any way to dynamically replace the GAFImage with your own resource?
User avatar
anatoly.norenko
 
Posts: 2
Joined: May 27th, 2014, 4:47 am

Re: How to get object by Instance name?

Postby vadym.mitin » July 4th, 2014, 8:07 am

Right now we have no option to do that. But this feature is in our task list. We will implement it as soon as we will have a time for that.
User avatar
vadym.mitin
 
Posts: 254
Joined: December 4th, 2013, 8:00 am

Re: How to get object by Instance name?

Postby Robin Johnson » August 30th, 2014, 7:29 pm

Could you also please answer the main question - how to get object by instance name?

I see mc.getChildByID(<string>) which I think means it will find the instance name. But when I debug and look at the mc, all of the instanceIDs are numbers which makes me think that there isn't a way to get the instanceName.

Example: I have a movie clip on frame 2, it has an instance name of "meta"

I try to do mc.getchildByID("meta") but it never returns true.

What am I doing wrong?

Thanks
User avatar
Robin Johnson
 
Posts: 2
Joined: August 30th, 2014, 7:18 pm

Re: How to get object by Instance name?

Postby Ivan Avdeenko » September 2nd, 2014, 12:34 am

Try
Code: Select all
mc.getChildByName("meta")
or just mc.meta. We support both options and we'll document it asap.
User avatar
Ivan Avdeenko
 
Posts: 30
Joined: June 6th, 2014, 12:22 am

Re: How to get object by Instance name?

Postby Robin Johnson » September 4th, 2014, 6:24 am

I see that "getObjectByName" is still implemented by DisplayObject. So are you doing some magic on import to translate instance names to DisplayObject.name ? Or do I have an old GAF.swc?

And are you exporting the instance names "for actionscript" so that they work as class names? Seems like that could be problematic, given the nature of instance names in the timeline and how they can change.


It didn't work for me (hence the questions) but I'll double check my test case.

Thanks!
User avatar
Robin Johnson
 
Posts: 2
Joined: August 30th, 2014, 7:18 pm

Re: How to get object by Instance name?

Postby vadym.mitin » September 10th, 2014, 3:10 am

http://gafmedia.com/converter/files/content/GAF_replace_demo_Starling.zip
Here you can download example very simple game that is using getChildByName("name"). In this example you will see how prepare graphics in your *.fla file (assets/GafReplaceDemo.fla) and how to access objects by instance name (src/GafReplaceDemo.as).
User avatar
vadym.mitin
 
Posts: 254
Joined: December 4th, 2013, 8:00 am

Return to Starling Playback Library

Who is online

Users browsing this forum: No registered users and 3 guests