Sunday, June 27, 2010

Flash Player Runtime Errors and How to Fix Them

The following lists common runtime errors found with Flash Player and what you can do to fix them. Also available, Compiler Errors.

TypeError: Error #1009

TypeError: Error #1009: Cannot access a property or method of a null object reference.

This error occurs when you attempt to access a property or call a method (function) from an object variable that has no value (undefined) or has a null value. If the object is null, it has no value itself meaning it cannot contain any properties. The following example would be a situation where the error would occur:

var mySprite:Sprite; // null since not defined trace(mySprite.x); // Error #1009

Because the mySprite variable is null, accessing mySprite.x would be the same as null.x which is not possible, thereby creating the error condition. Note that this behavior is new to ActionScript 3.0. In ActionScript 2.0 and 1.0, doing this would cause a silent failure and return a value of undefined.

Usually when this error occurs, it means an error in your code logic. You're code is assuming an object exists when it does not. That is something you will have to identify and fix. This can sometimes be difficult because of the error's ambiguous text; it does not specify what specific object the error is in reference to. However, if you test a debug version of your project in your IDE, it will tell you.

Debugging in Adobe Flash Professional:

From the File menu, select Debug > Debug Movie.

Debugging in Flash Pro

Debugging in Adobe Flash Builder:

From the File menu, select Run > Debug [ProjectName].

Flash Builder Debugging

When debugging (in either Flash Pro or Flash Builder), a Debug version of your project which will include more information about code execution that can help better identify errors. When the error occurs, code execution will pause and the line of code with the error will be pointed out in the code view. Additionally, the Variables panel can be used to inspect the values of the objects and properties within the current scope.

If there is a circumstance where it is known that an object may or may not exist, then you would first need to check to see if the object being used has a value before attempting to access properties or call methods from it. This can be handled through a simple if condition.

if (mySprite){  trace(mySprite.x); }

Alternatively, you can also encase your logic in a try-catch block, directly handling any error that may occur.

