Wednesday, May 4, 2011

Tugasan 1 - Membina Perisian Flash

Dalam Assignment 1, saya dan ahli kumpulan ASAP diminta membina satu perisian yang menggabungkan pelbagai Scene. Sebelum itu, terlebih dahulu saya mencadangkan agar dibuat Storyboard dan Carta Alir sebagaimana yang pernah dipelajari semasa di peringkat Sarjana Muda dahulu, bagi memudahkan proses authoring menggunakan Flash. Berikut adalah antara paparan-paparan skrin perisian Animal World yang telah saya reka. Kekangan masa yang ada memang terhad, namun kami telah cuba sedaya-upaya untuk menyiapkan tugasan ini.

Ini adalah montaj perisian Animal World. Rekaan teks dibuat oleh saya sendiri, manakala imej latar belakang adalah dicari menerusi internet. Montaj ini turut memuatkan bunyi audio yang telah diimport ke Library sebelum ini.


Ini pula adalah paparan skrin Menu Utama perisian kami. Saya menggabungkan pelbagai gambar haiwan yang diambil dari internet. Kemudian saya memasukkan kod untuk setiap butang.

Ini adalah paparan di ruangan Nota. Pada skrin ini saya telah mencadangkan agar dibuat Button Frame, atau bingkai untuk menyeragamkan susunan Butang Perisian bagi memudahkan proses salin semula butang perisian, dan juga menjadikan paparan yang dihasilkan lebih kemas.


Ini pula paparan untuk Scene Kuiz dibuat oleh Afidah berdasarkan apa yang telah dipelajari menerusi aktiviti di Makmal Komputer.

Ini adalah paparan untuk permainan oleh Khairunnisa. Kebanyakan bahan yang dibuat untuk setiap Scene adalah didasarkan daripada latihan-latihan aktiviti di Makmal Komputer.

Seterusnya saya memasukkan video di bahagian Kredit sebagai penutup tugasan kami. Video ini bertemakan kesedaran terhadap menjaga kebajikan haiwan-haiwan di dunia, di mana haiwan-haiwan ini semakin diancam kepupusan akibat kerakusan manusia mencari keuntungan dunia.

Tuesday, May 3, 2011

Cara untuk Embed Flash ke dalam Blogger

Pertama, kita harus mengupload fail .swf atau fail flash yang kita mahu gunakan ke satu akaun internet yang boleh diakses secara terbuka.

Kemudian gunakan kod di bawah ini untuk disalin ke New Post > Edit Html


Sunday, May 1, 2011

What is Apache Web Server?

Often referred to as simply Apache, a public-domain open source Web server developed by a loosely-knit group of programmers. The first version of Apache, based on the NCSA httpd Web server, was developed in 1995.

Core development of the Apache Web server is performed by a group of about 20 volunteer programmers, called the Apache Group. However, because the source code is freely available, anyone can adapt the server for specific needs, and there is a large public library of Apache add-ons. In many respects, development of Apache is similar to development of the Linux operating system.

The original version of Apache was written for UNIX, but there are now versions that run under OS/2, Windows and other platforms.

The name is a tribute to the Native American Apache Indian tribe, a tribe well known for its endurance and skill in warfare. A common misunderstanding is that it was called Apache because it was developed from existing NCSA code plus various patches, hence the name a patchy server, or Apache server.

What Is XAMPP and how to Install it?

XAMPP is a protocol which allows messages to be sent in XML, the messages are constrained to type, it can be anything, IM messages, or an application talking to another application over the internet. Jabber has the most popular implementation and it is the same protocol used by Gtalk. There might be PHP library that allows you to use XAMPP for communcation.

XAMPP is a free and open source cross-platform web server package, consisting mainly of the Apache HTTP Server, MySQL database, and interpreters for scripts written in the PHP and Perl programming languages.

It is used as a development tool, to allow website designers and programmers to test their work on their own computers without any access to the Internet.

XAMPP is developed by Apache Friends to promote the Apache web server. Apache Friends was founded in the spring of 2002 by Kai ‘Oswald’ Seidler and Kay Vogelgesang. It’s Alexa rank is 7,939 as on today. Because, I use any software or website based on it’s alexa rank, I am mentioning it’s rank here to help my blog readers. XAMPP Acronym is X(Apache, MySQL, PHP, PERL)

Apache Friends developed this software to help the people to install and configure Apache web server along with MySQL, PHP and Perl.


* The file name of the software after downloading from specified location is xampp-win32-1.7.3.exe
* Right click on the file and click Run as administrator and click Run in the Open File – Security warning
* Click Install in “XAMPP for Windows” screen
* Type “y” for the question “Should I add shortcuts to the start menu/desktop? (y/n):” and hit enter
* Type “y” for the question “Should I Proceed? (y/x=exit setup):”
* Type “y” for the question “Should I make a portable XAMPP without drive letters? Your choice:”
* Press Enter – Enter and Type x and Enter in the next 3 steps
* You have successfully installed XAMPP in your computer now

