Advantages of Tableless Designs
by Sagar Awasthi on Jul.13, 2009, under Advantages of Tableless Designs
Designing a website with tables is now an old technique. Now a days it’s time to introduce tableless web design, which is very flexible as well as web development friendly. Table restricts development with many complications and disadvantages. I will try to elaborate the vital advantages of tableless for web development and web designs.
Quick loading
The most important feature of tableless desinging, helps in reducing the size of a HTML page. It is true that tables take time to load and therefore a website made with tables generally loads slowly. Slow loading means slow visual apearance, may leads to losing visitors. Reason behind is that tables come with clutter of codes which increases the loading time. As you know table is structured with number of open-close tags(i.e thead, tr, td.) that makes the entire table structure heavy. At the same time if you have used tableless, it basically reduces the code and shed up 70% of unnessasary elements.
Simple and Clear Code
If you are developing website without tables, it will clear the code with lots of stuff. It reduce unwanted tags and make it more clean which helps a developer to make changes comfortably. Developer will not have to labor hard while making any changes in the codes. Infact a clumsy apearance make it difficult for a coder to find out errors. Tableless make your code very simple and clear, without any complication one can integrate or develop some new features in the same design.
Flexibility in Presentation
With the help of CSS one can change style, graphic or font very easily. You don’t need to look whole code for a small style change. By editing CSS file, you can change the complete look and feel of design. Furthermore, Developer will update the CSS file only of a website, he will not need to update all the pages.
Search Engine Optimization
Conceptually, websites with fewer codes are always search engine friendly and can be easily read by all the search engine crawler.
Use of Standard Code
Tableless layout uses professional and very standard layout for designing a web page. Use of standard tags make designing effortless and one could make changes easily without putting lot of hard work.
Printer Friendly
Usually user surf net for the content, and takes print when they find some useful content for them. But in the tablebased layout, there are many limitations as one can’t take print of the nessasary part, it comes with the whole page(i.e header, footer, Links, and other extra advertisments) but in tablesless you can customize the need and make a layout printer friendly.
Cost Effective
Yes! It is true that Tableless web desinging requires sound knowledge on div tags and CSS. However, editing CSS files of div tags is not a complex task. Therefore, a web developer will take less working hours. This is the reason why it is considered highly cost effective.
onClipEvent
by Sagar Awasthi on Jul.01, 2009, under onClipEvent
An Event handler which activates actions defined for an instance of a movie clip. Requires a movie clip instance/object.
Code:
onClipEvent( movieEvent ){
statement(s);}
Parameters
A movieEvent is a trigger called an event. On any specific event, the statement defined within the curly brackets are executed. There are many events defined in the Flash, please refer the following events:
- Load: The Action initiated when the movie clip is loaded and apears in the timeline
- Unload: Opposite of Load even , this Action initiated when the movie clip is unloaded or removed in the timeline
- enterFrame : This action is activated repeatedly with the frame rate of Movie. The actions linked with the enterFrame clip event are executed before any frame actions which is defined for the affected frames.
- mouseMove: This action is activated whenever the mouse moves. Use _xmouse and _ymouse properties to find out the mouse position in the movie
- mouseDown: The action activated whenver left click of mouse is pressed
- mouseUp: The action activated when left click of mouse is released.
- keyDown: On key press, this action activate. For retrieving key press value use Key.getCode
- keyUp: When key is relased, the action activate.
- data: The action activated when data is received from loadVariables or loadMovie action. When it is specified with loadVariables action, the data event occurs only once, after the last variable is loaded. When it is defined with a loadMovie action, the data event occurs repeatedly, as each section of data is recieved.
statement(s) The block of your code used to execute when the mouseEvent takes place.
Examples
1.
onClipEvent(load) {
#include “externalScript.as”
}
Above code will include some external Script file, when the movie is loaded. The actions defined in the “externalScript.as” runs while the movie clip it is attached, is loaded.
2.
onClipEvent(mouseMove)
{
xpos = Math.abs(this._xmouse);
ypos = Math.abs(this._ymouse);_root.data_mc._x = xpos;
_root.data_mc._y = ypos;
}
Above code executes when Mouse moves on the movie clip. _xmouse will retrieve X position of mouse and _ymouse will retrieve Y position of mouse in the the movie.
3.
onClipEvent(keyDown)
{
if(Key.getCode() == Key.RIGHT)
{
_root.data_mc.nextFrame();
}else if(Key.getCode() == Key.LEFT)
{
_root.data_mc.prevFrame();
}}
onClipEvent(mouseDown)
{
_root.data_mc._currentframe.stop();}
On keyboard’s key press, above code executes. Lik I told you in the Event’s description, Use Key.getcode() method for retrieving last key pressed value. Here in the example Key.Right will associated with right arrow keys and Key.LEFT is for left arrow key of your keyboard.
I hope you gained well in this article. Many more to come, so keep visitng.
Cheers!!!
Mouse Follow – xMouse & yMouse
by Sagar Awasthi on Jun.15, 2009, under Mouse Follow - xMouse & yMouse
In this article you will learn to make an object which will follow the mouse. Code itself will increase or decrease the speed according to the distance. Let’s not waste time and start the lesson.
1. Open a New flash document and name it.Create two layers, action and mouse_object.
on the mouse_object later draw a small circle or put any “arrow” icon. Select the icon an convert it into “movie clip” (press f8 to achieve this).Name this movie clip “icon_mc“.
2. Double click on the movie clip, and Press align(ctrl + k), align the coordinates “to the stage” then Press “Align horizontal Center” and “Align Vertical Center”. It will align your object’s x and y coordinates to the absolute center. This will position the icon in the center of the movie clip. Finally go back to the main timeline, select the ball Movie Clip and give it an instance name of icon_mc.
3. Now let’s start the main thing, add a few lines of actionscript and we will be done then. Mast Na!!!
Add this code on the main timeline on the action layer.
icon_mc.onEnterFrame = function() {
var xPos = _root._xmouse;
var yPos = _root._ymouse;
if(Math.abs(xPos – this._x) < 1) {
this._x = xPos;
this._y = yPos;
} else {
this._x -= (this._x-xPos) / 6;
this._y -= (this._y-yPos) / 6;
}
}
In the code above what we are using onEnterFrame action for icon_mc. In the function’s first line we find the coordinates of the mouse pointer in the movie. Then we check if icon is within one pixel of the mouse. If it is same then only we set the icon’s position to the mouse position otherwise we move the icon towards the mouse. On moving closer towards the mouse, we will take the distance from the icon to the mouse. For making the motion slower as it gets closer to the mouse, we are dividing the distance by 6.
I hope you understand the lesson.
lemme know in the comments if you find any doubts.
Cheers!!!
Variables in PHP
by Sagar Awasthi on Jun.11, 2009, under PHP Variables
Variables are used for storing values, like text strings, numbers or arrays. When a variable is declared, it can be used over and over again in your script. All the variable in PHP are declared with $ sign:
$var_name = value;
Below is a block of code declaring String type and Integer type variable :
<?php
$txt=”This is a String!”;
$x=2104;?>
Note: As PHP is a loosely typed language that is why a variable does not require to be declared before adding a value to it. In the example above, you have not defined the variable’s data type and PHP automatically converts the variable to the correct data type, depending on its value.
Naming Rules for Variables
- It is recommended to declare a variable name that start with a letter or an underscore “_”
- A variable name can have alpha-numeric characters and underscores (a-z, A-Z, 0-9, and _ )
- A variable name should not contain spaces.
PHP has a eight data types which we use to create our variables:
1 Integers: They are simplest and whole numbers, without a decimal point, like 4195. are whole numbers
$int_var = 12345;
$another_int = -12345 + 12345;
2. Doubles: Doubles are floating-point numbers, like 3.14159 or 49.1.
$var_dob = 2.2888800;
3. Booleans: It has only two possible values either true or false.
if (TRUE)
echo(”This will always print<br>”);
elseecho(”This will never print<br>”);
4. NULL: It is a special type that only has one value: NULL.
$my_var = NULL;
5. Strings: Most commonly used for accepting alphanumeric values, it has the sequences of characters, like ‘This is 1 good example of string type data”.
$var_string = “This is a string in double quotes”;
<?
$var_name = “name”;
$literally = ‘My $variable will not print!\\n’;
print($literally);
$literally = “My $variable will print!\\n”;
print($literally);
?>
After we create a string we can control it. A string can be used openly in a function or it can be stored in a variable. There is no artificial limitation on string length, it could be within the bounds of available memory, and you have to be able to make arbitrarily long strings.
With in the string backslashe(\) replaces certain character sequence with special characters. The escape-sequence replacements are:
- \n is replaced by the newline character
- \r is replaced by the carriage-return character
- \t is replaced by the tab character
- \$ is replaced by the dollar sign itself ($)
- \” is replaced by a single double-quote (”)
- \\ is replaced by a single backslash (\)
6. Arrays: An array is a data structure that stores one or more similar type of values in a single variable. For example if you want to store 100 student names then instead of defining 100 variables it’s easy to define a single variable that will store all 100 values.
$name[0] = “Sagar”;
$name[1] = “Divye”;
$name[2] = “Aman”;
$name[3] = “Ravinder”;
$name[4] = “Prats”;
$name[4] = “Daffy”;
7. Objects: Objects are instances of classes, which can be package up both other kinds of values and functions that are specific to the class.
8. Resources: Resources are special variables that hold references to resources external to PHP (such as database connections, widgets, plugins developed in PHP)
Basic PHP code
by Sagar Awasthi on Jun.11, 2009, under Basic PHP code
Let me tell you the structure of PHP Scripts. If you know HTML tags then you won’t find problem in dealing with PHP, script. It basically combines with the HTML elements to make some result.
To get a feel for how PHP code look like, let’s start with simple PHP scripts. First we will create a friendly little “Hello, World!” script. As told you earlier, PHP is embedded in HTML which means that you’ll have PHP statements merged with your normal HTML or XHTML. For example, In the example below I will print “Hello world” on the browser window:
<html>
<head>
<title>Hello World</title>
<body>
<?php echo “Hello, World!”;?>
</body>
</html>
It will produce following result:
Hello, World!
A PHP scripting block will always start with <?php and ends with ?>. A PHP scripting block can be placed anywhere in the document but document should be saved with “.PHP” extension.
You may enclosed PHP code inside any one of the below special markup tags , recognized by the PHP Parser.
1. <?php
——–PHP code goes here
———-
——
?>
2. <?
——–PHP code goes here
———-
——
?>3. <script language=”php”>
——–PHP code goes here
———-
——
</script>