Wednesday, September 2, 2009

Ideas?

Is there anything you want to know how to do? Post a comment!

Tuesday, July 7, 2009

How to make a custom cursor

I haven't made anything in awhile so I decided to make this tutorial on using custom cursors. Also this could be really easily made into a sniper game.

First of all draw your cursor then convert it into a symbol (F8) then select movieclip from the drop down box. After you do this double click your cursor and then you will be editing the movieclip. Once you're inside the movieclip, open up the align pallet by going to the top bar and Clicking Window > Align. Make sure "To stage:" is selected and select your cursor. Then use the align buttons to put the part of the cursor that you would like to click with at the Registration Point (The small + sign)

Double click anywhere on the stage to exit back the the main file. Select your cursor and make it's instance name "crs"







Next open up the Actions pallet and enter this code in the frame your cursor is in: stage.addEventListener(MouseEvent.MOUSE_MOVE, movecrs);
stage.addEventListener(Event.MOUSE_LEAVE, outahere);

function movecrs(e:MouseEvent):void {
crs.x = mouseX;
crs.y = mouseY;
crs.visible = true;
Mouse.hide();
crs.mouseEnabled = false;
crs.mouseChildren = false;
}

function outahere(e:Event):void {
Mouse.show();
crs.visible = false;
}


The first two lines tell Flash to "listen" for one event each. The first one says that when the mouse moves run the "movecrs" function. The next one says when the mouse leaves the screen run the "outahere" function. The next line opens the movecrs function. Then it sets the x and y position of the object you drew to the actual cursor. after that it makes sure your cursor is visible and then hides the actual mouse. The next two lines make sure that buttons work with your cursor. Then the "}" closes the function. next in the outahere function it says that when the mouse moves away from the Flash window it un-hides the real cursor and hides your cursor.

now hit control enter to test your cursor.

Tuesday, May 19, 2009

Simple Preloader

First open a new flash document and make four layers. name the top one "Actions", Then the second down should be "Outline", Then "Text", and finally the bottom layer should be "Bar" Select the layer named Bar and get the rectangle tool. Now draw a rectangle. Select the outline and right click and cut it out. Then select the Outline layer then right click and press "paste in place".









Now convert the fill into a movie clip. Do this by selecting it and hitting the F8 key. Make sure it's a movie clip and name it Loadbar.














Now go to the text layer and select the text tool. Then select dynamic text from the properties inspector and draw a text box under you load bar that is about the same width as it. and give it an instance name of "percent" (without the quotes and the no capital letters). Also change the instance name of the fill color to "lbar" (without the quotes and the no capital letters)Once you have both the instance names in go to the actions layer and hit F9 on your keyboard. This will open the actions window. now type in this code:

stop();
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, loadbar);

function loadbar(event:ProgressEvent):void {
var pcent:Number=event.bytesLoaded/event.bytesTotal*100;
lbar.scaleX=pcent;
percent.text="Loading... " + int(pcent)+ "%";
if(pcent==100){
gotoAndStop(2);
}
}

The first line stops the timeline where it is. The second line says that when the movie starts loading run the "loadbar" function. The third line makes a variable called "pcent" and makes it the percent of the bytes loaded of the movie. The fourth line makes the fill scale down to the percent loaded. The fifth line makes the text box say "loading... [percent loaded]%".
The sixth and seventh lines say that if the percent is 100 then go to frame 2 and stop there. then the two }'s close the if then the next one closes the function.

Now hit Ctrl + Enter to test the movie. If you hit Ctrl + Enter a second time once the window pops up it will simulate download so you can see your preloader working . If you want to do that put somthing after the preloader for it to load.

Have fun with your new preloader!