Now we will see how to test web server with PHP, MySQL. The following steps for testing Apache web server, PHP and MySQL

* Open web browser and type http://local host in address bar and hit enter
* If you get “Internet Explorer cannot display the webpage” message, we have forgotten to start the web server
* To start web server Click start – click all programs – click XAMPP for Windows – Click XAMPP Control Panel
* Click start button which opposite to Apache label
* Now try to browse using above url http://localhost
* Now you should get the welcome page of XAMPP for Windows
* If you can be able to see the XAMPP home page means you can understand that Apache web server is working fine
* Now click on the link phpinfo() from left navigation of XAMPP to get the information about PHP
* If you get the information about PHP version and other details in the right pane you can understand that PHP is installed and configured on your computer
* You also can check whether Perl installed and configured or not by clicking on the link perlinfo() in the left page. Detailed information should be displayed in the right pane
* You have to start MySQL from XAMPP control panel to test the phpMyAdmin. phpMyAdmin is a tool to manage MySql databases


Saturday, April 16, 2011

CREATE A CONTACT FORM IN DREAMWEAVER CS3 USING ASP

CREATE A CONTACT FORM IN DREAMWEAVER CS3 USING ASP
  • Create a new site in Dreamweaver CS 3. Save the new site in c:\inetpub\wwwroot\project.
  • Create a database in Access and save the database in the folder c:\inetpub\wwwroot\data. The database must save in MS Access 2002-2003 with .mdb file extension
  • create a table in database and create the following fields:
  1. name1
  2. username
  3. password
  4. remarks
  • 4. For remarks field, choose Memo as its data type.
  • 5. Then create connection in Dreamweaver CS3. Open the database panel, click at + button, select Custom Connection String. Enter a name for the connection as dmx. Enter the connection string as
"Driver={Microsoft Access Driver (*.mdb)};DBQ="& Server.MapPath("/data/guest.mdb").
  • Click the button Test to connect to the database and then click OK.

  • Create a new ASP VBScript page. Insert a form. Insert a table and insert the text and text field.
  • Give the name to the text field in Properties panel.
  • Save the page as daftar.asp in c:\inetpub\wwwroot\project
  • Then set the Insert Record to write data into database. Click Active Server Behaviors tab. Click the + button then select Insert Record, select the connection that you gad created then click ok. Save the file.
  • Create a new ASP VBScript page. Save the file as view.asp.
  • Create the text and text field for name, username, password and remarks.
  • Click Server Behaviors tab. Click the + button, select RecordSet. Select the connection that you had created. Select sort: name1 and Ascending to sort the data for viewing. Click Test.
  • Activate Bindings tab. Click + button select RecordSet. Click at + button sign in front of the RecordSet and you can see all the fields in the database.
  • Drag nama into cell 1 in column 2 in the table that you create in view.asp. drag other fields also into the following cell in column 2. Draw a line below the table. Next highlight the table including the line below the table. Click the + button on the panel, select Repeat Region. Click OK.
  • Open back your daftar.asp file. Double click Insert Record behavior in Server Behavior and add view.asp in After inserting go to: Click OK.
  • Click at Preview in Browser icon. Type any data and click save button. Automatically the view.asp file will be displayed and you can see the data that you typed.

Solve IIS Installation Problem For Windows User

QUESTION:
I am a windows users and I always have face the same problem when installing IIS on my computer. What I need to do?

ANSWER:
Here are the solution for problems in Microsoft Windows.
  1. Open Windows Explorer > click tools > folder options > activate view tab.
  2. Then deactivate Use simple file sharing (recommended) options.
  3. Click OK.
  4. Open your inetpub folder at c:\Inetpub\wwwroot\folder using windows explorer.
  5. Right click at the folder that holds the access database file and click at properties.
  6. Click at security tab and click add button > then click advanced button.
  7. Click at find now button and choose everyone.Click ok.
  8. Then activate write options for everyone user.
  9. Click OK.

Friday, April 8, 2011

WEEK 12 - PHP

Buka xampp untuk Start MySQL

pilih SCM (window Services akan terbuka) dan stop kan IIS

C:\xampp\htdocs\learning
C:\xampp\mysql\data\data

Cuba tengok di bahagian Application dalam Dreamweaver
dah ada dmx

Cuba http://localhost/ di Firefox untuk ke xampp

Friday, April 1, 2011

PHP GUESTBOOK TUTORIAL

First off we need phpMyAdmin and to create admin table and insert some admins inside it, here is code you need for phpMyAdmin, use same database as your guestbook is in.

CREATE TABLE admins (
username varchar(50),
password varchar(50),
id int(11) NOT NULL auto_increment,
PRIMARY KEY (id)
) TYPE=MyISAM;

Now over phpMyAdmin you need to add admins, go to admins table and click insert, write in username and password, from scroll down box on left from password select MD5 so it protects it with md5 hash, when you have done that it’s start to do admin part of guestbook, make folder admin where your guestbook is and inside it make first file named form.php, put this code inside.














