|
1. Import your image into flash by clicking file=>import. Set your stage
to 550 wide by 400 high, black background.
2. Highlight the image and click Insert=>Convert to symbol. Call it mars
and set it to movie clip.
3. Position the symbol mars just too the left of stage so that the upper
right corner is aligned to the upper left corner of the stage. ( x=-150 and
y=0). Name the instance "mars".

4. Insert a new layer called scripts insert a key frame in frame 2 and 3
of the scripts layer by clicking in frame and hitting your F6 key. Click in
layer 1 frame 3 and hit F5 to increase the key frame.
5. Open your actions panel. In Frame 1 of the scripts layer we want to set a starting value for
the variable x. This is not the position x (_x), but will mirror the
position x in this tutorial. Add the following script to position the
instance off stage
The number 280 represents the width of the image. Since I want it off the
stage to the right and the edge of the stage is _x=0, the value should be
-280.
6. Click in frame2 of the script layer. Here we need to increment
the value of x so that it increases. We want a new value of x to equal the
old value of X plus 10. Add this script:
This means that when the X starts at -150, your movie goes to this frame
and changes x to -150 plus 10 or -160. 7. Click on frame 3 of the script
layer. Here we will need some sort of direction to the movie or it will go
back to play frame 1 and reset x. We can ask the movie to go to and play
frame 2 again to add 10 more, thereby not resetting the x value. Use the
following script in frame 3.
 8. Now
we need to set the x value so it actually indicates a property of this clip,
such as _x which is a positioning of the horizontal axis of the stage. Click
back on frame 2. Position your cursor after your existing script and hit
enter to go to the next line. Type in the path to your symbol instance, _root.mars
where _root is the stage, and the .mars to the next to indicate the
instance. Then you type in a period and the property you want to change, _x.
Play your movie and you should see your panet
move across the stage. 9. The next step is to set limits for your x value.
Once your planet is off the stage, it will continue counting the value
unless we either reset the movie, or stop it. imagine this scenario:
Your playing ball outside in the yard. Everything is ok as long as the
ball is inside the yard. But what will happen when the ball goes outside the
yard, say in the neighbors yard. You must have a rule for it such as "If the
ball goes in the neighbors yard, start the game again"
This is exactly what we must do in our movie to continue the motion in
the visible playing area (the stage). So we can add a statement that says If
we move off the stage, go back to frame 1 and start again. Add the following
script on the next line:
Since your stage is 550 wide, the symbol will be
off the stage at _x=550. If the stage was 750 wide, you could test for
greater then or equal to 750. and so on. 10. You are on your way to
playing with scripting straight line motion. You can now set the _y value.
It can be based on X or not, it can be independent of the current timeline
or not. Totally up to you. try this option- on frame 2 of scripting add a
line _root.mars._y = x/2 which would mean that position y will equal x
divided by 2.
|