THEACTIONSCRIPTER.COM
THEACTIONSCRIPTER.COM

AS3 MOUSE_OVER VS. ROLL_OVER

A lot of Flash developers I come across have an issue with mouse actions when MovieClips are embedded inside other MovieClips.  AS3 has multiple ways to handle embedded mouse actions within MovieClips.  The two main ways are MOUSE_OVER and ROLL_OVER.  They sound the same but have slight differences. 

MOUSE_OVER

MOUSE_OVER will be triggered when you first rollover the main MovieClip.  It will also be triggered every time you rollover any MovieClip inside the main MovieClip.  This can get dangerous when you have additional buttons inside the main MovieClip with MOUSE_OUT functionality.  Be careful because your MOUSE_OVER functionality will be called multiple times.

* If you set the main MovieClip to mouseChildren = false, it will prevent the MOUSE_OVER action being triggered when you mouse over any embedded MovieClip.  Be careful though because you will not be able to add any mouse actions to those embedded MovieClips.

ROLL_OVER

ROLL_OVER will be triggered when you first rollover the main MovieClip.  It will not be triggered again until you roll out of the main MovieClip and back over it.  You can rollover as many embedded MovieClips as you want without it being triggered multiple times.  ROLL_OVER is best for when you have embedded MovieClips with mouse actions.



 del.icio.us  Stumbleupon  Technorati  Digg 

Best Practices for Flash AS3

Take a look at this article I wrote on Bukisa.  In this article you will read about best practices for developing a website in Flash.  Learn different tricks to make your site perform better, load faster, and maintain easier.

http://www.bukisa.com/articles/137106_flash-and-actionscript-3-best-practices-to-improve-performance

 del.icio.us  Stumbleupon  Technorati  Digg 

Align Text with ActionScript 3 - Center AS3 Text

Imports needed to align your Flash text in AS3.

import flash.text.TextField;
import flash.text.TextFieldAutoSize;
Alignments you can do with your text:
TextFieldAutoSize.LEFT
TextFieldAutoSize.RIGHT
TextFieldAutoSize.CENTER
TextFieldAutoSize.NONE
Syntax needed to align your dynamic text in AS3.
_textField.autoSize = TextFieldAutoSize.LEFT;
_textField.text = "Hello World!  This is my text.";
Make sure that you assign the autoSize before you set the text. If you set the text first the alignment will not work correclty.

 del.icio.us  Stumbleupon  Technorati  Digg 

Disable the right click menu in Flash AS3

Gain control of your Flash Movie. Do not let users right click and zoom in on it if you do not want them to. Take a look below at the AS3 code to prevent users from right clicking on your Flash experience.

stage.showDefaultContextMenu = false;

Example Flash Movie with Right Click Functionality Disabled.

 del.icio.us  Stumbleupon  Technorati  Digg 

Error #2044: Unhandled ioError: With .DAE file in Papervision

I got the classic  #2044 Error today when I moved a project I have been working on from local to test environment.  Usually you receive this error because the file doesn't exist.  That wasn't the case for me. 

I am building a papervision project and the file that was causing the #2044 error was the Collida .DAE file.  Since the test environment was IIS, I had to add the .DAE file the the MIME Map.  After I added the .DAE file to the MIME Map I was able to load my Collida .DAE into my PaperVision project.

Add the following code to your Web.config file

<system.webServer>
<staticContent>
<mimeMap fileExtension=".dae" mimeType="application/octet-stream"/>
</staticContent>
</system.webServer>
This is is more common when trying to dynamically load a .flv file on the server.

 del.icio.us  Stumbleupon  Technorati  Digg 

AS3 Tint MovieClip

Here is how to tint a MovieClip in Flash via AS3.

var c:Color = new Color();                   //Create a color object
c.setTint(Math.random() * 0xffffff, 1);      //Set tint to a random color
mcObject.transform.colorTransform = c;      //Apply tint to your MovieClip

Below is an example of randomly changing a MovieClip's tint with ActionScript 3




Source Code

 del.icio.us  Stumbleupon  Technorati  Digg 

Going from ActionScript 3 back to ActionScript 2 isn't fun