Username:
Password:


When you have made form we need login.php file that will check for login details and if successful it will log you in.

// Check if login button has been pressed
if(isset($_POST['login'])){
// Define username and password
$username = $_POST['username'];
$password = $_POST['password'];
// Do some stripslashes on them
$username = stripslashes($username);
$password = stripslashes($password);
$password = md5($password);
// Include our config file for mysql server connect and select database
include "../config.php";
// Query admins table and check if admin data is good
$query = "SELECT username, password FROM admins WHERE username = '$username' AND password = '$password' LIMIT 1";
$result = mysql_query($query);
$count = mysql_num_rows($result);
// If result is good start session and register it with s_logged_n
if($count == 1){
session_start();
$_SESSION['s_logged_n'] = 'true';
$_SESSION['s_username'] = $username;
// Display successful login message
echo "You have sucessfully logged in, click here to access admin area";
} else {
// If user or pass is wrong display it
echo "Invalid username or password";
}
} else {
// If someone try to open login.php only tells them to use form
echo "You must login over form, click here to go back to login";
}
?>

Now when we have login.php we need index.php where our post from guestbook and options to edit or delete them will be, so make file index.php and put this code inside

// Start sessions and check if sessions is registered from login form, if it is true display admin data, else display that you must login
session_start();
if(
$_SESSION['s_logged_n'] == 'true'){
?>
Welcome to admin area echo $_SESSION['s_username']; ?>, here you can administrate guestbook.




= "10";
// Include config file
include "../config.php";
// if we don't get page number get page number 1
if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}
// Max results per page
$max_results = "$max";
$from = (($page * $max_results) - $max_results);
// Do query on database table
$query = "SELECT * FROM guestbook ORDER BY id DESC LIMIT $from, $max_results";
$result = mysql_query($query);
// If query is ok then output messages from guestbook
if ($result) {
while (
$row = mysql_fetch_array($result)):
?>










endwhile ?>


Posted by echo $row['name']; ?> if($row['website'] == ''){
echo
"";
} else {
echo
". $row['website'] . "\">www";
}
?>
on echo $row['date']; ?> - echo $row['id']; ?>">click to edit - echo $row['id']; ?>">click to delete
echo $row['message']; ?>

Go to page #:= mysql_result(mysql_query("SELECT COUNT(*) as Num FROM guestbook"),0);
$total_pages = ceil($total_results / $max_results);
for(
$i = 1; $i <= $total_pages; $i++){
if((
$page) == $i){
echo
"$i ";
} else {
echo
".$_SERVER['PHP_SELF']."?page=$i\" title=\"Go to page $i\">$i ";
}
}
?>

// If query fails then output it
} else {
echo
"Unable to select data from database table";
}
?>
} else {
echo
"You must login to access admin area";
}
?>

When index.php is done we need file edit.php and this code that goes in

// Start sessions and check if sessions is registered from login form, if it is true display admin data, else display that you must login
session_start();
if(
$_SESSION['s_logged_n'] == 'true'){
?>
// Get the id of the post
if(isset($_GET['id'])){
$id = $_GET['id'];
include
"../config.php";
$query = "SELECT * FROM guestbook WHERE id = '$id' LIMIT 1";
$result = mysql_query($query);
if (!
$result){
echo
"Please select what post to edit over index page";
} else {
while (
$row = mysql_fetch_array($result)):
?>

echo "$id"; ?>" method="post">





















Name:
echo $row['name']; ?>">
Email:
echo $row['email']; ?>">
Website:
echo $row['website']; ?>">
Message:



endwhile ?>
}
}
} else {
echo
"Please login over
form."
;
}
?>

And now our delete.php file that has this code

// Start sessions and check if sessions is registered from login form, if it is true display admin data, else display that you must login
session_start();
if(
$_SESSION['s_logged_n'] == 'true'){
?>
// Get the id of the post
if(isset($_GET['id'])){
$id = $_GET['id'];
include
"../config.php";
$query = "DELETE FROM guestbook WHERE id = '$id' LIMIT 1";
$result = mysql_query($query);
if (
$result){
echo
"Successfully deleted post";
} else {
echo
"There was an error deleting post";
}
}
} else {
echo
"Please login over form.";
}
?>

And now finally our update.php file that have contents of updating posts inside, code goes like this

