[Flashcoders] AS3: for in loops with nested MCs

2009-07-24 Thread Schnurgle Schnurgle
I'm migrating an AS2 project to AS3. I'm not sure how to approach this part of 
the migration. I have a  MovieClip called us_states_mc. It contains 50 
MovieClips, one of each US state.  us_states_mc  has this code inside it:

for (var item in this)
{
this[item].id = item.toString();
this[item].onRelease = function ()
{
_root.zoomToState(this.id);
};
};

How can I recreate this functionality in AS3?


  
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3: for in loops with nested MCs

2009-07-24 Thread ekameleon
Hello :)

Read the reference AS3 of the MovieClip class :

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/MovieClip.html

The new display list implementation of the DisplayObjects is different in
AS3.

The MovieClip class inherit the DisplayObjectContainer class and you can use
now :

- the numChildren property to defines the number of childs in the MovieClip
- the getChildAt() method to keep all childs with a specific position

Example :

var action:Function = function( e:Event ):void
{
  trace( e ) ;
}

var item:DisplayObject ;
var size:int = zoomState.numChildren ;
for( var i:int = 0 ; isize ; i++ )
{
 item = zoomState.getChildAt( i ) ;
 item.addEventListener( Event.CLICK , action ) ;
}

If you want learn the AS3, read the documentation :-)

EKA+ :)

2009/7/24 Schnurgle Schnurgle schnur...@yahoo.com

 I'm migrating an AS2 project to AS3. I'm not sure how to approach this part
 of the migration. I have a  MovieClip called us_states_mc. It contains 50
 MovieClips, one of each US state.  us_states_mc  has this code inside it:

 for (var item in this)
 {
this[item].id = item.toString();
this[item].onRelease = function ()
{
_root.zoomToState(this.id);
};
 };

 How can I recreate this functionality in AS3?



 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3: for in loops with nested MCs

2009-07-24 Thread Deepak Sahu
register the click listener to top MC and make it capture phase
true.. and keep checking the event.currentTarget.
hope this help.

On Fri, Jul 24, 2009 at 12:22 PM, Schnurgle Schnurgle
schnur...@yahoo.comwrote:

 I'm migrating an AS2 project to AS3. I'm not sure how to approach this part
 of the migration. I have a  MovieClip called us_states_mc. It contains 50
 MovieClips, one of each US state.  us_states_mc  has this code inside it:

 for (var item in this)
 {
this[item].id = item.toString();
this[item].onRelease = function ()
{
_root.zoomToState(this.id);
};
 };

 How can I recreate this functionality in AS3?



 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders