flash actionscript:
Hi,
I haven't seen this example but I'm fairly certain it's because the
clip is not aligned to it's upper left-hand corner. If you open up the
ball clip I suspect that you'll find that it's not sitting exactly to
the lower right-hand side of the cross-hairs.
However, if you use the align tool and allign it to the top and left
edges the X and Y values will match up both on stage and when you trace
them out.
Rotation and scaling also play a factor in these values so you might
want to check the code if this is being played with.
Regards,
Patrick
[quoted text, click to view] NBSflasher wrote:
> Hi , tapping into this forum in hopes of resolving a question I am having with
> the third part of Lesson 2, the Pool Table exercise in Training From the
> Source for Flash MX 2004. So I'm checking out the stage area, and Im looking
> at the properties for the ball_mc movieclip. In the properties inspector, I see
> that the X and Y coordinates for this MC are 320 and 139.5 respectively (this
> is how it was set up on the stage when the OrchestratingEvents1.fla file is
> opened). The ball is in the correct position next to the stick and invisible
> button. However, step 3 on page 180 assigns a mouse event to the invisible
> button next to the ball, to return the ball to starting position. The mouse
> event is as follows:
>
> on (press) {
> ball_mc._x=360;
> ball_mc._y=180;
> power=0;
> powerAmount_txt.text=power;
> hitAmount=0;
> trackMouse=true;
> mouseStart=_root._xmouse;
> }
>
> When the invisible button is pressed, it does seem to bring the ball exactly
> back to the original location next to the pool stick. But according to the
> properties of ball_mc, its original position is 320 and 139.5 (X and Y
> respectively). So why does moving it to 360 and 180 within the actionscript
> bring it back to its original position, when the original position according to
> the properties of instance is not 360 and 180, but instead 320 and 139.5?
>
>
> Appreciate the help.
> -NBS
Hi , tapping into this forum in hopes of resolving a question I am having with
the third part of Lesson 2, the Pool Table exercise in Training From the
Source for Flash MX 2004. So I'm checking out the stage area, and Im looking
at the properties for the ball_mc movieclip. In the properties inspector, I see
that the X and Y coordinates for this MC are 320 and 139.5 respectively (this
is how it was set up on the stage when the OrchestratingEvents1.fla file is
opened). The ball is in the correct position next to the stick and invisible
button. However, step 3 on page 180 assigns a mouse event to the invisible
button next to the ball, to return the ball to starting position. The mouse
event is as follows:
on (press) {
ball_mc._x=360;
ball_mc._y=180;
power=0;
powerAmount_txt.text=power;
hitAmount=0;
trackMouse=true;
mouseStart=_root._xmouse;
}
When the invisible button is pressed, it does seem to bring the ball exactly
back to the original location next to the pool stick. But according to the
properties of ball_mc, its original position is 320 and 139.5 (X and Y
respectively). So why does moving it to 360 and 180 within the actionscript
bring it back to its original position, when the original position according to
the properties of instance is not 360 and 180, but instead 320 and 139.5?
Appreciate the help.
-NBS
its that way to offset the difference in the registration mark for the ball
graphic itself.
in flash, double click on the ball instance to bring up the editor and you'll
see that in the properties panel for the ball bitmap(not ball instance), that x
is now -40 and y is now -40.5. So x 360 and y 180 minus these values is
equal to what you see on ball instance, 320 and 139.5 respectively .
Why did they do thise? Again in the ball editor, if you look at the ball, you
see that the registration mark, that crosshair, is on the ball itself. If you
go ahead and change the x and y back to 0 and 0, you'll see the registation
mark go off the ball and into the left hand top corner. Because the ball
graphic is a bitmap, by default the x and y registartion mark is on the upper
left corner of the entire graphic, so the creator of this fla, offset the x and
y so they could better align the center of the ball with thier pool stick.
THey could have, and this is much easier IMO, have instead set the
registration mark's x and y starting point to the center. So that the center
of the graphic would be 0,0 and not the upper left hand corner.
to set the registration mark alignment, click on the ball graphic and press
ctrl+i ( if on mac, maybe its cmd+i). You'll see a grid of 9 small boxes, if
you select any of those, the registration mark starting point will start at
that point. Right now the top left corner box is selected. Also good to know,
you can change the registration mark for any object, not just the in the
editor, but the movieclips on stage, buttons etc.
hope that helps.