// Start sessions and check if sessions is registered from login form, if it is true display admin data, else display that you must login
session_start();
if(
$_SESSION['s_logged_n'] == 'true'){
?>
// If form button has been pressed then do the following
if(isset($_POST['update'])){
// Get id of post
$id = $_GET['id'];
// Include config file
include "../config.php";
$name = $_POST['name'];
$email = $_POST['email'];
$website = $_POST['website'];
$message = $_POST['message'];
// Make some preg replaces
$name = preg_replace("/>/",">",$name);
$name = preg_replace("/,"<",$name);
$email = preg_replace("/>/",">",$email);
$email = preg_replace("/,"<",$email);
$website = preg_replace("/>/",">",$website);
$website = preg_replace("/,"<",$website);
$message = preg_replace("/>/",">",$message);
$message = preg_replace("/,"<",$message);
// Add few stripslashes...
$name = stripslashes($name);
$email = stripslashes($email);
$website = stripslashes($website);
$message = stripslashes($message);
// Check if fields name, email and message are empty
if ((( empty($name) ) || ( empty($email) ) || ( empty($message) ))){
// If they are empty then output message
echo "Please write in all fields, name, email and message";
// Else if they are filled in check if email is valid
} elseif ((!strstr($email , "@")) || (!strstr($email , "."))) {
// If email is invalid then output it
echo "Please use valid email address";
} else {
// If all fields and email is valid then update data to database
// Do the query
$query = "UPDATE guestbook SET name = '$name', email = '$email', website = '$website', message = '$message' WHERE id = '$id' LIMIT 1";
$result = mysql_query($query);
if (
$result){
echo
"Successfully edited post";
} else {
echo
"There was error editing post";
}
}
}
} else {
echo
"Please login over form.";
}
?>

And that would be it, all this files must be inside guestbook/admin folder

Friday, March 4, 2011

ASP versus PHP 4 MAC 2011

ASP = Actives Server Pages, PHP Hypertext Preprocessor

ASP and PHP are both programming languages that are commonly used to create websites. Unlike the usual static html web pages, ASP and PHP websites are more dynamic and can allow users to interact and exchange information using the website's databases.

ASP is the short term for Active Server Pages, a type of program that works with Microsoft alongside IIS or Internet Information Server. ASP needs a Microsoft Server for the website to work. On the other, PHP or Hypertext Preprocessor, runs using Linux or Unix server. The more updated PHP programs can now run on an NT server.

Platfrom
PHP programs can also run in Windows, Solaris, Unix and Linux while ASP can only work with Window-based platforms. Just recently, ASP can now run on a Linux platform given that there is an ASP-Apache program installed on its server.

Language Programme
If you were a programmer adept with the C++ language, you would probably be more comfortable using PHP than ASP. PHP uses C/C++ as base language and most syntax are similar to each other. Because a big chunk of programmers are still using C++ language, PHP are by far more popular than ASP.


ASP is very much similar to the syntax and interface of Visual Basic programming. This is basically because Visual Basic is basically correlated with Microsoft products and programs. So if you were a programmer, choosing between ASP and PHP would basically depend on which language you are more adept with.

Server Installation Cost
When it comes to costing and expenses, ASP programs needs to run on Windows with IIS installed on the server. You need to purchase both of these components in order for ASP to work. On the other hand, a PHP would only require running on a Linux server, which you can get at no cost.

Database
PHP is very much flexible when it terms of database connectivity. It can connect to several databases of which the most commonly used is the MySQL. Note that MySQL would not cost you a thing to use. But if you were to use ASP, you need to purchase MS-SQL, which is a Microsoft product.

Speed and Secure
Loading speed is a big factor in maintaining a website. If you are particular about speed, then you need to go with PHP. PHP codes runs much quicker than ASP basically because it runs in its very own memory space while ASP uses an overhead server and is uses a COM based architecture.

Cost
In working with PHP, most tools associated with the program are mostly open source software so you need not pay for them. As for ASP, you might need to buy additional tools to work with its programs.


In conclusion, both PHP and ASP have its own advantages and disadvantages. It basically depends on which part of developing a website you are most concerned with. Are you worried about the cost of creating your website? Do you want to use a programming language that you are more familiar with? Do you want a more stable and faster website? Choosing between ASP and PHP basically depends on your own personal preference. It doesn't hurt to confer with other programmers or webmasters and research more information on which programming would best fit the requirements of your website.
ASP versus PHP

Tuesday, March 1, 2011

Drag And Drop Flash CS3

This Flash CS3 Tutorial is about controlling graphics with the mouse, creating the tweens will not be covered. However, you will learn how to make the smiley face react to the mouse. Lets make the MovieClip do something every time the mouse moves over it. Start by coping the code from the example to the first key frame in the actions layer.

smiley_mc.addEventListener(MouseEvent.MOUSE_OVER , smiley);
function smiley(event:MouseEvent):void{

smiley_mc.play()
};

The code creates an Event Listener and adds that Event Listener to the MovieClip smiley_mc. Event listeners have been covered in more depth other Flash CS3 Tutorials. The Event Listener is simply listening for the MouseEvent Mouse over. Then once the event happens ActionScript is telling the MovieClip smiley_mc to play.

Press Control-Enter to see the Smiley Face react.

If you once again go into the Smiley MovieClip and look at the key Frames you will see how this works. When the Event Listeners detects that the mouse has passed over or onto the smiley_mc, actionScript tells the smiley_mc to play, thus playing the movie until something tells the smiley_mc movie to stop. In this case there are key frames in the actions layer that simply have the stop action added to them. You can create any form of animation inside a movie clip then use action script to control when the movie plays.

Drag and Drop
Lets add some more interactivity to the smiley face by adding a drag and drop ability.

Copy the example code and add it below the current event listener.
smiley_mc.addEventListener(MouseEvent.MOUSE_DOWN , smileyDrag);
function smileyDrag(event:MouseEvent):void{

smiley_mc.startDrag();
};

Once again you will see the slandered event listener. What is new would be the smiley_mc.startDrag();. The startDrag method tells Flash CS3 to enable a MovieClip to be moved around the stage. You define which MovieClip by placing the name of the MovieClip in front of the startDrag method, separated with a period. If you test the movie at this point you will see that when you click on the smiley face it movies with the mouse cursor., but how do you stop dragging the smiley around. Well, you need to add another Event Listener.
smiley_mc.addEventListener(MouseEvent.MOUSE_UP , smileyStopDrag);
function smileyStopDrag(event:MouseEvent):void{

smiley_mc.stopDrag();
};

The first Event Listener listened for the mouse to be pressed down. This time you need Flash CS3 to listen for the mouse up event. Since you want the smiley_mc to stop dragging when the mouse button is released you will add the method stopDrag to the MovieClip. Basically, you use the same thing to stop dragging as you do to start dragging.

RESOURCE: http://www.squidoo.com/flash_cs3_tutorial_DragAndDrop

Monday, February 28, 2011

Motion Guide - Flash CS3

Making a simple motion tween animation that will follow the motion guide later

1.1 Open a new document by selecting File > New. Select Flash File (ActionScript 3.0), click OK.

1.2 Save your document right away. Later, you’ll be able to save it just by pressing Ctrl+S. Remember to do this whenever you pass a certain number of steps or make significant changes to your document. It is better to save often then to lose your work because of your computer crashing, power shortages, etc.

OK. You’ll start by making a movieclip. You need it to make a motion tween animation which will be made to follow a motion guide later. A paper airplane will be fine for this kind of animation.

1.3 Select the Line tool (N). Select a darker grey hue for the Stroke color (I picked #646464), turn on the Snap to Objects option and make sure that Object Drawing is turned off. The screenshot below shows you these three options clearly.

Options for the Line tool.

1.4 Click and start dragging with the Line tool downwards. Make a line that is approximately 60-65 pixels long.

Drawing a straight line.

Since you have turned on the Snap to Objects option, drawing a straight line should pose no problem at all.

1.5 Select the Zoom tool (Z) and zoom in on the line that you just drew. Click and drag to zoom in on the desired area.

Using the zoom tool to work more easily.

You’ll be able to work more easily now.

1.6 Use the Line tool (N) again. The Snap to Objects option should be turned on from before (that’s the small magnet icon found at the bottom of the Tools panel). Bring the cursor near the top of the line, click and start dragging left and down. You will automatically start drawing from the top end of the existing line, thanks to the Snap to Objects option.

Drawing lines with the Line tool in Flash CS3

1.7 Add three more lines to complete one side of your paper airplane, as shown on the image below.

Adding further lines.

1.8 Select the whole drawing using the Selection tool (V).

Selecting the drawing with the Selection tool.

1.9 Copy the selected items by pressing Ctrl+C or selecting Edit > Copy.

1.10 You will now paste in place a copy of these lines either by pressing Ctrl+Shift+V or selecting Edit > Paste in Place. Now, there won’t be any apparent change. But you have just pasted a smae, exact copy of your drawing over the original one. To see it, use the left or right arrow keys on your keyboard to move the new copy.

Moving the new copy of your vector drawing.

If you had clicked anywhere on the stage after pasting the drawing in place, you will lose it. That’s because the copy will merge with the original automatically. That’s what happens with vectors (pure drawings, not symbols) in Flash. So, if you want to make use of your new copy, just move it before clicking anything else.

1.11 With the freshly pasted copy still selected, select Modify > Transform > Flip Horizontal.

Using the Flip Horizontal action to create a mirror image.

1.12 Move the mirrored half so that it joins the original drawing perfectly. You can do that with the arrow keys, but I recommend doing it with the Selection tool (V), because thanks to it, the drawing will perfectly snap into place, as shown in the picture below.

Putting two vector objects together with the selection tool.

1.13 If you wish to make your paper airplane more realistic, you can apply some linear gradient color fills to it. Use the Paint Bucket tool (K) to do it.

Applying some linear gradients to the vevtor drawing.

1.14 Turn back the zoom to 100% (no zoom at all).

Zooming the stage to 100%

1.15 Select your completed drawing, both the lines and fills, using the Selection tool (V). To create a movieclip out of your selected vector drawing, select Modify > Convert to Symbol.

Call your new symbol paper airplane, select Movie clip as type and also select the central square for the registration point This last choice isn’t exactly a must, but it will make creating the guided animation a little bit easier. Click OK.

Creating a new movieclip symbol in Flash CS3.

…as soon as you do that, an azure outline will appear around your newly made symbol and the Properties inspector will also show you that you are dealing with a movieclip symbol now and not a simple drawing anymore.

The new movieclip shown.

You will create a simple motion tween animation now.

1.16 Right-click on frame 50 and select Insert Keyframe.

A new keyframe is being inserted into the layer.

1.17 Use the Selection tool (V) to move the movieclip. Just click and drag it to a new position. You can place it anywhere, because what’s important is that you make a motion tween animation, the direction of the movement isn’t important now.

Moving the newly made movieclip.

1.18 Right-click between the two keyframes and select the Create Motion Tween animation.

Creating a motion tween animation.

If you have done everything properly, an unbroken arrow over a purple background should appear.

A correctly done motion tween animation.

If you didn’t obtain a good motion tween (your arrow is dashed-broken), please check my motion tween animation tutorial which explaines in detail how to make such an animation, and where possible errors may lurk.

1.19 Call the current layer airplane and lock it.

The first layer has been renamed and locked.

Fine. Now you have the prerequisite for creating a guided animation — a simple motion tween. Let me show you how to add a guide to it.

Top of page
2. Creating a motion guide

2.1 Click the Add Motion Guide icon beneath the layers to add a new motion guide.

Adding a motion guide layer.

As you can immediately see, a new motion guide layer has been added to your document. The layer benath it (airplane) has instantly become linked to this layer, become the guided layer. The airplane layer is now guided by the Guide: airplane layer. This can clearly be seen by the layer’s icon which has become slightly indented — it has moved to the right.

The motion guide and the layer guided by it.

Also, the duration of the guide layer is the same as that of the guided layer (50 frames in this particular example).

2.2 Select the Pencil tool (Y). In the Tools panel, go to the end of it and choose the Smooth option for drawing with your pencil.

Smooth option for the pencil tool.

In the Properties inspector, select hairline as line type and enter 100 as the value for the Smoothing option. Choose any color you like, since the guide won’t be visible. I chose hairline to be able to work more easily and adjust the animation in more detail.

The options for the Pencil tool.

2.3 Click and start dragging with the Pencil tool (Y) to draw a guide (in the Guide: airplane layer, of course). Make a curve — it will come in handy for simulating the flight of your paper airplane. I started and finished drawing the curve outside the stage on purpose — to make it appear as if the airplane flew inside the scene and then disappeared outside of it.

A curve will serve as the guide for the animation.

Top of page
3. Creating a guided motion tween animation

3.1 Now lock the Guide: airplane layer and unlock the airplane layer. Click on the first keyframe of the airplane layer to select it.

Locking and unlocking the layers.

3.2 Click on the paper airplane movieclip once to select it – do this with the Selection tool (V).

3.3 You will move the movieclip to the guide’s starting point. Use the Selection tool (V) again. Click on the movieclip’s registration point (that’s the small circle with a little cross inside) and drag it over to the beginning of the guide. Once the movieclip is ready to snap into place, you will see a bold, black circle appear near your cursor, as shown below.

The movieclip has just snapped onto the guide.

If the snapping does not occur, check if it is turned on.

The Snap to Objects option selected in the Tools panel.

3.4 Click on the second keyframe in the airplane layer to select it.

Selecting a keyframe in the guided layer.

3.5 Now do the same thing for the movieclip in this keyframe: Place it over the other end of the guide using the Selection tool (V). It should also snap into place, just like before.

Placing the movieclip on the guide.

3.6 Speed up the animation a little bit (before testing it), by increasing the frame rate of your Flash movie. Double-click the frame rate (below the layers) to open the Document Properties window.

Accessing the frame rate option in Flash CS3.

Set the Frame rate to 24 fps and click OK.

Modifying the speed of the SWF movie.

3.7 Select Control > Test Movie. You should see an animation similar to the one shown below.

Wow! The movieclip is moving along the guide! You did it. But, there is one obvious flaw here: the paper airplane isn’t moving around as in the real world. It should be moving with its nose pointing forward. So let me show you now how you can easily do that (you must, because animation is about simulating the real-world)!

3.8 Select the first keyframe again.

Selecting the keyframe for motion adjustment.

3.9 Select the Free Transform tool (Q). Also, turn off the Snap to Objects option to be able to adjust your movieclip’s position freely, without any snapping.

Selecting the Free transform tool.

3.10 Bring the cursor near one of the movieclip’s corners (if the movieclip isn’t selected, select it now). Click and start rotating until the paper airplane’s nose is aligned with the direction of your motion guide (the curve in the layer above it).

Rotating a movieclip with the Free Transform tool.

3.11 Select the second keyframe of your animation again.

Selecting the keyframe on the animation's ending.

3.12 Adjust the movieclip with the Free Transform tool here too. The important thing is that the movieclip should be oriented as if it was following the guide all along — aligned with its direction.

Rotating the movieclip in relation to the motion guide in the layer above it.

3.13 There is one last thing to be done to have a proper guided motion tween: Select the first keyframe again (like you did in step 3.8) and go to the Properties inspector. Once there, turn on the option called Orient to path. Make sure that it is selected, as seen below.

Selecting the Orient to path option for the guided animation.

3.14 Test your SWF again by selecting Control > Test Movie and you should see your airplane moving realistically, as shown at the beginning of this lesson.

Now that was easy, wasn’t it? Guided animations are fun, because they help simulate real-world movements of various objects.

Saturday, February 19, 2011

Timeline Motion Tweening - Flash CS3

Flash can create two types of tweened animation using timeline: Motion Tween and Shape Tweening.

Creation of Motion/Shape tween using timeline is the basics of Flash.

Motion tween is nothing but tweening a Symbol's movement from one position to another.
To implement Motion Tween all that you have to do is, provide Flash with Symbol's initial position and the end position. Rest is taken care by Flash. Isn't it really simple.


For example in the above demonstration, I have converted the pencil object to a Symbol. Provided Flash with its initial and the end position, intermediate tweening is done by Flash. Motion Tween animation is as simple as that :)
Okay, you ready to learn how to create motion tween. All you have to do is just follow this tutorial step by step.

Please note:
1. You need to have Flash Player 7.0 installed to view the Flash animation.
2. Flash MX 2004 must be installed in your system to download the .fla file.

Steps to follow:

* Open a new flash file (Ctrl+N).
New Document window will appear
Select General panel and choose Type: Flash Document . Press OK.
* If your timeline window is not open, press (Ctrl+Alt+T).
* Now you can see a single Layer called "Layer1" in your timeline Window.
* Select the first frame. Import your image onto stage, upon which you would want to implement motion tween.
File>Import>Import to Stage, or just press (Ctrl+R).
Or you can even draw your own object, you can either choose Rectangular tool or Oval tool from the tool box and draw your desired shape.
* Now select your object on the stage and press F8 to convert this image to a Symbol. Convert to Symbol window will pop-up.
Name your Symbol what ever you like.
Select Graphic behavior and press OK.

Note: You can create motion tween only on symbols. So any object upon which you would want to implement motion tween, First convert the object to a Symbol.

* Right now your Symbol is in frame1 of Layer1. Select frame 20 and press F6 to insert a new keyframe.
* Still keeping playhead on frame 20, move your Symbol to any other position other than the present one.
* Select any frame between, 2 to 19 and select Motion from the tween pop-up menu in the Property inspector. Now your Layer will look something like the one shown below.
* Now press (Ctrl+Enter) to view your motion tween.

Friday, January 28, 2011

Drag and Drop Flash CS3 - VERSION 2

Step 1 - Draw an object

* Anything you like

Step 2 - Transform it into a Movie Clip

* Select the object (or if you created several objects for a drawing select them all)
* Right-click on the object and create a movie symbol
* Give the instance a name in the properties panel !

Step 3 - Adapt code below

Dragging code is really simple and follows the same principles we encountered for example in the Flash button tutorial.

* Associate an event listener with an event handler function. This time we listen to "mouse down" and "mouse up" events and for each we need to write a function that will do the dragging.

// Register mouse event functions
blue_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
blue_btn.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);

red_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
red_btn.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);

// Define a mouse down handler (user is dragging)
function mouseDownHandler(evt:MouseEvent):void {
var object = evt.target;
// we should limit dragging to the area inside the canvas
object.startDrag();
}

function mouseUpHandler(evt:MouseEvent):void {
var obj = evt.target;
obj.stopDrag();
}

Results

* Admire the result (flash-cs3-drag-and-drop-intro.html)
* Get the source from http://tecfa.unige.ch/guides/flash/ex/drag-and-drop-intro/ (files flash-cs3-drag-and-drop-intro.*)

Drag and drop over another object

The goals is to write a little Flash application that will tell the user whether he correctly dragged and dropped an object over another one.

Step 1 - Start from the file above

* I.e. we want to have the user drag the red circle over the blue rectangle.

Step 2 - Add a text box

This textbox should initially display instruction, then display feedback: "made it" and "missed".

* Use the Textool in the tools panel to enter the text.
* Then in the properties panel, change the type to Dynamic Text.

Dynamic Text

Step 3 - Action script code

// Register mouse event functions
blue_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
blue_btn.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);

red_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
red_btn.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);