I remember when I first made the jump from ActionScript 2 to ActionScript 3.  I wasn't excited about the switch at the time.  I remember always asking myself why did they change this, I can't I do this anymore but after my first project I was happy I made the switch.  AS3 made coding easier.  I write less code in AS3 than I needed to do in AS2 with the exception of getURL.

I've been doing AS3 straight for the past year now.  Every time I have to start a new ActionScript project I always write it in AS3 for obvious reasons.  The challenge is when someone asked me to write a project that had to be done in AS2.  No AS3!  Sure, I thought, no problem. I have been coding for years in ActionScript 2 but wow how quickly I forget the differences.  I felt I had to reteach myself some of the basics.

The project should have only took me 4-6 hours but ended up taking me 8-10 hours.  If I could have wrote it in AS3 it probably would have took me just 2 hours.  Making the jump back seemed more difficult than the jump forward.  Some of the simplest actions I just forgot.  For example, assigning actions to buttons from my class.  It took me a moment to remember that inside the onClick function there is no true reference to the class, so I had to set one before I declared the action.  Simple code like that, which I used to write like clockwork, I just forgot. 

In all the change back was frustrating but kind of funny.  Seems like I need to do some more small AS2 projects on my own to stay sharp but if I have to do anything important I'm writing it in good new ActionScript 3.

 del.icio.us  Stumbleupon  Technorati  Digg 

Omniture Media Tracking in Flash with ActionScript 3

Omniture made media tracking easy with their creation of ActionSource.  You no longer have to make external javascript calls for when the video starts, pauses, plays, ends, etc.  The ActionSource object handles it all.  ActionSource is pretty easy to learn and implement but I do feel Omniture in general and the way they handle their reporting is quite ambiguous.  I'm lucky I just have to do the implementation and not the naming strategy for the tracking.  I am told what props, eVars, events, etc to implement and can easily fire them correctly because of ActionSource.

First you will have to setup your ActionScource object as usual.  Then you can track your videos by using the below function calls. 

When the video get initialized you need to call the media open function.

// mediaName :: Name of video
// mediaLength :: Duration of video
// mediaPlayName :: Name of video player
s.Media.open(mediaName, mediaLength, mediaPlayerName);
When the video play listener is called you need to call the media play function.

s.Media.play(mediaName, mediaOffset);
When a user pauses the video or it stops you need to call the media stop function.
s.Media.stop(mediaName, mediaOffset);
When the video is finished you need to call the media close function.
s.Media.close(mediaName);
The tracking call to Omniture doesn't get fired until the close() function gets called.

Omniture Media Tracking Reports


  • How many people watched a video
  • How long a user stayed on a video
  • What sections of the video a user watched
  • When the user exited the video
  • Videos By Player
  • If you have Omniture tracking throughout your site, you can also know the user flow before and after the video

 del.icio.us  Stumbleupon  Technorati  Digg 

AS3 ? Conditional

You can use the following line of code as a if/else statement.

x = ( a == b ) ? y : z;

if(a==b){
x=y
}
else{
x=z;
}

 del.icio.us  Stumbleupon  Technorati  Digg 

Cool Papervision and Web Cam Video

Take a look at this cool Papervision and Web Cam video I found on YouTube. You can hold your virtual creations in your hands now.

 del.icio.us  Stumbleupon  Technorati  Digg 

Sponsored Links

Recent Entries

  1. HTML5 vs Flash
    Sunday, June 13, 2010
  2. Free Gucci Mane Flash Game
    Monday, January 18, 2010
  3. Flash Input Text Font Issue with Mask
    Tuesday, January 05, 2010
  4. Developing Flash on a Mac vs PC
    Tuesday, December 29, 2009
  5. AS 3 Hide/Show Mouse Cursor
    Tuesday, December 15, 2009
  6. Where Can I Find Omniture Flash ActionSource Documentation?
    Friday, November 06, 2009
  7. Flash Making Extra Omniture Tracking Calls
    Thursday, November 05, 2009
  8. Connecting to a Web Service in Flex
    Wednesday, November 04, 2009
  9. Reading a RSS/Twitter feed with ActionScript 3
    Tuesday, November 03, 2009
  10. AS3 :: Get all Children MovieClips
    Friday, October 09, 2009

My Bukisa Articles


Subscribe


Blog Software