Skip to main content
Known Participant
December 7, 2009
Answered

How to find current MovieClip

  • December 7, 2009
  • 1 reply
  • 458 views

Hi

I am creating a flash file to display products.

Product details and images are stored in XML File.

What i am trying to create is something similar to banner on http://www.gainfeeds.com/home

The addition to this is that products will be scrolling right to left automatically if there is no interaction from user, and product at the center will remain highlighted.

I have created a long strip of Products cover with a mask, the long strip keeps moving to give a scrolling effect.

Now my question is how can i find the product which is currently at the center of the mask?


Thanks.

Alok Jain

This topic has been closed for replies.
Correct answer Venian

No there's no default name assigned to them.

If you take the parent movie clip and with for you apply a getChildNum() method, don't know exactly the sintax, you can take the childs of the parent by numeral assigment. 0,1,2,3,4... etc.

But this is not something that will help you much because you don't know which one is what number.

So, when you create the child movieclips based on the xml i presume you use a for statement. Thus in that for statement when creating each movieClip, fi you do something like " var m:MovieClip = new MovieClip(); " also do the following " m.name = "mc"+i ".

You will want to do this because the name "m" is valid only as long as the scope of the function si valid. Once the for statement begins again you loose all reference to the old "m" and a new one is created. So to future reference the movieClips outside the function that creates them you need to name them.

After that you can call them from anywhere (given that you set the path corectly to the parent) like this: " parentMovieClip.getChildByName("m3") " if you want to target the third one, or using any name you give in the creating for statement.

1 reply

Known Participant
December 9, 2009

No Replies

Let me try to simplify my question:

I have a dynamically created MovieClip, which contains multiple movieclips ( number based on XML data ).

How can i access the child MovieClips? Is there any name or number etc. assigned to them dynamically?

Thanks,

Alok Jain

Venian
VenianCorrect answer
Inspiring
December 9, 2009

No there's no default name assigned to them.

If you take the parent movie clip and with for you apply a getChildNum() method, don't know exactly the sintax, you can take the childs of the parent by numeral assigment. 0,1,2,3,4... etc.

But this is not something that will help you much because you don't know which one is what number.

So, when you create the child movieclips based on the xml i presume you use a for statement. Thus in that for statement when creating each movieClip, fi you do something like " var m:MovieClip = new MovieClip(); " also do the following " m.name = "mc"+i ".

You will want to do this because the name "m" is valid only as long as the scope of the function si valid. Once the for statement begins again you loose all reference to the old "m" and a new one is created. So to future reference the movieClips outside the function that creates them you need to name them.

After that you can call them from anywhere (given that you set the path corectly to the parent) like this: " parentMovieClip.getChildByName("m3") " if you want to target the third one, or using any name you give in the creating for statement.