// Define a mouse down handler (user is dragging)
function mouseDownHandler(evt:MouseEvent):void {
var object = evt.target;
// we should limit dragging to the area inside the canvas
object.startDrag();
}

function mouseUpHandler(evt:MouseEvent):void {
var obj = evt.target;
// obj.dropTarget will give us the reference to the shape of
// the object over which we dropped the circle.
var target = obj.dropTarget;
// If the object exists AND it is the blue button, then we change
// the text in the TextBox.
// Since obj.dropTarget is a Shape, we need its parent.
if (target != null && target.parent == blue_btn)
{
textField.text = "Made it !!";
}
else
{
textField.text = "Missed :(";
}
obj.stopDrag();
}

Results

* Admire the result
* Get the source from http://tecfa.unige.ch/guides/flash/ex/drag-and-drop-intro/ (files flash-cs3-drag-and-drop-intro2.*)

Improvements to be made

* Styling of the textbox: You can do this with the filters panel. Click on the + sign to add filters and then play around with the options.
* Move the red circle back to its initial position
* Special effects maybe

Drag and match learning application - dumb version

The goal is to move objects to a textbox containing the first letter of its name. E.g. "Cat" should be moved to the "C" box. If there is a hit, the user will get some success message and can't move the object anymore. If he is done, he should get an extra message.

