This content has been marked as final. Show 1 reply
"kevmedia.com" <email@example.com> wrote in message news:firstname.lastname@example.org...
> Hi, thanks in advance for any guidance on this.
> You know how you can change the registration point of a MC in the properties
> dialog box? I'd like to do the same thing for an empty MC created via AS, so
> that I can position the thing in the center of the stage easily.
The registration point isn't programmable but you can use a trick to get the job done. The idea is to use 2 movieclips. The first
one, mc1, gets visibility settings and rotation etc, while the 2nd one inside of mc1 gets the image loaded into it.
This code creates two clips, loads the jpeg, waits until the header part of the jpeg comes in to get the width and height values,
then positions the clip and turns on visibility.
It is a demo to rotate an external jpeg around it's center point.
mc1._visible = false; // don't want to see the repositioning happen
id = setInterval(positionClip, 400);
// wait until the jpeg header comes in (the first 19 bytes)
if(!mc1.mc2._width) // if zero, just quit for now
clearInterval(id); // don't need this function anymore
mc1._x = 400; // position the base clip
mc1._y = 300;
// move the 2nd clip mc2 relative to the first clip mc1
// this puts the center of the loaded jpeg in mc2 on the top
// left corner of mc1 giving you a way to rotate about the
// center point of mc2
mc1.mc2._x = mc1.mc2._x - (mc1.mc2._width / 2);
mc1.mc2._y = mc1.mc2._y - (mc1.mc2._height / 2);
mc1._visible = true; // visible now
id = setInterval(spin, 12); // start rotation
spin = function()
mc1._rotation += 3; // rotate the base clip
updateAfterEvent(); // make it smoother looking