Archive for Flash/Actionscript

Flash Player 8.5 Beta renamed to Flash Player 9

Adobe has announced that the next released version number of Flash Player will be 9 instead of 8.5.

I think this probably a good change, because it brings to light the importance of the new enhancements.

I for one am very excited for the release of AS 3.0/FP9. There is not enough time in a day to satisfy how long I just want to jump into Flex/AS3, but I suppose it won’t be long until it is released.

I must admit thoguh, I havent had the opportunity yet to check out Flex, although I have heard quite a bit about it.

A friend of mine and a very well-rounded flash developer; Kristopher Schultz was showing me a bit about AS 3.0 that got me excited, like the integration of regular expressions, I am not certain on how it will work, but I love where they are going with it.

Comments

Create a smooth startDrag() in Flash

Let's face it, startDrag() has been around since wow....flash 4 I think? Perhaps Flash 3, not sure exactly. Sure it serves its purpose still, but one thing that has always bugged me about it ever since updateAfterEvent() became available, is the fact that startDrag is dependant of the frame rate.

I put together a simple MovieClip prototype that would work the same way as startDrag except using updateAfterEvent. It is pretty basic so you could probably add a lot to it, but it does perform the simple task of draggable Objects without being dependant upon the frame rate!

Actionscript:
  1. MovieClip.prototype.startSmoothDrag = function (lockCenter:Boolean) {
  2.     if (lockCenter == undefined) var lockCenter:Boolean = false;
  3.     var thisXMouse:Number = this._xmouse;
  4.     var thisYMouse:Number = this._ymouse;
  5.     var setPosition:Function = function (target:Object)
  6.     {
  7.         target._x = target._parent._xmouse - ((lockCenter) ? 0 : thisXMouse);
  8.         target._y = target._parent._ymouse - ((lockCenter) ? 0 : thisYMouse);
  9.     };
  10.     setPosition(this);
  11.     this.onMouseMove = function () {
  12.         setPosition(this);
  13.         updateAfterEvent();
  14.     };
  15. };
  16.  
  17. MovieClip.prototype.stopSmoothDrag = function () {
  18.     this.onMouseMove = null;
  19. };
  20.  
  21. myDraggableMC.onPress = function () {
  22.     this.startSmoothDrag(true);
  23. };
  24.  
  25. myDraggableMC.onRelease = myDraggableMC.onReleaseOutside = function () {
  26.     this.stopSmoothDrag();
  27. };

I have also put together a simple demo of this in use, to give you an idea of how it can be effective. Notice below that the fps (frames per second) is set to 1, which is slow if you didn't already know :). Notice how the smooth Dragable obejct is really smooth, while the regular startDrag() method is dependant on that horrifying 1 fps!

Click here to download.

Like I said, it is pretty simple but feel free to add to it what you want!

Digg This!

Comments (15)

Metadata; SEO for Flash

Before Flash 8, there was no standard for seo'ing a flash movie. There was, and still is limited functionality provided by major search engines such as google, for instance if you search "game filetype:swf" in Google, it will return some results perhaps relevant but not really accurate.

In Flash 8 there is something called "Metadata". Although, in my opinion standard html pages will always have the higher "value" in terms of being indexed well by search engines. But this is a good start for getting flash on the right track in terms of SEO for flash.

Within Flash 8, open the document properties and along with your usual document properties you will see the Title and Description Fields, that pretty much says it right there.

Flash 8 Metadata

One thing to keep in mind, and is what I tell everybody who asks me anything about SEO: Don't try to use meta fields to spam keywords. This applies to html with meta tags as well. This isnt 1999 any more and the search engines aren't stupid. So just put what best defines the flash movie and allow the search engines to gain accuracy, common sense really.

If you turn on size report generation (File > Publish Settings > Flash Tab > Generate Size Report) and then test your movie (CTRL + ENTER) you will see something like this in the report:

Metadata
--------
Bytes    Value
-----    -----
217    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/1.1/"><dc:title>My Flash Movie Title!</dc:title><dc:description>This is my flash movie's description!</dc:description></rdf:Description></rdf:RDF>

Keep in mind though, that because you included the meta information for your flash movie, this does not mean that it will automatically generate the meta tag information for your actual html page, this you will need to do separately. Although, in my opinion meta tags for html pages are no where near as vital as they once were and are more of an option.

Also another perk to using the metadata fields, is that you can publish the information for ANY version of flash player 8 or earlier. This means if you have a flash site compiled in flash 6 and just want to include the metadata, then go right ahead! You will need the corresponding .fla file and flash 8 to do this, but in the long run I think it is worth it.

Digg this!

Comments (1)

Why Strict Data Typing is Good

I must admit, my first introduction to strict data typing was in JSP and at the time I HATED it. But it wasn't until I got into strict-typing in actionscript that I realized "hey hey.....wait a minute" - trust me when I say it has more then one purpose then cluttering the code.