Step 1 - Create movie clips for object to be moved

* As above with the red and blue circle
* Each object should have an instance name

Step 2 - Create textboxes

* Also as above
* Create one for each object (E.g. a "C" for the cat, etc.)
* Make sure they are dynamic and they have a name.

Step 3 - Foreground/Background

Make sure that the textboxes are in the background or the movie clips in the foreground. Otherwise a dropped object will not find its target.

* Select all the movie clips, then right-click->Arrange->Bring to Front.

Step 3 - Write Action Script code

Code below is fairly awful since it lacks abstraction, but it has the advantage to use a minimal variety of AS3.

var hits = 0;

// Register mouse event functions

dog.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
dog.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
rocket.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
rocket.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
cat.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
cat.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
bat.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
bat.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);

// Define a mouse down handler (user is dragging)
function mouseDownHandler(evt:MouseEvent):void {
var object = evt.target;
// we should limit dragging to the area inside the canvas
object.startDrag();
}

function mouseUpHandler(evt:MouseEvent):void {
var obj = evt.target;
// obj.dropTarget will give us the reference to the shape of
// the object over which we dropped the circle.
var target = obj.dropTarget;
// If the target object exists the we ask the test_match function
// to compare moved obj and target where it was dropped.
if (target != null)
{
test_match(target, obj);
}
obj.stopDrag();
}

