How to Detect Android and Redirect to Android Version Website

android-phone

I have been posting redirect scripts for several devices such as the iphone and ipad, and I thought why not add android to the list. I own a android phone and I love it, and I have tested this script so I know it works. This code detects whether the person viewing your website is on a Android device. If they are on a Android phone, you can redirect them to a android version website or just to another page, its up to you. If they are on a normal computer it doesn’t redirect them and they go on as normal. Its just some simple javascript, and if you want to use it just change the “document.location” value to the url you want them redirected. Here is the code, and its just the same as when you detect for iPhone.

1
2
3
4
5
<script type="text/javascript"> // <![CDATA[
	if ( (navigator.userAgent.indexOf('Android') != -1) ) {
		document.location = "http://www.yoururladdress.com/yourpage.html";
	} // ]]>
</script>

Cya

Loading Multiple XML Files in Flash

While working on my second version of RocFolio, I came across a few errors while trying to load multiple xml files in Flash AS3. When loading the files sometimes Flash would randomly put additional characters at the end of my xml file giving me parsing errors. So I had to figure out a way to cut those out, and I’ll try to explain real quick what I did.

So to load your XML you have to create your load and request variables and then you should create a few event listeners for progress and complete events, like this:

1
2
3
4
5
6
var loader:URLLoader = new URLLoader();
var requestURL:URLRequest = new URLRequest(xmlfilename.xml);
 
//create progress and complete event listeners for the loader, and load the urlrequest
loader.addEventListener(ProgressEvent.PROGRESS, getBytesLoop);
loader.addEventListener(Event.COMPLETE, loadXML);

Now in your loadXML function all you have to do is figure out where the xml file actually ends, and then index that spot and then cut the rest of the string out with the substring() command. Here is how you do that.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//function loadxml loads the xml and handles assigning to places
function loadXML(e:Event):void {
 
	var dataString:String = e.target.data;
	var finalString:String = "";
	var endofString:uint;
 
        //find out where the end of the xml file is, however your set it up it should be the last closing tag, this one is </settings>
	endofString = dataString.indexOf("</settings>", 0);
 
	//cut out the good part of the xml using substring, then use 0 as your starting point to where you got your endOfString
        //make sure to add whatever amount you need to be at the end of the your last closing tag, </settings> has 11 characters in it so +11
	finalString = dataString.substring(0, endofString+11);
 
	//then assign the finalstring to your XML variable
	try {
		var theXML:XML = new XML(finalString);
	} catch (e:TypeError) {
		//loader.load(requestURL);
		trace("A TypeError has occurred : \r\t" + e);
	}
 
//then go on with setting up your XMLLists so you can access the data how you want
}

So hopefully this helps those out there that are getting weird parsing errors when trying to load multiple XML files. I know I tried finding the solution out on the web and couldn’t so that’s why I wrote this, if it helps you out please leave a comment.

Cya

Scrolling in Flash

I have been getting a lot of questions for a good way of scrolling in Flash. So I thought I would let you know about the Scroll Flash Tutorial I made on how to do that. It gives you the code and the explains  basic functionality.  But if you don’t know anything about programming, I also created a simple Auto Scroll Flash file or in other words a Flash Text Ticker / Text Scroller file.  It’s completely customizable by XML so you don’t even have to know Flash to use it and it super easy to add to any website. You can change the font size, color, link color, background color, and add multiple lines of text if you want, and you can even setup a timer to display each text line item. If you buy it, there is also a help file that will give you a step by step process on how to edit the XML file and add the Flash scroller to your webpage.  To see a few examples of this file in action, click the example  image below.

If you guys have any more specific questions about scrolling in Flash,  just let me know by sending me an email through my contact page or leaving a comment.

Cya

Detect Iphone


I got inspired and wanted to finish up the iphone version of my website. To do this, first you need to detect the iphone and then redirect the user to another webpage. Here is the script to do that:

1
2
3
4
5
<script type="text/javascript">// <![CDATA[
	if ((navigator.userAgent.indexOf('/iPhone/i') != -1) || (navigator.userAgent.indexOf('/iPod/i') != -1)) {
		document.location = "http://www.scottrockers.com/iphone.html";
	}
// ]]></script>

Add this Javascript inside your <head> tags. and change the document.location to the page you want the user to get redirected to. The reason I have a iPhone version of my website is because my home page is made in Flash and as you know the iPhone can’t display Flash yet. So I created a basic html page that has a div in the body of it that is sized to 300 width by 350 height. And if you put this line of script in the <head> section it will tell Safari that the viewport should be the same size as the iPhone screen. Setting this line of code forces the content to always fit the window.

1
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">

Now, if someone wants to bookmark your website, they can hit the + sign and then click “Add to Home Screen” and you want to specify what icon to use for the iPhone, then create a 57px by 57px .png formatted image, put it up on your server and put this line of code in to your <head> section as well.

1
<link rel="apple-touch-icon" href="http://www.scottrockers.com/library/images/sriphonelogo.png"/>


Just make sure the href tag is the correct destination to your image. What is cool is that you don’t have to add the corners or shine effect on the webclip because the iPhone will do that for you.

If you want to see all the actual html code, you can just go to scottrockers.com iPhone Version and click view source.

Cya

SEO Check List

I wanted to create a SEO check list for every website that I work on, that way I could go back and reference it after finishing up a site. These methods are proven and if you follow this SEO checklist as well, then you will have increased traffic on your site too. If you want proof of it working, you can check out my other post Search Engine Optimization Techniques where I explain more in detail about all these points. This check list is just a quick guide to help remind you of whats left to finish on the website to optimize it for Search engine ranking. Here we go:

  1. First, you need to validate all of your webpages on your site (meaning your  html code needs to not have any errors or warnings in it). This is the most important step because if the bot can’t index your page then how is it going to know how to categorize it. You can do that here: w3c Markup Validation Service
  2. Select the keywords that pertain to your particular post or page. Its important to select your keywords using a Keyword Tool, like Google Adwords Keyword Tool, so you know how many people are searching the specific terms you are choosing and which ones have the least competition.
  3. Insert your keywords into these parts of the webpage:
      1. Title – Very important, the title appears in the search engine results page as the link, Google uses the title tag for determining page relevance and ranks the page higher if the saearch phrase is found in the title.
      2. URL – Your keywords should be used in the url that specific page,  either in the directory or file name. Its good to use hyphens instead of a space in naming convention.
      3. headings – Every page should have a heading <h1> tag, and the keywords should be used in this and the h1 tag should be used only once.
      4. Text – In the text on your page, its very important to use the keywords in the first part of your webpage content. Also, if there is a small amount of text on the page it could cause the page to be ranked poorly too.
      5. keywords Meta Tag – Every webpage should have the keywords used in “Keywords Meta Tag”.  You add this line of code in between the <head> tags:<meta name=”keywords” content=”Your specific keywords” >
      6. Description Meta Tag – You add them like this:<meta name=”description” content=”A description sentence about your page or post pertaining to your keywords” >
      • Links – Use keywords in your links instead of using “click here” or phrases like that.
      • Images – all <img> tags should use the alt attribute using the keywords
      • Include a robots.txt file in the site root of your website. Even if the robots.txt file is blank upload one to your server because it will prevent your site from producing error messages every time a search engine spider visits your site.
      • Include a sitemap.xml file in the site root of your website. There is a website that will automate or help you create/ edit  a sitemap.xml file, it called xml-sitemaps.com.

      This is just  a really quick seo check list that will dramatically help with your websites overall SEO, but if you don’t think your site is being indexed by google still, you can go to google.com/addurl and add your site url and google will start to index your site.

      Cya