Flash AS2 - Tutorials and Articles

Banner Design Logo Placement Tips

When designing skyscraper banners (160×600 and 130×160…etc.) try incorporating your logo in to the top and bottom portions of your banner layouts.
If you only want to include one logo, try positioning the logo in the top or middle portions of the banner.
If you only include your brand identity at the bottom, it’s will most likely fall below the fold (below the initial browser window area) and out of view of the user. Having a logo atop of the banner insures the viewer will be able to identity the brand associated with the message and call to actions.

AS2 loop through all the movie clips on the stage

Here is a quick way to get and set properties for all movie clips on the stage without having to know the instance names of each MovieClip.

for (var prop in this) {
if (this[prop] instanceof MovieClip) {
mc = this[prop];
trace ("test name: " + mc._name + " mc._x:" + mc._x + " a: " + mc._alpha);
}
}

How to use JQuary LightBox with Flash getURL

I was searching ways to use Lightbox in Flash and found this great article at CodeFidelity.com.

http://blog.codefidelity.com/?p=18

Picture 1

Flash and SEO. Why not?

Google learns to crawl Flash
Google has been developing a new algorithm for indexing textual content in Flash files…
Source: http://googleblog.blogspot.com/2008/06/google-learns-to-crawl-flash.html

How to SEO Flash
•    Search Engines and Flash
•    Requirements for Successful Use of Flash
•    SEO Flash Programming
•    Example: Making Flash Home Page Spiderable
•    Scalable Inman Flash Replacement
Source: http://www.hochmanconsultants.com/articles/seo-friendly-flash.shtml

Here are a few comments on this topic from SearchEngineGuide.com:
“Stoney, You hit the nail on the head and pounded it down with one stroke. I completely agree, I have turned down clients in my own business due to flash sites. Now that I am with an agency I find Flash more common, as many of the businesses are big enough and niched enough where they feel that they don’t need SEO for their website. Oddly enough they are often right. Unfortunately SEO can have a big effect on PPC marketing, and most of these accounts suffer from bad keyword quality scores and thus higher click costs in AdWords.”

“Susan: I disagree slightly. Mostly because it all comes down to the intent. Building a flash only website for Ozzy Osbourne is fine, but e-commerce is not. I think you know what I mean”

“ Working on seo for hotel sites, I’ve come across some stunning creative sites designed with Flash. If the designers had thoughtfully used the Flash applications to “wow” site visitors, ie embedding in otherwise SE-friendly pages, it could be a win-win situation.
Perhaps all of you have seen the June info about making Flash SE-friendly. ( http://googleblog.blogspot.com/2008/06/google-learns-to-crawl-flash.html )”
Source: http://www.searchengineguide.com/stoney-degeyter/why-i-still-wont-seo-flash-websites.php

And from SearchEngineJournal.com:
“Disney does it. And so does Oprah. Even my favorite pizza place does it…  Granted these are extreme cases of sites which use flash extensively, but there are other cases where even a little flash can be improperly used. There are also cases where flash is not only appropriate, it is recommended. The question then becomes how to best use flash without affecting search engine rankings”

“Yeah this article doesn’t help a bit. I thought after reading I would be able to find a solution for my all flash website for seo purposes. Thefwa.com is an all flash website, they rank no.1, they didn’t follow your mumbo jumbo about not using too much flash” (Note from Alex: TheFWA.com does not rank no.1. They rank 31,905. Still not bad for an all flash site.)
Source: http://www.searchenginejournal.com/flash-and-seo-using-flash-on-websites/2247/

Cool online tool that will probe a flash file:

http://www.flashprobe.com/

Get SWF url path and domain name using AS3

In as2 you would use:
trace(_url);

Now in as3 you will have to use loadInfo:
trace(loaderInfo.url);

If you know there is a .com in the domain name, just do a split on the info using “.com”. Now the third item in that array (index 2) should be your domain name.
var swfDomain = loaderInfo.url;
var pathArray = swfDomain.split(“.com”);
trace(pathArray[2]); // should be yourdomain.com if on a web server

Get current URL or Domain of current flash location

Get current URL or Domain of current flash location

ExternalInterface for Domain Name

/* -------- ExternalInterface for Domain Name ------- */
import flash.external.*;
var urlPath;
function geturlhttp() {
urlPath = ExternalInterface.call("window.location.href.toString");
}
geturlhttp();
trace(urlPath);

LocalConnection for Domain Name

/* -------- LocalConnection for Domain Name ------- */
import flash.net.LocalConnection;
var lc:LocalConnection = new LocalConnection();
var domain:String = lc.domain;
trace(domain);

Loop through child movie clips in AS3 and AS2

To iterate through all children in a display object container…

ActionScript 3 Code Sample:

for(var i=0; i

ActionScript 2 Code Sample:

for (var Item in Parent) {
	if (typeof (Parent[Item]) == "movieclip") {
		Parent[Item].doSomething();
	}
}

Flash AS2 using setInterval and clearInterval as a timer

SetInterval comes in handy as a timers or to set time delays for action events. To stop the setInterval from repeating use the the clearInterval(myID) function using the id that you specified for the setInterval. See code sample below for a fully functional counter that ends after 4 seconds. Note that setIntervals time is in milliseconds. So 1000 = 1 second.

var count = 0;
var stopCount = 4;
myFunction = function (message) {
	trace (count +" "+message);
	count++;
	if (count >= stopCount) {
		count = 0;
		clearInterval (intervalID);
	}
};
intervalID = setInterval (myFunction, 1000, "Optional Message Passed");

Time Delay in Flash AS2 with setInterval

It’s relatively simple. Say you want to delay a slideshow of images every 5 seconds using actionscript. You would achive this with setInterval at 5000 milliseconds (every 5 seconds) calling predefined or anonymous function like so:

setInterval( function(){ trace("interval called"); fadeImage(); }, 5000 );