..:;WELCOME TO MY BLOG;:..

Tuesday, April 3, 2012

how to create dynamic star in flash

now i share about tutorial adobe flash professional how to make star dynamic field

create a new file and go to document properties. Adjust the properties as shown below:
document properties
Using oval tool draw a star. We can magnify and draw as we have to draw small one. Then goto Modify>Convert To Symbol and name it “Star”. Registration should be center.
star symbol
Then click on the star and again convert it to symbol. Name it “Starfield”. Registration should be center as in the image.
starfield symbol
Double click on the “Starfield” movieclip. Now we can work inside it.
edit symbol
Click on the star there and type its instance name “star” on its properties tab and also make the x and y both “0″ to bring it to the edge.
star instance name
Now we are going to create the area where the star will be generated by the code. For this we are going to create a plus sign. Remember we are still working inside the movieclip “Starfield”. Now draw a verticle line and make its height equal to 200 as the height of the document itself. For this you can directly type in its properties. Click it and type in the properties tab as in the image. Here we will position it by correcting the x and y also.
line properties1
Similarly draw a horizontal line and type in its properties as in the image below:
line properties2
Draw a third line now, vertical and modify its properties as before.
line properties3
Finally a fourth line and its properties.
line properties4
Now we can see a plus sign is formed.
preview
Select all the four lines and convert to symbol. Name it “Centerlines” and registration is center again.
centerlines
Goto its properties and type its instance name “centerlines”.
centerlines instance name
Now we wanna come out of the “Starfield” movie clip. For this click on “scene 1″ .
back to scene1
Now click the “Starfield” movieclip and convert it to symbol again. Name it “Stars”.
stars symbol
Double click on “Stars” movieclip. Now we are gonna work inside it.
stars edit
Right click on the Layer 1 and Click on “Insert Layer”.
insert layer
Now on this new layer i.e Layer 2, using a Rectangle Tool, draw a rectangle and modify its size and position from the properties.
rectangle properties
Now right click on Layer 2 and Click on “Mask”.
mask
Now right click on the first frame of the Layer 1 and click on “Actions”.
actions
Now copy the following code on the actions window:
starfield.centerlines._visible = 0;
x=starfield._width/2
y=starfield._height/2
initx = starfield._x;
inity = starfield._y;
_root.onEnterFrame = function() {
with (starfield) {
_x += 0;
_y += 2;
if (_x>initx+x) {
_x = initx;
}
if (_xinity+y) {
_y = inity;
}
if (_y Close the actions tab. And click on “Scene 1″ to get back from the “Stars” movieclip.
Press Ctrl+Enter for the result.
If you wanna change the speed or direction of the whole stars then you wanna try changing the values for the _x and _y on the code which are just after “with (starfield) {“.
Now we are done. If you have any problems doing this then feel free to comment. Enjoy flash

No comments:

Post a Comment