Hello :)
you don't limit your while loop instruction ?
while ( --i > -1)
{
}
EKA+ :)
2007/5/11, Steven Sacks <[EMAIL PROTECTED]>:
Even more optimized
public static function center():Void
{
var targetClip:MovieClip = MovieClip(arguments.shift());
centerX:Number = targetClip._x + (targetClip._width / 2);
centerY:Number = targetClip._y + (targetClip._height / 2);
var i:Number = arguments.length;
while (i--)
{
arguments[i]._x = centerX;
arguments[i]._y = centerY;
}
}
> public static function center():Void
> {
> var targetClip:MovieClip = MovieClip(arguments.shift());
> var i:Number = arguments.length;
> while (i--)
> {
> arguments[i]._x = targetClip._x + (targetClip._width / 2);
> arguments[i]._y = targetClip._y + (targetClip._height / 2);
> }
> }
>
> :)
>
>
> Alistair Colling wrote:
>> Hi there, just a quick syntax question, I want to receive a function
>> that will centre the position of all objects passed to that of the
>> first object passed but the number of objects passed may vary. This
>> is the syntax I am currently using, is this the best way to do it?
>> Thanks for any comments in advance :)
>> Ali
>>
>> //ob1 is the object that the objects in the array centre themselves to
>> public static function center(ob1:Object, ob_ar:Array) {
>> var targetX:Number = ob1._x;
>> var targetY:Number = ob1._y;
>> for (var i = 0; i<ob_ar.length; i++) {
>> ob_ar[i]._x = targetX+(ob1._width/2);
>> ob_ar[i]._y = targetY+(ob1._width/2);
>> }
>> }
>>
>> center(myMC, [myMC2, myMC3, myMC4]);
>>
>>
>>
>> _______________________________________________
>> [email protected]
>> To change your subscription options or search the archive:
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>> Brought to you by Fig Leaf Software
>> Premier Authorized Adobe Consulting and Training
>> http://www.figleaf.com
>> http://training.figleaf.com
>
>
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com