try {  trace(mySprite.x); }catch(err:Error){  // it's OK, we know mySprite may not exist }

Common circumstances where a #1009 may occur:

  • root, stage, or loaderInfo is null. The root, stage, and loaderInfo properties of the DisplayObject class are unique in that their values are dictated by whether or not the DisplayObject is a child of the active display list. If the DisplayObject is not, these properties will each be null. They will not have valid values until the object made a child of the active display list throughaddChild or addChildAt. You can identify when this occurs using the Event.ADDED_TO_STAGE event.
    addEventListener(Event.ADDED_TO_STAGE, stageAndRootAndLoaderInfoAvailableHandler);
  • A variable is declared, but not defined. As is the case with the mySprite examples, the mySprite variable was declared, so it exists, but it was never defined with a valid Sprite value. This can be common when creating new classes where you have correctly declared all of the necessary variable members but may have neglected to define them before they're being accessed.
  • A timeline instance no longer exists. If you navigate to a frame within the timeline of a MovieClip that no longer has a timeline-placed object you're referencing in code, that object variable will be null. You will need to make sure you're on the correct frame or at least check to see if the object variable is still valid when used.

ReferenceError: Error #1056

ReferenceError: Error #1056: Cannot create property [property] on [Type]

This error occurs when you try to create a new variable on an object that does not already have that variable and is not allowed to have new variables created for it dynamically. Only instances of dynamic classes can have arbitrary variables defined for them. These classes include Object, Array, MovieClip, and a few others. Most classes, however, are not dynamic and limited to use only those variables which are part of their class's definition.

var mySprite:* = new Sprite(); // untyped to circumvent compiler errors mySprite.foo = "bar"; // Error #1056

The Sprite class is not dynamic so the variable mySprite above generates an error when an unrecognized variable foo is attempted to be set on it.

If you are in a situation where you need to set a variable in this manner, you have a couple of options. One option is creating a new class that extends the original and contains the property you need to use. For the case of mySprite above, a new class extending Sprite can be created to used in place of Sprite that contains the foo property.

// in CustomSprite.as package {  import flash.display.Sprite;  public class CustomSprite extends Sprite {   public var foo:String;   public function CustomSprite(){    super();   }  } }
var mySprite:CustomSprite = new CustomSprite(); mySprite.foo = "bar"; // OK

If you do not have control over the definition of the object you're working with, usually the best solution is making a hash map. A hash map (or simply map) will allow you to link a custom value with a unique key, or in this case an object, in a location other than within the object itself. Generic objects in ActionScript can map strings to values but for this to work - mapping values to object instances - a Dictionary instance will be needed for the map. Example:

var foo:Dictionary = new Dictionary(true); var mySprite:Sprite = new Sprite(); foo[mySprite] = "bar"; // OK

Here, you can see that instead of setting a property on the mySprite Sprite, mySprite is instead being used as a property on a fooDictionary (map). As long as you have access to both foo and the Sprite instance, you have access to custom values that are directly associated with that Sprite even though they are not defined on it. The nature of the map allows it to be used with any other objects as well, not just the mySprite instance. If at any time you need more custom variables, you would create a new map.

var foo:Dictionary = new Dictionary(true); var boo:Dictionary = new Dictionary(true);  var mySprite:Sprite = new Sprite(); foo[mySprite] = "bar"; // OK boo[mySprite] = "far"; // OK  var myMovieClip:MovieClip = new MovieClip(); foo[myMovieClip] = "none"; // OK boo[myMovieClip] = "away"; // OK

Hash maps are very versatile but they lack type safety and can be difficult or confusing to manage. When possible, it's recommended you use a custom class to solve this issue.

ArgumentError: Error #1063

ArgumentError: Error #1063: Argument count mismatch on [function](). Expected [#], got [#].

This occurs when a function is called in a way that does not satisfy the number of arguments that is expected for the function call. When a function is defined, it's parameters determine what arguments is expected to be passed into that function when the function is called. Unless given a default value, all parameters are required. Additionally, if a function has no parameters but arguments are provided when called (or more arguments than there are parameters are provided) this error will also occur. Examples:

function myAddFunction(a:Number, b:Number):Number {  return a + b; }  myAddFunction(1); // Error #1063 // exactly two arguments are required 
function myRandomFunction():Number {  return Math.floor( 10 * Math.random() ); }  myRandomFunction(1); // Error #1063 // exactly zero arguments are required

When function calls are made, the arguments used must match the parameters defined by the function definition. Note that this behavior is new to ActionScript 3.0. In ActionScript 2.0 and 1.0, doing this would cause a silent failure and the superfluous arguments would be ignored.

If you need to allow a function to be called with a varying number of arguments, you have two options: default parameters and the ...rest parameter. Default parameters specify optional parameters. Arguments may be passed into a function to satisfy these parameter values or they can be omitted at which point the default values will be used. To define default parameters, include an equals sign (=) with a default value next to the parameter in the function definition. All default parameters must be at the end of a parameters list; non-default parameters cannot be listed after a default parameter.

function myAddFunction(a:Number, b:Number = 0):Number {  return a + b; }  myAddFunction(1, 2); // standard use myAddFunction(1); // also OK, b will default to 0 myAddFunction(); // Error #1063, a is still required

The ...rest parameter signifies that any number of arguments can be used in place of where the ...rest is in the parameter list. Any required parameters before ...rest are still required. When using ...rest, any variable name may be used to signify the extra parameters. It must be preceded by 3 dots (.) and must not be followed by any additional parameters. In the function body, the ...rest variable references an array containing any arguments used in place of the ...rest parameter.

function myAddFunction(...values):Number {  var total:Number = 0;  var i:int, n:int = values.length;  for (i=0; i

Common circumstances where a #1009 may occur:

  • Event handlers. If you create a function that is used for an event handler, it must be able to accept single Event argument.
    addEventListener(Event.ENTER_FRAME, enterFrame); function enterFrame():void {  // Error #1063, an event parameter is required! }
    addEventListener(Event.ENTER_FRAME, enterFrame); function enterFrame(event:Event):void {  // Works! }

ArgumentError: Error #2025

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.

This occurs when you try to use a removeChild with a display object that does not exist within the parent object you are trying to remove it from. For example, in the following sample where myParent is a Sprite or some other DisplayObjectContainer instance that (supposedly) contains a child Sprite (or some other DisplayObject) called myChild:

myParent.removeChild(myChild);

this error would occur if the myParent instance (the "caller") did not contain myChild (the "supplied DisplayObject"). This could be because myChild was already removed prior to this call, or myChild exists within some other object. If this is happening when you think it shouldn't, try tracing the value of the child display object's parent to see if it's what you expect.

To be safe, when removing a child display object from its container, you should make sure the object you're removing it from is, in fact, it's parent.

if (myChild.parent == myParent) {  myParent.removeChild(myChild); }

This goes with the assumption that you need to explicitly remove that child from that specific parent. If you just want to remove the child from the display list, you can explicitly reference it's own parent through its own parent property rather than an object reference for the object you suspect might be its parent. In doing so, you should check to see that parent exists. If it's null, it is already off of the display list.

if (myChild.parent) {  myChild.parent.removeChild(myChild); }

This is the standard approach for removing an object from the display list. Verify it's on the display list (parent is not null) then remove the object from it's parent directly.

There is one exception to this rule: event handlers for the Event.REMOVED event when a timeline containing the child display object moves to a frame where the child does not exist. In this case, parent will be non-null but the removeChild will not work because the child display object is actually no longer on the display list. This circumstance would be extremely rare, but for absolute assurance that your code would continue without interference, you can attempt to handle the error in a try-catch block when attempting to remove the child display object with removeChild.


if (myChild.parent) {  try {   myChild.parent.removeChild(myChild);  }catch(err:Error){   // fail silently; child already removed  } }    
source link : http://www.senocular.com/flash/tutorials/runtimeerrors/

100 Popular jQuery Examples, Plugins and Tutorials

    1. jQuery Lavalamp MenuIt is the jQuery plugin that is based of Guillermo Rauch plugins for mootools and Ganesh Mawwaha’s jQuery 1.1.x plugins. Through the Sliding Doors CSS/Javascript method, you are able to add a background hover effect on HTML link lists with Lavalamp by utilizing the Eazing library.
    2. Superfish Menus – Suckerfish on ‘roids, This jQuery plugin allows the development of improved Suckerfish style of dropdown menus from the existing pure CSS type of dropdown menu. The features that are added as a result of these include: a timed-delay on mouseout, automatic utilization of hoverIntent plugin when present; obligatory IE6 –hover capability; animated sub-menu; accessibility through keyboard tab key; generation of arrows to indicate the submenus; use of drop shadows for browsers that are capable; and many others.
    3. jQuery Context MenuThis jQuery plugin provides easy implementation, CSS styling, keyboard shortcuts and control methods.
    4. Kwicks for jQueryThis highly versatile and customizable widget had started as just a port for Mootools framework.
    5. jQuery iPod-style Drilldown MenujQuery has an iPod-style drilldown menu that helps users traverse hierarchical data with relative ease and control. This feature is very useful in organizing large data structures that don’t translate well into the traditional fly-out or dropdown menus.

    6. jQuery File TreeThis jQuery plugin is a configurable AJAX file-browser plugin where you use to create a fully interactive and customized file tree as little as one of the Javascript code.
    8. CSS Sprites2 using jQueryOne can use jQuery to implement CSS Sprites2. One distinct advantage of jQuery over the other javascript libraries is that it allows users to select elements on a pages using CSS-like syntax that we are already familiar with.
    9. jQuery AccordionIt is the jQuery plugin that allows the creation of the accordion menu. It can be used for nested lists, nested divs and definition lists. This plugin has options for structure specification, active element, when necessary, and animation customization.

    IMAGE MANIPULATION

    10. jQZoomIt is the jQuery plugin that easily allows the creation a small magnifier window near an image or group of images on the web page. You decide to build jQZoom to embed big images in your B2B. This creates the jQZoom in your eCommerce websites or any other websites.
    11. jCropThis jQuery plugin allows an easy and quick way of adding image-cropping functionality to web application. This functionality combines the use of typical plug in with a powerful cross-platform DHTML cropping engine that is compatible to common desktop graphics applications.
    12. Captify 1.1.0It is a jQuery plugin that creates short and beautiful image captions that appear every time a user’s mouse passes over an image.

    IMAGE GALLERIES AND VIEWERS

    13. Simple Controls GalleryThis jQuery tools displays and rotates images by fading it into view over the previous images using navigation controls that pop up when the mouse moves over the gallery.
    14. Agile CarouselIt is a jQuery plugin that provides for the easy creation of a custom carousel. This plugin makes use of PHP to call images from the folder that is specified by the user. Users can configure different options including slide timer length, controls, transition type, easing type and more.

    TRANSITION EFFECTS

    15. InnerFadeIt is a small jQuery plugin used in the jQuery Javasrcipt Library. This plugin allows using fade effects on any element found within a container in and out. The elements may include divs, list items or images. In order to do this, you have to create your own slideshow and the produce a newsticker or an animation.
    16. Easing PluginIt is the jQuery plugin that comes from GSGD that provides advanced easing options. This plugin can support a default easing mode. This allows you to set your preferred animation once for all animations. It uses the Robert Penners easing equations for all the transitions.
    17. HighlightFadeIt is a jQuery plugin that allows the use of fading effects from one color to any other pre-selected colors at any transition speed and interval of color update using a color progression tactic that is customizable.
    18. JQuery Cycle PluginIt is a jQuery plugin that is classified as basic slideshow plugin. It is based on the Slideshow plugin by Matt Oakes, jqShuffle plugin by Benjamin Sterling and the InnerFade plugin by Torsten Baldes. This plugin can do auto-stop, before and after callbacks, pause-on-hover, and many other transition effects.

    jQUERY CAROUSEL

    19. Riding Carousels using jQueryIt is the jQuery plugin used for controlling items in a list in vertical or horizontal order. The list of items can be loaded with or without AJAX, or can be a static HTML content. It can be scrolled in either direction with or without animation effects.

    COLOR PICKER

    20. FarbtasticIt is a jQuery plugin that allows you to add more color picker widgets in a page using Javascript. These widgets are linked to an element and will update the value of that element when one particular color is picked.
    21. jQuery Color PickerIt is a jQuery plugin that allows you to select color in a way that is almost the same as you pick colors in Adobe Photoshop. This jQuery plugin is a Flat mode element in a page and is easy to customize the look by simply changing the images. It also has powerful controls used for selecting the colors and fits easily into the viewport.

    LIGHTBOX

    22. jQuery ThickBoxIt is a jQuery plugin that is created using the jQuery library. The function of this jQuery plugin is to resize images that are bigger than the browser window and provides versatility in inline content, images, AJAX content and iFramed content. It will remain at the center of the window even if you change the size of the browser window or you scroll the pages.
    23. SimpleModal DemosIt is a jQuery plugin defined as lightweight plugin that creates a basic interface to provide a modal dialog. This jQuery plugin shall give developers a cross-browser overlay and a container that will contain data provided to SimpleModal
    24. jQuery LightBox PluginIt is a jQuery plugin that provide an option to present an image on a page in a simple and elegant manner. Under this jQuery plugin, the lightboxes can be assembled in one group and provides many options for configurations. It also provides both the manual and automatic options to create and to start lightboxes.
    25. Revealing Photo SliderThis tool of jQuery allows to create a thumbnail photo gallery where clicking a button would reveal the entire photo and other information about the photo.
    26. FancyBoxThis jQuery tool automatically scales large images to fit in windows by adding a nice drop-shadow under the zoomed item. This tool can be used to group items that are related and add navigation between them. It is totally customizable through CSS and settings.
    28. jQuery.popeyeIt is a jQuery plugin that converts an unordered list of images into a simple image gallery. When an image is clicked, it enlarges just like with LightBox.

    FORM ELEMENTS AND VALIDATION

    29. jQuery Form ValidationIt is a jQuery plugin that is fast, unobtrusive, scalable and easy to use validation plug in that offers a variety of methods for all types of validation needs. It comes from the very basic to the more complex schemes of validation.
    30. Ajax Form ValidationThis refers to the client aspect of validation using Javascript. The username will perform the validation by checking with the server whether a chosen username is available and valid.
    31. jQuery AlphaNumericIt is a jQuery plugin that uses javascript to allow you to control what characters a user can use and enter on text areas and text boxes.
    32. jQuery.combobox – It is a jQuery plugin that provides a simple way of producing an HTML type of combobox from the existing HTML Select tags. This plug in was created to provide the solution on the limitation in styling of standard Select tag.
    33. jQuery CheckboxIt is a jQuery plugin that creates a replacement for the standard checkbox. This plugin allows you to modify the look of the elements of the checkbox in the page.
    34. File Style PluginIt is a jQuery plugin that solves your problem with browsers that does let you style file inputs. This jQuery plugin also allows you to style filename field to normal textfield by using css.
    36. Submit a Form Without Page RefreshBy using jQuery, you not only can add form validation to wordpress comments without any page reload but also submit your form without a page refresh.
    37. jQuery AJAX Contact FormUsers of jQuery can make an AJAX contact form with a “honeypot” to foil email bots, load success and error messages without leaving the page and provides descriptive error messages detailing the reasons for the failed validation of the submitted value.
    38. jQuery Form ValidationThis form of jQuery can show form-input validators both the browser-side and server-side

    STAR RATING

    39. Simple Star Rating SystemIt is a jQuery plugin used for star rating system. This jQuery system was created with the basic framework of the star rating system of Wil Stuckey. This jQuery plugin provides the solution on the problem of the original script requiring too much coding. It also did away with the requirement for developing a star system.
    40. Half Star Rating PluginIt is a jQuery plugin that was developed in response to the clamor for an enhancement of the simple rating system of Ritesh Agrawal and allow for the use of half-star rating system.

    TABLE PLUGINS

    41. Table Sorter PluginIt is a jQuery plugin that is used to turn a standard HTML table with TBODY and THEAD tags into a table which is sortable without resorting to page refreshes. This jQuery plugin can effectively sort and parse multiple data including data in a cell that are linked.
    42. Autoscroll Plugin for jQueryIt is a jQuery plugin that provides for hotspot scrolling of webpages. This jQuery plugin will still work even with earlier versions of jQuery.
    43. Scrollable HTML Table PluginIt is a jQuery plugin that is used to convert HTML tables into scrollable tables. This jQuery plugin solution does not require any additional coding.
    44. Table Row CheckBox ToggleThis jQuery tool adds a toggle function to any table row that you specify based on a CSS class name. This tool will toggle on by default any check boxes within that table row.
    45. TablesorterThis is a jQuery plugin that allows you to turn a standard HTML table with and tags to a sortable table without refreshing the page. This plugin can successfully parse and sort many kinds of data in a cell.
    46. TableEditorThis tool allows flexible in-place editing of HTML tables. Users can easily drop handler functions to update.

    ROUNDED CORNERS

    47. jQuery Curvy CornersIt is a jQuery plugin that allows for the creation of nice looking rounded corners without the use of images. It is a jQuery plugin considered to be unobtrusive and can work well with all major browsers which include iPhone. Another nice feature about this jQuery plugin is that the corners to be rounded and its radius can be set easily.

    OTHER JQUERY PLUGINS

    48. HeatColor PluginIt is a jQuery plugin that provides color to elements and determined by a value derived from that element. This derived value comes from a range of value which are either pre-designated or passed in. The element is then assigned a “heat” color which is derived from the position of the value within the range of values.
    49. jQuery Date PickerIt is a jQuery plugin that is considered unobtrusive and clean. It adds date-entry functionality to web forms and pages. It was created from the basics up in order to attain flexibility and extensibility. It has varied options of use that allow you to all a calendar widgets to web pages and forms.

    DYNAMIC CONTENT

    50. Create a Log-in Form with jQueryOne can create a sliding panel that slides in to reveal new content and animate the height of the panel through jQuery.
    51. Spoiler Revealer with jQueryThis is a technique in jQuery that can hide and reveal content with animation effect once it is clicked.
    52. AJAX UploadIt is a jQuery plugin that provides for easy uploading of multiple files without having to refresh the page. This plugin also allows the use of any element to trigger the file selection window.
    53. FCBKcompletejQuery also provides users with Facebook-like dynamic inputs along pre-added and auto-complete values.

    MANIPULATING CONTENT

    55. jQuery Books WidgetOne can use jQuery with some custom Javascript to create interesting widgets like a browsable Amazon.com books widget.
    56. Text Size SliderUsers of jQuery can control the text size of an article on a page using a slider. This feature of jQuery allows the user to control exactly the size they prefer and is a very impressive feature to have on a site.
    57. PaginationUsers of jQuery can group large numbers of items into pages and present navigational elements that allow users to move easily from one page to another.
    58. Coda-SliderThis jQuery tool also groups items together through navigational elements that allow users to traverse the pages.
    59. Slick Auto-Playing Featured-Content SliderThis jQuery plugin allows users to cycle through panels and auto-playing different kinds of custom content. It features an arrow indicator to guide users on which panel he is currently viewing.

    BROWSER TWEAKS

    60. Setting Equal Heights with QueryThrough jQuery, users can utilize a script that can equalize the box heights within the same container to create a tidy grid.
    62. BGI FrameThis jQuery tool helps users in dealing with IE z-index issues.
    63. Fix OverflowThis jQuery bug fix solves the issue on the scroll bar covering overflowing elements when the element is only one line.
    64. Lazy LoadThis tool can delay the loading of images below the fold on long pages, loading the images only when the user scrolls down on that part of the page.
    65. MaxlengthThis jQuery plugin automatically limits the number of characters a user can input in a field and giving feedback on how many spaces are remaining.

    ANIMATION EFFECTS

    66. ScrollableIt is a lightweight and flexible jQuery plug-in used to create a scrollable content. It can contain any HTML, including images, forms, text, video or a combination of any of them.
    67. Fading Menu-Replacing ContentThis jQuery tool lets users to utilize animation and change the way to style a page on-the-fly to react to events that happen on your page.

    TOP jQUERY TIPS

    70. Rotate Through Tabbed ContentThrough this functionality of jQuery, the movement is more likely to catch the user’s eyes, thus increasing the chances they will notice the tabbed box and allow the user to see all the content of the box instead of just the first tab.
    71. Stopping the RotationThis technique allows users to stop the rotating of tabs and stop it from switching when you are interacting with them. The technique involves some editing a couple of lines from the document ready function.
    72. Build a Tabbed Content with CSS and jQueryThis technique outlines the steps required to easily customize to fit the size and color scheme, use fixed or variable height, automatically rotate through the tabs and stop the rotation when the user needs to.
    73. Advanced CSS Accordion EffectThis technique is improved by the use of Javascript and all browsers will handle this technique even without JS enabled.
    74. Consistent Base Font SizeThis is the best jQuery technique to gain control over your font sizes until IE finally support the resizing of text in pixels.
    75. Maintain Consistent MarginsThis jQuery technique enables users to remove the margin and padding from every element instead of CSS resets.
    76. Set a Float to Clear a FloatThis jQuery is one of the most important things to understand with CSS. However, it is also important to learn how to clear floats.
    77. Image ReplacementThis image replacement technique involves the positioning an image over the top of the HTML. One feature of this technique is that even when images are disabled, the text is still visible.
    78. Faux ColumnsThis technique allows 2 adjacent columns with unequal amounts of content to have 1px tall background image being repeated vertically in the containing element of the 2 columns.
    79. Animate a Hover with jQueryThis technique allows users to animate an image while hovering over it and allow users to see information while doing that
    85. 43,439 Reasons to Use Append() CorrectlyThis technique provides for the proper way of using this jQuery method. Although an extremely easy and useful method to work with, it can significantly affect the performance of the page.
    87. Minimize Manipulation of DOMWe can further make the code faster if we cut down on the frequency that we insert into the DOM. Insertion operations of DOM will make things slow down.
    88. Give context to your selectorsWhen you use the selector, the entire DOM will be traversed as a result of the action. This can be a very expensive process.

    jQUERY TUTORIALS

    89. How jQuery WorksThis is a featured tutorial on jQuery by John Resig, the creator of jQuery. This is an ideal basic tutorial for those who are starting to learn jQuery for the first time.
    90. jQuery in 15 DaysThis is a 15 day tutorial that turns you from a greenhorn to an expert in 15 days.
    91. BassistanceThis tutorial covers the basics of jQuery up to the more advanced topic like building plugins.
    92. Remy Sharp’s BlogHe has written numerous tutorials and plugins and he is also the person responsible for the very helpful jQueryForDesigners website which also provides useful tutorials in answer to request of readers.
    93. CSS TricksThis reference site is full of examples, tips, tricks, tutorials and news about cascading style sheets (CSS).
    94. jQuery Cheat SheetsIt provides to aspects of cheat sheets. These are: those made for iPod and other mobile devices; and those with the A4 cheat sheet.
    98. How to Get Anything You WantThis is an introductory tutorial on traversal methods and jQuery selectors and their use in DOM navigation
    99. It’s all about CSSAs the title suggests, this tutorial is all about CSS selectors. Once you learn from this tutorial, you can now easily query the DOM.
    100. jQuery Crash CourseThis tutorial is designed for web designers with advanced knowledge of codes.

How to remove index.php from url using .htaccess (mod_rewrite)


For better SEO optimization and make urls more search engine friendly , remove index.php from URL and make it easier to read.

Remove index.php from URL can be done by writing only two lines in your .htaccess(mod_rewrite in apache) file. Before writingthis rule in .htaccess , make sure that your mod_rewrite is enabled(On) in yourapache server. Most probably mod_rewrite is enabled in Linux server but for windows server , you need to contact hosting people to make mod_rewrite enabled. You can check this by looking in phpinfo().

Below is the Rules which will remove index.php from URL using .htaccess. Look at below links for .htaccess rules.


RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /([^/]+/)*index.php HTTP/ RewriteRule ^(([^/]+/)*)index.php$ http://www.%{HTTP_HOST}/ [R=301,NS,L]

Redirect 301 means Moved Permanently so most search engines will remove index.php from URL.

To know more about programming,MYSQL database,php info,php editor,programming php,Open-source,php help and php script , subscribe to our feed by entering email address below. You will get updates via email about every tutorial posted on this site . It will not take more than a sec.

Redirect one domain to another using .htaccess

Are you looking for redirecting your website fromone domain to another ? I was working for client who has a domain in .com and now they want to move full website into .ie domain. The problem is that all links has been crawled by major search engine. So if we remove all files from .com domain than it shows 404 not found (broken links) for .com domain links. Also we have to remove files to avoid duplicate content issues.

The solution is to redirect all request from .com to .ie. So we need to write rules in .htaccess file of .com domain which redirect all request from .com to .ie and we will not loose the visitors. Below are the rules which is useful forredirecting from one domain to another domain.


Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^www.olddomain.com$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]

Comment below if you have any query.

To know more about programming,JavaScript issues,jQuery,Expression Engine,MYSQL database and Open-source, enter your email address below. We will send you free tutorials.


Source link : http://www.programmingfacts.com/2010/03/09/redirect-domain-htaccess/

Thursday, July 31, 2008

Flash - PHP Feedback Form

Flash - PHP Feedback Form. It is easy to create and send your comments with in few seconds..






Paste below codings in your flash action script file.


var sendData_lv:LoadVars = new LoadVars();
var receiveData_lv:LoadVars = new LoadVars();
var formValidated:Boolean;
var errorMessages:Array = new Array();

receiveData_lv.onLoad = function():Void{
trace(this.sent);
if(this.sent == "OK"){
message0_txt.text = "Thank you for your feedback";
}else{
message0_txt.text = this.sent;
}
}


submit_btn.onRelease = function() {
//this clears the error text field if they have been populate previously
clearTextFields();
errorMessages.length = 0; //empty the array so next time the submit button is clicked the array is not already populated
formValidated = checkForm();
if (formValidated) {
//the form is valid and so now we can send details to our PHP file
//populate LoadVars object with the field values
sendData_lv.name = name_txt.text;
sendData_lv.email = email_txt.text;
sendData_lv.feedback = feedback_txt.text;
//trace(sendData_lv.email);
//trace("valid");
sendData_lv.sendAndLoad("email.php?ck="+new Date().getTime(), receiveData_lv);
} else {
//populate textfields with the error messages
for (var i = 0; i _root["message"+i+"_txt"].text = errorMessages[i];
trace(errorMessages[i]);
}
}
};


function checkForm():Boolean {
//check whether the name field is empty
if (name_txt.text == "") {
errorMessages.push("Please enter your name.");
}
if (email_txt.text == "") {
errorMessages.push("Please enter your email address.");
} else if (email_txt.text.indexOf("@") == -1 || email_txt.text.indexOf(".") == -1) {
errorMessages.push("Please enter a valid email address.");
}
if (feedback_txt.text == "") {
errorMessages.push("Please enter some feedback");
}
//if at this point the array is empty i.e has length 0, then this in effect means the form has passed all checks
if (errorMessages.length == 0) {
return true;
} else {
return false;
}
}


function clearTextFields():Void {
for (var i = 0; i _root["message"+i+"_txt"].text = "";
;
}
}


Your Actionscript file is ready then create a phpl file to send your information. The php file names as email.php

$name = $_POST['name'];
$email = $_POST['email'];
$feedback = $_POST['feedback'];
$subject = 'feedback from your website';
$headers = "From: $name <$email>\n";
$headers .= "Reply-To: $name <$email>\n";

//ENTER YOUR EMAIL ADDRESS HERE
$to = 'innovativeidea@gmail.com';
//---------------------------

$success = mail($to, $subject, $feedback, $headers);
if($success){
echo '&sent=OK';
}else{
echo '&sent=Error';
}
?>