Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand you correctly, it seems all you want is a handle to the movieclip inside your tileList and from there, you want to add an event listener.</p> <p>There are many ways to get a handle to the movieClip inside your tileList. First, I'd say you should be making use of a <a href="http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/fl/controls/TileList.html#dataProvider" rel="nofollow noreferrer">dataProvider along the lines of the example here</a>. This would serve as the model for your display object. From there, you can just access your desired movieclip from within the list as in:</p> <pre><code>import fl.controls.TileList; import fl.data.DataProvider; var dp:DataProvider = new DataProvider(); dp.addItem(moviClip1); dp.addItem(moviClip2); dp.addItem(moviClip3); dp.addItem(moviClip4); var myTileList:TileList = new TileList(); myTileList.dataProvider = dp; addChild(myTileList); ... //sometime later in the code //this adds a listener to movieClip3 dp.getItemAt(3).addEventListener(MouseEvent.CLICK, onClick); ... //or for (var mc in dp.toArray()) { (mc as DisplayObject).addEventListener(MouseEvent.CLICK, onClick); } </code></pre> <hr> <p>Another approach (if you can't work with the data provider) would be to try your luck with the following TileList methods:</p> <pre><code>getChildAt(index:int):DisplayObject getChildByName(name:String):DisplayObject getChildIndex(child:DisplayObject):int getItemAt(index:uint):Object </code></pre> <p>and see if you can get access to the clip you want. If it were me, I'd test by doing something like:</p> <pre><code>var mc:MovieClip = myTileList.getChildAt(1) as MovieClip; if(mc != null) mc.addEventListener(MouseEvent.CLICK, doSomethingWhenClicked); public void function doSomethingWhenClicked(event:MouseEvent):void { Alert.show('click!', 'click'); } </code></pre> <p>Then, I'd keep trying different things on line 1 until the alert popped up.</p> <p>I hope that helps in some way,</p> <p>--gMale</p> <p>EDIT: In response to your comment below, here is a quick example off the top of my head of you might play around with your clip and find the button (it may not compile but you should get the idea). Use this only if you don't have an ability to edit the clip and if its button is actually a fl.controls.Button (as opposed to a MovieClip button):</p> <pre><code>import fl.controls.Button; var buttonsFound:Integer = 0; //assume mytiledClip points to your clip that has the button on it for(var i=0; i &lt; myTiledClip.numChildren; i++) { var button:Button = myTiledClip.getChildAt(i) as Button; if(button != null){ Alert.show('Button Found at index:' + i, 'Button Found'); buttonsFound++; } } Alert.show('Number of buttons found: ' + buttonsFound, 'Search Complete'); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload