Download the JQuery library from Jquery.com. They archive different versions and provide a compressed (or minified) version and an un-compressed version. You can download the latest compressed version from the JQuery home page and it will work with all of the examples. Move this file into the directory where you will be working.
You can obviously place the jquery js file anywhere, as long as you provide the correct path to the file in your HTML document.
JQuery is very easy to use. Follow these steps:
- Import the JQuery js file with the script tag
// your own JS here
At this point you can use JQuery in your scripts. Notice, your scripts come second.
Many times you will want to wait for your document to load before applying your own JS. This important, because executing JS before the elements it acts on are loaded will cause your scripts to fail. JQuery provides the ready() event to easily work around this.
To set up the ready event use the following:
// Scripts here execute after the page has loaded.
Here are a few examples showing the use of the CSS absolute and relative position properties.
A key feature when using position:absolute is when the parent is position:relative the absolute child element can be positioned within the coordinate space of the parent. Effectively this means you can position the child by setting it’s left and top properties. The child element will position from it’s upper left corner relative to the upper left corner of the parent.
For example setting the child to left:0 and top:0 would place the child object so that it’s upper left corner was aligned with the upper corner of the parent.
The background-size property determines how a background image fills an area. The size and method used to fill the space has several options. Here’s an example that fills the background with an image, resizing the image to fill the space.
It may take a moment to load the background image. After the background loads resize the browser window. Notice the image always fills the space.
This transparency thing is very useful, esoecially to desginers. There are two methods for setting the transparency of an element with your stylesheet.
First use the opacity property. For example imagine you have a paragraph. The following would make the paragraph transparent. This would include the entire element, text and background.
The other method is to assign an element an rgba color value. Any element that can be assigned a color value using a hex color like #FF0000, can also be assigned a color value with rgba. For example:
In this example the color of the text would red 50% transparent. The first three values, with ranges of 0 to 255, represent the amount of red, green and blue. The last value, with a range of 0 to 1, represents the amount of transparency.
Using rgba you can transparency any feature of an element.
The difference between the two is, using opacity will take the element with it’s current rendering and display it transparent at the opacity value. rgba on the other hand selts the color value of any feature of an element to include a transparency level.
Identifiers are the names that you invent to represent or identify elements in the program. Identifiers can be used to name MovieClip instances, Classes, Variables and Functions.
The program comes with many built elements that already have names. These are things like MovieClip methods like gotoAndStop() etc. You should avoid using these names as names for your own elements.
When creating Identifier names you should follow the following rules.
- Names must begin with a letter (a,b,c etc) the underscore (_) or the dollar sign ($).
- Names can contain any combination of letters, numbers and the underscore and dollar sign.
- Avoid using names have already been used by the program.
Identifiers are used fro various purposes. Following conventions while creating identifier names will help you keep them all straight.
In general identifiers should be kept lower case.
Class names: Class names always begin with an upper case letter. All of the built in classes follow this convention. For example MovieClip, Sprite and EventDispatcher all start with an uppercase letter.
Private Properties: A common convention is to start private properties with an underscore. For example: _index, _width, _height etc. The definitions for these might look like:
private var _index:uint;
private var _width:Number;
private var _height:Number;
Here’s a great idea, an open source video player. Everyone needs a video player, why not use one created by the open source community. Best of all it comes in Flash, Silverlight and HTML5 versions.
HTML is a mark up language. The idea is to use HTML tags to mark up the content of a page. When choosing a tag for an element the best approach is to choose the tag that best describes the element. Tags should add to or confirm the context of an element.
Continue reading Semantic HTML
This post describes the basics of working with wp_list_pages.
Continue reading WordPress: wp_list_pages
What are Identifiers?
When you are writing your code many of the elements are predefined. That is the words you are using have already been defined. Other elements you must create are defined by you. That is you get to make up the name assigned to these elements. Movieclip Instance names, Function names, Class names and Variable names are defined by you. That is you make up the names for yourself. All of these names are Identifiers.
When naming an Identifier you must follow a few simple rules.
- The name must begin with a non numeric character
- The name can not contain spaces or special characters. The _ (underscore) and $ (dollar sign) are exceptions to this rule
Foe example the following names work as identifiers:
The following would not work as identifiers for various reasons:
- 5_button – begins with a number
- button 5 – contains a space
- button*5 – contains a special character (*)
Using names that describe the use of the element being named is a good idea. This creates code that reads well comments itself.
Good naming should be balanced by creating names that are not too long and don’t encourage spelling errors.
Adobe suggests the use of extensions at the end of Identifier names. These extensions help label your Identifiers as being of a particular type. They also work with the code editor in Flash to give targeted code hints. All of the extensions begin with the _ followed by a few letters. Here’s a list of extensions, each is followed by the type it represents:
- _mc – MovieClip
- _sprite – Sprite
- _txt – TextField
- _str – String
- _array – Array
Here are a few names that might used for identifiers:
- home_mc – instance of a movie clip on the stage, maybe the button labeled Home
- icons_sprite – instance name of a sprite containing icons
- button_array – an array containing a list of buttons
Functions in PHP
PHP allows you to write functions similarly to the way functions are written in other languages. Functions in PHP provide the same advantages that they provide in other languages also. Functions provide a way to encapsulate a block of code so it can be reused as often as needed. This allows you to avoid rewriting the same blocks of code over again. Which makes your job easier by writing less code. This also keeps your from having to write similar or the same block of code more than once.
Continue reading PHP Basics: Functions