all groups > flash actionscript > september 2004 >
You're in the

flash actionscript

group:

making stage/view center on most recently attached/created MC


making stage/view center on most recently attached/created MC Ken Fine
9/20/2004 10:12:44 PM
flash actionscript: I have a movie that attaches new movie clips at runtime in reponse to
changes in an XML file that it polls regularly. The clips are displaced
vertically based on how many clips have been generated; the effect is a
stack of textboxes in a listlike presentation.

I would like the "view" of the flash movie to follow the most recently
created clip, such that the most recently attached movieclip is moved to the
center of the view. Here's a snip of what my code is doing:

for (var i=0; i<menuItem.length; i++) {
itemCounter= itemCounter+1
item = _root.attachMovie("itemClip", "itemClip" + i, i);

item._x = 100;
item._y = 10 *i;

Basic stuff. Can anyone suggest the best approach for centering the newest
MC in the view? Extra credit: eventually I'll make it so that it moves the
view with programmatic "easing".

Thanks.

-KF

Re: making stage/view center on most recently attached/created MC Ken Fine
9/21/2004 12:01:32 AM
Thanks. Can people suggest other approaches?

I'd be interested a solution that could be generally applied to any MC
content, and would follow the "active" MC as determined by a counter or
label or other identifier.




[quoted text, click to view]

Re: making stage/view center on most recently attached/created MC SiggeJ
9/21/2004 6:51:57 AM
A simple way of doing this would be to put the generated mc:s in a scrollpane
that is scrolled in the XML pull function. You could use a setInterval() here
to create an 'ease' effect if you want, but be carefull here:
If an easy scroll is not completed when the next xml pull is performed, you
will have a synchronisation issue if you're not carefull.
AddThis Social Bookmark Button