Sawfish Media

Game/Animation Software
Game/Animation SoftwareIn the field of internet game design and animation, there is mainly only one product: Flash. Of course even with an educational discount, it's about $200+. Here are some methods of creating games/animations without flash.FlashDevelopThis is what I use to make games in AS3, since I only have an older version of Flash (MX). You can find FlashDevelop at www.flashdevelop.org. FlashDevelop is basically an IDE (Integrated Development Enviroment), and only supports programming (and embed objects, no graphical design interface). Here's the steps to set it up: Download/install FlashDevelop (Releases) Download the Flex (3.0) SDK (SDK download) Open up FlashDevelop and link to the SDK in the settings Test it, to make sure it compiles the project Many people actually prefer using FlashDevelop for programming instead of Flash. To me, it really improves my OOP (object oriented programming) since there isn't any graphical design involved. You can still use images and objects from other .swfs.Doink.comDoink.com is a website which enables people to create animations and vector images through their website. So far this is the best (free) alternative I've found for flash, though I'm sure there are others. It has a lot of the same tools as flash and also incorporates objects/symbols into the process. In many ways, forms of tweening is actually easier through this program. Though, you are limited to their "player" to view the video/animation, and you can embed it in different websites.4/21/2009AS30
Easy Email Verification
Easy Email VerificationWhen you have a website in which people create accounts and have to enter an email, it is very important that that is actually their email. For these reasons: This is how you contact your user(s) privately, so in order to get information to user(s), it must be their real email. Email usually handles when a user forgets their password (or username). It is a piece of trust between the user and the creator of the site, something they can rely on in case something happens to a user's account. This tutorial will talk about a very simple way of doing email verification that can be used/implemented in C#, php, VB or any other server-side language. I will be using C# for this tutorial, with the ASP.Net Membership class (too make things easier).The Code and TheoryFirst, a user creates a new account for themselves on the sign-up page:protected void createUser_click(object sender, EventArgs e){try{ MembershipUser newUser = Membership.CreateUser(UserName, Password, Email, null, null, false, out status); //creates new user    if(newUser != null){        newUser.Comment = generateRandomString(20); //generates a random string, more about this later        Membership.UpdateUser(newUser);        Response.Redirect("validate.aspx?u=" + newUser.UserName);    }}}This creates a new user using Membership.CreateUser(username, password, email, question, answer, approved, createStatus). Then when the user has been created a random string is made and stored into the Comment section of the database. This will be used to verify that the email is theirs.The Random string can be generated many different ways, you could just do numbers, but the best is alphanumberic, but I'll just show numberic for the ease.public static string generateRandomString(int length){    Random rand = new Random();    return rand.Next(length).ToString();}This generates a random string of a certain length verification. After creating their account, the user is redirected to a validation page, where an email is sent out to the user.protected void Page_Load(object sender, EventArgs e) { string userName = Request.QueryString["u"]; //the user string verification = Request.QueryString["v"]; //verification code if(userName != null && verification == null){            var user = Membership.getUser(userName); string strSubject = "Account Activation"; string strBody = "<a href='validate.aspx?u=" + userName + "&v=" + user.Comment + "'>Validate your Account</a>"; MailMessage mail = new MailMessage(new MailAddress("activation@example.com"), new MailAddress(user.Email)); mail.Subject = strSubject; mail.Body = strBody; mail.IsBodyHtml = true; SmtpClient server = new SmtpClient(); try { server.Host = "mail.example.com"; //server.EnableSsl = true; System.Net.NetworkCredential cred = new System.Net.NetworkCredential(); cred.UserName = "activation@example.com"; cred.Password = "password"; server.UseDefaultCredentials = true; server.Credentials = cred; server.Send(mail); } catch (SmtpException ex) { Response.Write("error"); }Response.Write("email sent");}if(userName != null && verification != null){ var user = Membership.getUser(userName); if(verification == user.Comment){ user.isApproved = true; Membership.UpdateUser(user); Response.Write("account verified");        Response.Redirect("login.aspx");}}}The validation page first checks for the userName and verification variables. If there is only a username, it sends an email to the user's email address with a link to the validation page which has the validation code from the Comment row of the db. When the user gets the email they click on the link which takes them to the same page but the page sees the validation code. The page then checks the code against the Comment row and if it is the same validates the account and redirects to the login page.ImprovementsThis can be customized and improved in many different ways. A long random string with which is alphanumeric and also has symbols. A cleaner email (HTML) which looks nice and like your website. Factoring the Date/Time into the random string Redirect users who are already validated to the login page And others! Of course, other services on the internet like OpenId, Facebook Connect and Google Opensocial can serve as ways to validate a user automatically.1/15/2009C#0
Color();
Color();Color is crucial to an game or website as well as art/graphics. This article/tutorial will talk about colors and color trends as well about programming colors.Hexadecimal ColorsColors that are expressed in websites or in programming are usually expressed as a hexadecimal number, such as #FFFFFF for white. Hexadecimal means that the number has a base of 16. For instance, 0=0, 1=1, 2=2... A=10, B=11, C=12, D=13, E=14, F=15. One hexadecimal value is equal to 4 byte values, F = 1111. So two hexadecimal values are equal to eight byte values which equal a maximum number of 255.A hexadecimal color is basically a RGB value. For instance in #FF4466, red = FF, green = 44 and blue = 66. And as stated in the other paragraph these values are out of 255 just like RGB. Just remember that a hexadecimal color is still a number and it can be used like a number.Color TrendsInverting a colorThe inverse of a color is the exact opposite of the color. For instance the exact opposite of white is black. An inverted color is surprisingly easy find. All that you have to do is subtract the original color from white. Here's an example:public static function invertColor(color:Number):Number{ return 0xFFFFFF - color;}Now remember that a color is just a number so a function would return a number. White is #FFFFFF or in actionscript 0xFFFFFF (0x is the same as # indicating a hexadecimal number). So white - the original color will give you the inverse.Finding another shade of a colorFinding the shade of a color is basically finding the ratios of each of the RGB values. First you determine which RGB value is the largest, this will have a ratio of 1. Then you find the ratios of the other values to the largest. Here's a example:public static function getColorShade(shadecolor:Number, percent:Number):Number{var basecolor:Object = ConvertToRGB(shadecolor);var Colorratios:Object = new Object();var color:Object = new Object();if (basecolor.r > basecolor.b && basecolor.r > basecolor.g){ Colorratios.r = 1; Colorratios.g = basecolor.g / basecolor.r; Colorratios.b = basecolor.b / basecolor.r;}else if(basecolor.g > basecolor.r && basecolor.g > basecolor.b){ Colorratios.g = 1; Colorratios.r = basecolor.r / basecolor.g; Colorratios.b = basecolor.b / basecolor.g;}else{ Colorratios.b = 1; Colorratios.r = basecolor.r / basecolor.b; Colorratios.g = basecolor.g / basecolor.b;}var hexvalue = percent * 255;color.r = hexvalue * Colorratios.r;color.g = hexvalue * Colorratios.g;color.b = hexvalue * Colorratios.b;return ConvertToHEX(color);}public static function ConvertToRGB(hexNum:Number):Object{ var rgbObj:Object = new Object(); rgbObj.r = hexNum >> 16; var tmpVal:Number = hexNum ^ rgbObj.r << 16; rgbObj.g = tmpVal >> 8; rgbObj.b = tmpVal ^ rgbObj.g << 8; return rgbObj;}public static function ConvertToHEX(rgb:Object):Number{ return rgb.r << 16 ^ rgb.g << 8 ^ rgb.b}What this does is it first has two main functions ConvertToHEX() and ConvertToRGB(). These two functions are able to switch between RGB values (for generating ratios and also the shade of the color) and HEX (for displaying the actual color). Then in the getColorShade function, it recieves a color and a percent (0-1). It then calculates the ratios of the RGB values by first finding the highest value and then dividing the other values by it to get ratios for each RGB value. Then the percent is multplied by the full value of a RGB, 255 to get the starting value for the greatest ratio of the RGB. Then that number is multiplied by the ratios to get the RGB value of the shade, which is then converted to a hexadeciamal value at the end.The source has both examples here as well as CMYK conversions.10/16/2008AS32
AS3 Basics
AS3 BasicsActionscript is large part of the internet. Every Flash website that you visit or Flash Game that you play is programmed in actionscript. The newest version AS3, which was introduced with Flash CS3 is very similar to other languages such as C# and Javascript. To start programming with AS3 or AS2 buy Adobe Flash CS3/4 or as a free alternative download FlashDevelop. FlashDevelop enables you to program in AS3 and then using the Flex 3 SDK compile it into a .swf file (flash).In this tutorial I'll focus on basics of AS3 and its functions. First, create a new file (.as). You'll get something like this:package{ import flash.display.sprite; public class Main extends flash.display.Sprite { public function Main():void { } }}Package means the project or package of classes (.as). Import is used to import classes either that you have made or from Flash itself (flash.display). Each .as file must be a class, this is the main class which extends (or is) a Sprite. In other words this is basically the stage. The main function is what is called or played first (like the first frame), make sure the main.as file is set to "compile first." Importing ClassesTo import classes use "import" outside the class but inside the package.package{ import flash.events.*; //Many classes import flash.display.sprite; //One class import ball; //custom class//and so onflash.[classes] are classes that are a part of flash but you need to import them before you use them. You can import just one class by specifying the specific class or you can import many with  "*" at the end of the folder. You import your own custom classes by specifying the file. (ball is a class in the same folder as main)FunctionsClasses always include functions. Functions that are either for a certain purpose (such as custom functions) or functions that caused because of events. They can either return a value or just do something. Here is an example:public function main():void{//actionstrace(sum(5,5));}public static function sum(Number n1, Number n2):Number{return n1+n2;}The first function Main() (which is the first function called by the main class),  which returns nothing or void (the return type of the function). The second function sum() returns a number, and it is also a static (always the same) function which means the function can be called with sum(). The function also accepts 2 parameter, 2 numbers and then returns the sum of the numbers.VariablesA variable in AS3 is the same as in Algebra. But you must define the type of variable in AS3.package{ import flash.display.*; public class Main extends flash.display.Sprite { public var sum:Number = 0; public var title:String = "Blah"; public var circle:Sprite = new Sprite(); public function Main():void{ var helloworld:Boolean = true; } }}Notice that the variables are declared after the class declaration, this way the variables can be accessed anywhere within the class. If they where only in a function, they might still be accessed but not as easily (see Access). Before a variable goes the access-control modifier which tells where the variable can be accessed from (see Access). Then comes "var" for variable, and after that the name of the variable. A colon and then the type name is used to define a specific data type for the variable. Then comes the = sign followed by the value of the variable. For the circle var and Sprite is a display object and also a class. So to create a new instance of a sprite call "new Sprite()" (when I will talk about class structure/custom classes this will further explained).Access (-control modifiers)Access-control modifiers go before a class, function or variable. This is to indicate where the object can be accessed from.9/24/2008AS30
All SM Tutorials (9)

Ad

© Sawfish Media 2008 | Created by Sawfish Design
Unless otherwise noted, content is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.
 
 
Or login with Facebook Connect
Cancel