function test_match(target,obj) {
// test if either one of the four pairs match
if ( (target == box_c && obj == cat) ||
(target == box_d && obj == dog) ||
(target == box_r && obj == rocket) ||
(target == box_b && obj == bat) )
{
// we got a hit
hits = hits+1;
textField.text = "Yes ! You got one !";
// make the object transparent
obj.alpha = 0.5;
// kill its event listeners - object can't be moved anymore
obj.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
obj.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
// Test if we are done
if (hits == 4)
{
textField.text = "Made it !!";
}
}
else
{
textField.text = "Missed :(";
}
}

Thursday, January 20, 2011

Frame By Frame Animation

Langkah-langkah untuk mencipta animasi bingkai demi bingkai atau disebut sebagai frame by frame animation.

Persediaan:
Cipta atau dapatkan satu set imej pergerakan animasi. Untuk tujuan ini saya perlu mencari imej menerusi fungsi Google Search:

Web Images Maps News Translate Books Gmail more ▼

Saya klik pada Images, dan di ruang carian, saya taip: motion image

Hasilnya saya menemui satu set mej seperti di bawah:

Motion Image - Horse Rider

  1. Anda boleh lukiskan gambar latar belakang atau anda boleh memasukkan gambar apapun dengan mengklik File> Import> Import toStage.
  2. Masukkan symbol dengan mengklik Insert> New Symbol. Pilih klip video dan klik OK.
  3. Anda akan melihat Scene baru bernama 'Symbol 1'
  4. Import set gambar yang menunjukkan gerakan dengan mengklik File> Import ke Stage. (Import file pertama sahaja kerana fail-fail lain akan diimport secara automatik. Untuk tujuan ini, anda harus memastikan bahawa semua gambar adalah disimpan secara berurutan (sequence), misalnya kuda01, kuda02, kuda03 dan seterusnya. Jika tidak, imej-imej tidak akan dapat diimport secara automatik ke Library)
  5. Kembali ke Scene 1 dan seret (drag) symbol anda (dari Library) untuk Stage.
  6. Pergi ke mana-mana timeline (misal: timeline 40) dan masukkan satu lagi keyframe dengan menekan F6.
  7. Pindah symbol anda ke lokasi yang lain di Stage.
  8. Antara timeline, klik Insert> Timeline> Create Motion Tweening.
  9. Simpan fail anda (Ctrl + Save) dan uji movie (test movie) anda (Ctrl + Enter).

Komen: Saya dapati penggunakan shortcut key memudahkan kerja-kerja menghasilkan animasi. Antara kekunci atau kombinasi kekunci yang boleh digunakan dalam aktiviti kali ini ialah:

Short cut key:

F6 - Insert keyframe
Ctrl + SAve - Save file
Ctrl + Enter = Test movie

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | belt buckles