In fact, when utilized to it's full extent, you can minimize your code by preventing common code problems like unnessecarily making 2 or more variables of something that could just be the same, along with other common coding "typo's".

Take for example this simple "hello world!" code:

Actionscript:
  1. myVar = "Hello World!";
  2. trace(myVar);

Simple? Yes, it is. And if this is all the code you had to write and this were a perfect world, then I see no harm in keeping it that way. However lets say that was only 2 of about 100-300 lines of code, well sure its still readable, but if you used strict typing on everything, well its kind of like having road signs on the highway, it gives you direction, it labels a variable, array or whatever your contraption may be without you having to dive through your code to find what the hell the variable hahaYouDontKnowWhatIAm is for.

Here is the above code using strict data typing:

Actionscript:
  1. var myVar:String = "Hello World!";
  2. trace(myVar);

Alone it doesn't look like much, I know, but try using it in your next endeavor in actionscript and you will see what I mean.

Another great use of strict data typing is with functions, especially when you are passing parameters that should be strict, although it is usually a rare event. Here is an example of using strict data typing with a function:

Actionscript:
  1. function myFunction (myParam1:String, myParam2:Boolean) :Void
  2. {
  3.     if(myParam2)
  4.     {
  5.         trace(myParam1);
  6.     }
  7. }

Notice the ":Void" after defining the function. This specifies that there is no return from this function. However if you wished to return something you could simply put the type of data you wish to return, such as Boolean, String, Number, Array and so on.

Strict typing is also the ideal coding to debug, for example lets take something like this:

Actionscript:
  1. var myNumber:Number = "Blah Blah";
  2. trace(myNumber);

This will throw an error, however if you didnt make it strict then it would let u pass with setting a variable that should be a number, to a string value. This is helpful and preventive and applies to any use of strict data typing.

Along with strict data typing comes other good practices of code, such as initializing variables on the proper level, BEFORE using them. You don't have to set it to anything, infact you could just put the following, just to set its proper scope:

Actionscript:
  1. var myVar:String;

After getting into the habbit of strict data typing, I find myself getting picky with code that isnt using it, mainly because I see the code is not at it's full potential.

Strict data typing is most useful in classes, or I should say it is required with classes...well in most scenario's, but that is another post, on another day :).

I encourage all actionscript coder's to make this their new habbit of coding, you will be happy you did.

Comments (3)

Flash & SEO, Good or Bad?

More and more people have been asking me questions about flash, and if it is SEO friendly.

Well the obvious answer is really in the question if you think about it: YES it is seo-friendly, in the sense that it does NOT harm any seo efforts on a website. However the goal of achieving a successful website in terms of seo and still use flash, well the things to consider and keep in mind are no special case for flash than it is for any other web application! CSS, your html coding, what you are doing server-side that might affect the html output, a huge list of other things as well! But in this scenario, lets stick to the topic of why flash will not harm your seo.

Google I believe currently can index a swf file, and per my tests only to a certain extent and the weight value granted to what is indexed in a swf file is no where near the importance of a standard html document. However in Flash 8 there is a whole API built that search engines will be building compatibility for. And I quote from Flash 8's feature list:

SWF Metadata
A new metadata property for the SWF file format improves searchability of SWF files by Internet search engines. Now Flash authors can add a title and description to a SWF file, allowing search engines to more accurately reflect the content represented by the SWF file.

Although this is huge advance for flash and SEO, this by no means gives flash the same SEO power as would a html document. But what is my point you may be asking?:) well! My point is (get ready for it, drum roll please?) don't put your textual content embedded into a flash movie. At least not yet anyways, we will see when this new flash 8 search engine api has been fully implemented into the major search engines. Until then, it is simple really - just continue naturally developing your web pages, web applications or whatever the case may be! That is the largest mistake any seo can make; thinking of unnatural methods in attempt to gain ranking in the search engines.

My main point here, is that flash does not under any circumstances harm your website for SEO, unless otherwise you are using flash to violate search engine guidlines (like using getURL to perform sneaky redirects for doorway pages, etc). But then again this refers to my above statement about how you should think naturally not sneakily! Don't fix something if it isnt broken, don't assume it's broken just be naturally observant.

An ideal website that uses flash and is seo-friendly, is one that has all of their textual content in html form and has all their promotional and attractive "portions" in flash, like a flash header for example!

A perfect scenario of a great time to use flash for your website is if the textual content of the website doesn't matter! Or at least does not matter to you, but then again if that is the case, then you are probably not reading this right now!

I should also mention that Google has some flash seo suggestions that I personally would only take if I were in the position that the flash website was already built. But none the less, it still helps to perform the task at hand; making flash seo-friendly.

I started in flash, that is my grounding and everything else that I have grown into came after that, even SEO. So as long as it is fact, I will be defending Flash on all acusations that flash is not seo friendly!

Comments (8)

« Previous entries · Next entries »