Automatically set focus to flash movie

Usually flash movies needs to be clicked to make them gain focus before they can be interacted via keyboard. If you want to gain automagically when your movie starts, you can do it via javascript. It's just a matter of calling the focus() method on the right html element at the right time.
You can find here an example made using SWFObject. The setFocusOnFlash() is used as a callback by the embedSWF() method. An event object is sent along the function callback, holding the operation status, the html element id and a direct reference to the html element.
Notes:

  • make sure to use wmode opaque or transparent, otherwise this trick won't work on chrome and safari

  • make sure to set the tabIndex property on the html element you're going to focus, otherwise it won't be in the "tabbing list" and some browsers (chrome and safari) will ignore the focus() call

  • on firefox (both 3.6 and 4.0) the callback is fired a bit too early, hence the need for a small timer before the actual call


<script type="text/javascript">
function setFocusOnFlash(e) {
setTimeout(function() {
if (e.success) {
e.ref.tabIndex = 0;
e.ref.focus();
}
},125);
}
var swfVersionStr = "10.0.0";
var xiSwfUrlStr = "playerProductInstall.swf";
var flashvars = {};
var params = {};
params.quality = "high";
params.bgcolor = "#000000";
params.allowscriptaccess = "sameDomain";
params.allowfullscreen = "true";
params.wmode = "opaque";
var attributes = {};
attributes.id = "MyMovie";
attributes.name = "MyMovie";
attributes.align = "middle";
swfobject.embedSWF(
"MyMovie.swf", "flashContent",
"300", "200",
swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes, setFocusOnFlash);
swfobject.createCSS("#flashContent", "display:block;text-align:left;");
</script>

Call AMF RPC methods from Flash

If you would like consume some services through RemoteObject from Flash in the same fashion you do in Flex, you will need to follow these step:
  • Add the rpc.swc and framework.swc from your {FLEX_HOME}/frameworks/libs to you ptoject or .fla classpath

  • Optional: If you are compiling an Actionscript Project in Flash Builder you'll also need the resource bundles for those swcs. So add also the rpc_rb.swc and framework_rb.swc from {FLEX_HOME}/frameworks/locale to your classpath.

  • Look at the code below, the initializeRPC and registerClasses methods are what you need to make things work.


You are now ready to call remote methods via amf like this simple example.
Notes:
You will bring nearly 100kb of footprint to your swf due to dependencies from the flex framework. You reduce that footprint by registering a custom collection class instead of the ArrayCollection. The only requirement is that your collection class implements the IExternalizable interface.
import mx.collections.ArrayCollection;
import mx.core.mx_internal;
import mx.logging.Log;
import mx.logging.targets.TraceTarget;
import mx.messaging.ChannelSet;
import mx.messaging.channels.AMFChannel;
import mx.messaging.config.ConfigMap;
import mx.messaging.config.LoaderConfig;
import mx.messaging.messages.AcknowledgeMessage;
import mx.messaging.messages.AcknowledgeMessageExt;
import mx.messaging.messages.CommandMessage;
import mx.messaging.messages.CommandMessageExt;
import mx.messaging.messages.ErrorMessage;
import mx.messaging.messages.RemotingMessage;
import mx.rpc.AbstractOperation;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.remoting.RemoteObject;
import mx.utils.ObjectProxy;

use namespace mx_internal;

const ID:String = "my-amf";
const ENDPOINT:String = "http://your.domain/amf/gateway";
const DEFAULT_SOURCE:String = "your.service";
const DEFAULT_SOURCE:String = "your.service";

var remoteObject:RemoteObject;

/**
* This initializes the rpc library.
* After this you should see the requests going through.
* Note: LoaderConfig won't show up in the code hints, so you have to write down the import manually.
*/
function initializeRPC():void {

LoaderConfig.mx_internal::_url = loaderInfo.url;
LoaderConfig.mx_internal::_parameters = loaderInfo.parameters;
}

/**
* We register a bunch of class aliases that are needed by the rpc methods.
* The list *may be* incomplete, if you get some TypeCoertion error try registering that class.
*/
function registerClasses():void {

registerClassAlias("flex.messaging.messages.ErrorMessage", ErrorMessage);
registerClassAlias("flex.messaging.messages.CommandMessage", CommandMessage);
registerClassAlias("flex.messaging.messages.RemotingMessage", RemotingMessage);
registerClassAlias("flex.messaging.messages.AcknowledgeMessage", AcknowledgeMessage);
registerClassAlias("DSC", CommandMessageExt);
registerClassAlias("DSK", AcknowledgeMessageExt);
registerClassAlias("flex.messaging.config.ConfigMap", ConfigMap);
registerClassAlias("flex.messaging.io.ObjectProxy", ObjectProxy);
registerClassAlias("flex.messaging.io.ArrayCollection", ArrayCollection);
}

/**
* Prepare the RemoteObject, creating the appropriate AMF channel
* and setting up the default event handlers.
*/
function prepareDefaultRemoteObject():void {

var channel:AMFChannel = new AMFChannel(ID, ENDPOINT);

var channelSet:ChannelSet = new ChannelSet();
channelSet.addChannel(channel);

remoteObject = new RemoteObject();
remoteObject.source = DEFAULT_SOURCE;
remoteObject.destination = DEFAULT_DESTINATION;
remoteObject.channelSet = channelSet;
remoteObject.addEventListener(FaultEvent.FAULT, onDefaultServiceFault);
remoteObject.addEventListener(ResultEvent.RESULT, onDefaultServiceResult);
}

/**
* Create and execute the remote method.
*/
function makeAnonymousRemoteCall():void {

var operation:AbstractOperation = ro.getOperation("getProduct");
operation.send();
}


/**
* Handles faulty replies from the remote methods.
*/
function onDefaultServiceFault(event:FaultEvent):void {

trace(event.fault.faultDetail);
}

/**
* Handles successful replies from the remote methods.
*/
function onDefaultServiceResult(event:ResultEvent):void {

trace(event.result.toString());
}

// All RPC classes use the Flex logging API so enabling it in the Flash project could be helpful.
Log.addTarget(new TraceTarget());

initializeRPC();
registerClasses();

prepareDefaultRemoteObject();
makeAnonymousRemoteCall();

Circular preloader

How to create a circular animation in As3, useful for preloaders
(tested on Flash Cs3/4 but it should works fine in Flex too)
var angle:Number = 0
var centerX:Number = 50
var centerY:Number = 50;
var radius:Number = 22;
var speed:Number = 0.1

var circle:Shape = new Shape();
addChild(circle)
circle.graphics.beginFill(0x00FF00);
circle.graphics.moveTo(centerX, centerY);

function onEnterFrame(e:Event) {

if (angle > 2 * Math.PI)
this.removeEventListener(Event.ENTER_FRAME, onEnterFrame)

trace("angle", angle)
circle.graphics.lineTo(centerX + Math.cos(angle) * radius,
centerY + Math.sin(angle) * radius);

angle += speed;
}
this.addEventListener(Event.ENTER_FRAME, onEnterFrame)

How to set a global component style in Flash / AS3

Use StyleManager class and setComponentStyle method to set global styles
Following code sets color, size and textPadding properties to each Button Component used in your own Flash Application.
import fl.managers.StyleManager;
import fl.controls.Button

// Set a global textFormat for every Button Component
var tf:TextFormat= new TextFormat();
tf.color = 0x0000FF;
tf.size = 16;
StyleManager.setComponentStyle(Button, "textFormat", tf);

// Set a global style property for every Button Component
var styleProperty:String = "textPadding";
var value:Number = 30;
StyleManager.setComponentStyle(Button,styleProperty,value);

USING TWEENSY : particle runtime effects with Actionscript 3 and FLASH CS4

In the market are existing a lot of Tween libraries to help Flash/Flex developers to build cool actionscript animation making their life easier, like TweenLite/ TweenMaxor Caurina Tweener.
These libraries included cool stuff not provided from the default AS3 tween class like colors animation, animated drop, blur, shadow effect and much more.
So, in this post, i want to show you another tween engine, Tweensy, that provide a lot of cool bitmap and particle effects like smoke, fire and other 'magical'ÃÆââ‚Â
¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€ Ã¢âÃÂ
¢Ã¢â€šÂ¬Ã…¡Ã‚¬Ã¢â€žÂ¢ÃƒÆ’Æâ€ââ
€žÂ¢ÃƒÆ’ƒÂ¢Ã¢â€šÂ¬Ã‚ ÃƒÃ
‚¢Ã¢â€šÂ¬ÃÂ
¢Ã¢â‚¬Å¾Ã‚¢ÃƒÆâ€
™Ãƒâ€ Ã¢â‚¬â„¢ÃƒÆ’Ãâ€
šÃ‚¢ÃƒÂ¢Ã¢â‚¬Å¡Ã‚¬Ãââ‚Â
¬Ã…¡Ãƒâ€šÃ‚ ÃƒÆ’ƒÂ
¢Ã¢âââ€Ã
…¡Ã‚¬Ã…¡Ã‚¬ÃÃ
ƒâ€šÃ‚¢ÃƒÂ¢Ã¢â€šÂ¬Ã…¾ÃÃÂ
¢Ã¢â€šÂ¬Ã…¡Ãƒâ€šÃ‚¢ÃƒÆ’Æ’Ãâââ€
šÂ¬Ã‚ ÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€ Ã
ƒÆ’ƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆâ€
™Ãƒâ€ Ã¢â‚¬â„¢ÃƒÆ’‚¢ÃÃ
ƒâ€šÃ‚¢ÃƒÂ¢Ã¢â€šÂ¬Ã…¡ÃÃÂ
¢Ã¢â€šÂ¬Ã…¡Ãƒâ€šÃ‚¬ÃƒÆ’‚ÃâÃ
¢â€šÂ¬Ã…¡Ãƒâ€šÃ‚ ÃƒÆ’Æ’Ãââ‚Â
¬Ã‚ ÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€šÃÆ
’ƒâ€šÃ‚¢ÃƒÆ’ÃÆâ€
™ÃƒÂ¢Ã¢â€šÂ¬Ã…¡Ãƒâ€šÃ‚¢ÃƒÆ’¢âÃ
¢â‚¬Å¡Ã‚¬Ã…¡ÃÆâ€
™Ãƒâ€ Ã¢â‚¬â„¢ÃƒÆ’¢â‚¬Å¡Ãƒâ€šÃ‚¬ÃÃ
ƒâ€ Ã¢â‚¬â„¢ÃƒÆ’†â€™Ãƒâ€šÃ‚¢ÃÆÃ
¢â‚¬â„¢ÃƒÆ’‚¢Ã¢â€šÂ¬ÃÆ
’ƒâ€¦Ã‚¾Ãƒâ€šÃÃ
†â€™ÃƒÂ¢Ã¢â€šÂ¬Ã…¡Ãƒâ€šÃ‚¢ÃƒÆ’Æ’ÃÃ
ƒÂ¢Ã¢â€šÂ¬Ã‚ ÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€Ãâ
€šÃ‚ ÃƒÆ’¢â‚¬â„¢ÃÃâ
€ Ã¢â‚¬â„¢ÃƒÆ’†â€™ÃƒÂ¢Ã¢â€šÂ¬Ã‚
 ÃƒÂ¢Ã¢â€ÅÂÂ
¡ÃƒÆ’‚¬Ã¢â€žÂ¢Ã
ƒÆ’Æâ€â„
¢ÃƒÆ’‚ÂÂÂÂ
¢ÃƒÆ’ĮբÃÆ
’ƒÆ’¢â‚Â
¬Ã…¡Ãâ€Ã
…¡Ãƒâ€šÃ‚¬ÃƒÆâ€â„
¢ÃƒÆ’¢â‚¬Å¡ÃƒÃÂ
¢Ã¢â€šÂ¬Ã…¡Ãƒâ€šÃ‚ ÃƒÃââ‚
¬Â ÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€ Ã¢â‚¬â„¢ÃƒÆââ
‚¬â„¢ÃƒÆ’¢â‚¬Â ÃƒÂ¢Ã¢â€šÂ¬Ã¢âÃ
¢â€šÂ¬Ã…¾Ã‚¢ÃƒÆ’ĉââ
€šÂ¬Ã…¡Ãƒâ€šÃÆ
’‚¢ÃƒÃÃ
¢â‚¬Â ÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€Ãâ€
¦Ã‚¡ÃƒÆ’‚¢Ãƒ
¢âÃÂ
¢Ã¢â€šÂ¬Ã…¡Ã‚¬
Å¡Ã
ƒÆ’ƒÆ’â€Ã
ƒÆ’…¡Ãƒâ€šÃ‚ÃÆ
’‚¬ÃƒÆ’Æâ
€™Ãƒâ€šÃâââ
€šÂ¬Ã…¡Ãƒâ€šÃ‚¢ÃƒÆ’Æ’Ãâ€Ã
…¡Ãƒâ€šÃ‚¢ÃƒÆ’¢ââââ‚
¬Å¡Ã‚¬Ã…¡Ã‚¬ÃÆâ€â„
¢ÃƒÆ’¢â‚¬Â¦Ãƒâ€šÃ‚¾ÃƒÃ
ƒÆ’†â€™ÃƒÂ¢Ã¢â€šÂ¬Ã…¡Ã
ƒÆ’ƒâ€šÃ‚¢Ã
ƒÆ’Įâ€ââ
€žÂ¢ÃƒÆ’ƒâ€ Ã¢ââ€
šÂ¬Ã¢â€žÂ¢ÃƒÆ’Æ’Ã
ƒÂ¢Ã¢â€šÂ¬Ã‚ ÃƒÂÃ
ƒâ€šÃ‚¢ÃƒÆ’¢â€šÂ¬Ã¢Ã
¢â‚¬Å¾Ã‚¢ÃƒÆ’Ã
ƒÆ’ƒâ€ Ã¢â‚¬â„¢ÃƒÆ’ÂÂÃ
‚¢ÃƒÆ’¢â€šÂ¬Ã‚ÃÆ
’‚ ÃƒÆ’ÂÃââ‚
¬Å¡Ãƒâ€šÃ‚¢ÃƒÆ’ƒÂ¢Ã¢â‚Â
¬Ã…¡Ã‚¬ÃÃâ€Å
¡Ãƒâ€šÃ‚¢ÃƒÆ’¢â‚¬Å¾Ãâ€
šÃ‚¢ÃƒÆ’ÆÃ
ƒÆ’¢â‚¬â„¢ÃƒÆ’†Ã
¢â‚¬â„¢ÃƒÃÃ
¢â‚¬Â ÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€šÃ‚¢ÃƒÃâ€Å
¡Ãƒâ€šÃ‚¢ÃƒÆ’¢â‚¬Å¡Ãâ€
šÃ‚¬Ãƒâ€¦Ãâ€Å
¡Ãƒâ€šÃ‚¡ÃƒÆ’ĮÃÆ
’¢â‚¬â„¢ÃƒÆ’¢âÃÃ
‚¢Ã¢â€šÂ¬Ã…¡Ã‚¬Ã…¡Ã
ƒÆ’â€Ãââ‚
¬Â¦Ãƒâ€šÃ‚¡ÃƒÆ’ƒâ€šÃ‚Ãâ€Å
¡Ãƒâ€šÃ‚¢ÃƒÆ’ƒÆ’Æââââ
‚¬Å¡Ã‚¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€ Ã¢ÃÃ
‚¢Ã¢â‚¬Å¡Ã‚¬Ã¢â€žÂ¢ÃƒÆ’Æâââ€
šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒÂ¢Ã¢â€šÂ¬Ã‚ ÃÆâ€â
„¢ÃƒÆ’‚¢Ã¢â€šÂ¬ÃÆâ€
™Ãƒâ€šÃ‚¢ÃƒÂ¢Ã¢â€šÂ¬Ã…¾Ã‚¢ÃƒÆâÃ
¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€ Ã¢â‚¬â„¢ÃƒÆ’ÃÆ
’‚¢Ã¢â€šÂ¬Ãâ
€¦Ã‚¡ÃƒÆ’â
€šÃâ€Ãâ
€¦Ã‚¡ÃƒÆ’‚¢ÃÆâ€â„Â
¢ÃƒÆ’ƒâ€ Ã¢â‚¬â„¢ÃƒÆ’ââââ
‚¬Å¡Ã‚¬Ã‚ ÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢Ã
ƒÆ’ƒÆ’ƒâ€
šÃ‚ÂÃ
ƒâ€šÃ‚¢ÃƒÆ’ĮÃÂÂ
¢ÃƒÂ¢Ã¢â‚¬Å¡Ã‚¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€šÃââ
‚¬Å¡Ãƒâ€šÃ‚¢ÃƒÆ’Æ’Ãâ€
šÃ‚¢ÃƒÂ¢Ã¢ââââ€
šÂ¬Ã…¡Ã‚¬Ã…¡Ã‚¬ÃÆâ€â
„¢ÃƒÆ’¢â‚¬Â¦Ãƒâ€šÃ‚¡Ãƒ
ƒâ€šÃ
ƒÆ’ƒÆ’‚¬ÃÆ
’ƒÆ’Įâ€âÃ
¢â‚¬Å¾Ã‚¢ÃƒÆ’ƒÂ¢Ã¢â€ÅÂ
¡Ãƒâ€šÃ‚¬Ãƒâ€šÃ‚¦ÃƒÆÃ
ƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒÂ¢Ã¢â€šÂ¬Ã…¡ÃÃâ€
 Ã¢â‚¬â„¢ÃƒÆ’¢â‚¬Å¡Ãƒâ€šÃ‚¡ÃÆÃ
¢â‚¬â„¢ÃƒÆ’†â€™Ãƒâ€ Ã¢â‚¬â„¢Ã
ƒÆ’ƒâ€ Ã¢â‚ÂÂ
¬ÃƒÂ¢Ã¢â‚¬Å¾Ã‚¢ÃƒÆ’Æ’Ãââ
‚¬Å¡Ãƒâ€šÃ‚¢ÃƒÆ’¢ââÃÂ
¢Ã¢â€šÂ¬Ã…¡Ã‚¬Ã…¡Ã‚¬ÃÆÃ
¢â‚¬â„¢ÃƒÆ’¢â‚¬Â¦Ãƒâ€šÃ‚¡ÃÆââ
‚¬â„¢ÃƒÆ’†â€™Ãƒâ€ Ã¢â‚¬â„¢Ã
ƒÆ’¢â‚ÂÃ
ƒâ€šÃ‚¬ÃƒÆ’…¡ÃÆâ€ââ€
žÂ¢ÃƒÆ’ƒÂ¢Ã¢â€šÂ¬Ã…¡ÃƒÃÃ
‚¢Ã¢â€šÂ¬Ã…¡Ãƒâ€šÃ‚¬ÃƒÃââ
‚¬Â ÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€ Ã¢â‚¬â„¢ÃƒÆâ
€™ÃƒÂ¢Ã¢â€šÂ¬Ã‚ ÃƒÂ¢Ã¢â€šÂ¬Ã¢â
€žÂ¢ÃƒÆ’ĉâÃÂ
¢Ã¢â€šÂ¬Ã…¡Ã‚¬Ã‚ ÃƒÂ¢ÃÂÂÂ
¢ÃƒÆ’¢â‚¬Å¡Ã‚¬Ã¢â€ÅÃ
‚¾Ãƒâ€šÃ‚¢ÃƒÆ’ĮÃ
ƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢ÃƒÆ’ƒâ€šÃÃ
ƒÂ¢Ã¢â€šÂ¬Ã…¡Ãƒâ€šÃ‚¢ÃƒÆ’Æ’Ãââ
‚¬Å¡Ãƒâ€šÃ‚¢ÃƒÆ’¢ââÃÂ
¢Ã¢â‚¬Å¡Ã‚¬Ã…¡Ã‚¬Ã…¡ÃÆÃ
¢â‚¬â„¢ÃƒÆ’¢â‚¬Å¡Ãƒâ€šÃ‚¬ÃÆââ
‚¬â„¢ÃƒÆ’†â€™ÃƒÂ¢Ã¢â€šÂ¬Ã…Â
¡ÃƒÆ’‚ÂÂÂÂ
¦ÃƒÆ’ƒÆ’Æâ€
™Ãƒâ€ Ã¢ââÃ
¢â€šÂ¬Ã…¡Ã‚¬Ã¢â€žÂ¢ÃƒÆ’Æâ€â„
¢ÃƒÆ’‚¢Ã¢ÃÃâ
€šÃ‚¢ÃƒÂ¢Ã¢â‚¬Å¡Ã‚¬Ã…¡Ã‚ÂÂÂ
¬ÃƒÆ’ƒâ€¦Ã‚¡
ÃÆâ€Ã
¢â€žÂ¢ÃƒÆ’ƒÂ¢Ã¢â€Ãâ€
¦Ã‚¡Ãƒâ€šÃ‚¬Ãƒâ€¦Ã‚¡ÃƒÃâ€
 Ã¢â‚¬â„¢ÃƒÆ’¢â‚¬Å¡ÃÃ
ƒâ€ Ã¢â‚¬â„¢ÃƒÆ’¢â‚¬Å¡Ãƒâ€šÃ‚¡ stuff ;)



See the final result


SOURCE CODE:
To compile your flash file you'll need to download the Flash Cs4 source code (below) and get the right library assets.
Furthermore, you won't find the Tweensy API inside the zip file because you should download the last version from http://code.google.com/p/tweensy/.
Tweensy is still in beta and to create this sample(getting much more than inspiration from the provided demo) I used an old library version, so when you'll download the new one you could get some compiler errors.
package {
import flash.display.*;
import flash.events.*;
import flash.filters.BlurFilter;
import flash.geom.ColorTransform;
import flash.text.TextField;
import flash.utils.getDefinitionByName;

import com.flashdynamix.motion.*;
import com.flashdynamix.motion.effects.*;
import com.flashdynamix.motion.extras.Emitter;
import com.flashdynamix.motion.layers.BitmapLayer;


public class MenuEmitter extends Sprite {


public var menuButton:MovieClip;

private var emittor : Emitter;
private var layer : BitmapLayer;

private var ct : ColorTransform;
private var bf : BlurFilter;

private var tx : Number;
private var ty : Number;

public function MenuEmitter() {


// Create a Bitmap Layer where we'll draw the Emitter and apply some effects
layer = new BitmapLayer(900, 400);
bf = new BlurFilter(10, 10, 2);
layer.add(new ColorEffect(new ColorTransform(1, 1, 1, 0.9)));
layer.add(new FilterEffect(bf));

// Set quality to LOW to get better performance
stage.quality = StageQuality.LOW;


// The Emitter MovieClip "BluePrint"
var Box : Class = getDefinitionByName("Box") as Class;

// Emitter Creation
ct = new ColorTransform(1, 1, 1, 1, -115, -30, 70);
emittor = new Emitter(Box, null, 2, 1, "0, 360", "1, 110", 1, BlendMode.ADD);
emittor.transform.colorTransform = ct;
emittor.endColor = {redOffset:255, greenOffset:-10, blueOffset:-270, alphaOffset:-255};

// We can't build the emitter on 0,0 because it will be cutted on the top and on the left side
emittor.x = 150
emittor.y = 150

// Display on screen
layer.draw(emittor.holder);
menuButton.addChildAt(layer,0);

// Stop emitter at startTime
emittor.stop()

// RollOver / RollOut on button
menuButton.gfx.buttonMode = true;
menuButton.gfx.addEventListener(MouseEvent.ROLL_OVER, onMenuRollOver)
menuButton.gfx.addEventListener(MouseEvent.ROLL_OUT, onMenuRollOut)

// ENTER_FRAME event
// We'll update the emittor properties to generate random
addEventListener(Event.ENTER_FRAME, update)

}

/**
* Update emittor rotation properties to have different rotation for each particle
*/
private function update(e : Event) : void {
emittor.rotation += 20;
}

/**
* At Button rollOver start the emitter
*/
private function onMenuRollOver(e : MouseEvent) : void {
emittor.start()
}

/**
* At Button rollOut stop the emitter
*/
private function onMenuRollOut(e : MouseEvent) : void {
emittor.stop()
}





}
}

FullScreen in Flash CS4 / AS3

If you want enable fullscreen modality in Flash CS 4 and ActionScript 3.0 you need to following steps:
1) Modify the displayState property to StageDisplayState.FULL_SCREEN costant to enable it, and to StageDisplayState.NORMAL to come back to 'normal' modality
2) Enable the 'allowfullscreen' attribute in your html code (see below)

...
<param name="allowFullScreen" value="true" />...
and
<embed src="index.swf" allowfullscreen="true"></embed>


HOW CREATE A FULLSCREEN BUTTON in AS3

The script is quite simple and is fullCommented.
You just need to create a Flash CS3/4 ActionScript 3.0 file and link the document Class to the FullScreenMain.as class.
We add to the display list a Button Flash Component, so we need to import its assets to the .fla dragging it from the Component panel to the library.
package {

import flash.display.MovieClip;
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.display.StageDisplayState

import fl.controls.Button;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.FullScreenEvent;


public class FullScreenMain extends MovieClip {

// The FullScreen Button
private var fullScreen_btn:Button;

// Save the fullScreen status
private var fullScreenStatus:Boolean;


/**
* Constructor
*/
public function FullScreenMain() {

// Create the FullScreen Button (add to the .fla library the button component assets)
fullScreen_btn = new Button();
fullScreen_btn.label = "Enable FULL_SCREEN";
fullScreen_btn.width = 150;
fullScreen_btn.x = 120;
fullScreen_btn.y = 50;
addChild(fullScreen_btn)


// Set NO_SCALE because we don't want that when fullscreen is enable movieclips are scaled too
var swfStage:Stage = this.stage;
swfStage.scaleMode = StageScaleMode.NO_SCALE;
swfStage.align = StageAlign.TOP_LEFT;

// Registriamo un listener per la modalitÃÆ’Æ’ÃÆââ‚
¬â„¢ÃƒÆ’†â€™ÃƒÂ¢Ã¢â€šÂ¬ ââ‚Ãââ‚
¬Å¡Ãƒâ€šÃ‚¬ÃƒÆ’¢â€žÂ¢ FULLSCREEN:

// Listener for FullScreen Button
fullScreen_btn.addEventListener(MouseEvent.CLICK, changefullScreenStatus)


// Listener for FullScreen event. It's invoked every time the 'displayState' property change
fullScreen_btn.stage.addEventListener(FullScreenEvent.FULL_SCREEN, fullScreenRedraw);


}





/**
* Check the fullScreenStatus and Enabled / Disable the FullScreen
*/
private function changefullScreenStatus(e:MouseEvent):void
{
// Disable FullScreen if enabled, and viceversa
if(fullScreenStatus)
fullScreen_btn.stage.displayState = StageDisplayState.NORMAL;
else
fullScreen_btn.stage.displayState = StageDisplayState.FULL_SCREEN;


}

/*
* Invoked at every 'displayState' property change
*/
function fullScreenRedraw(event:FullScreenEvent):void
{
// Check if fullScreen is enabled and uptades properties
if (event.fullScreen)
{
fullScreen_btn.label = "Disable FULL_SCREEN";
fullScreenStatus = true;
}
else
{
fullScreen_btn.label = "Enable FULL_SCREEN";
fullScreenStatus = false;
}

}


}
}

Using 3D and Video with Caurina Tween in Flash Cs4

In this sample, full-commented, we'll use the FlashPlayer 10 3D features to display a list of Video Thumbnails enabling the Mouse Click Event to enlarge them changing their z and rotationY properties.
We'll use Caurina Tween to perform 3d animations, so download them and copy the caurina package in your project folder before test this sample (they are not included inside the source files)
IMPORTANT NOTE: 3D topic is really complex! This is only an introduction to this world and this VideoGallery needs a lot of improvements to be used in a real scenario.
To this URL the flash file with the final result (click on VideoThumbs to display 3D animations):


CREATE THE FLASH FILE

First of all we create a new Flash ActionScript 3.0 document (setting Flash Player 10 in the Publish Setting menu).
Create a new MovieClip with an FLVPlayBack component inside (with istance name videoFLB) and link the movieclip to the VideoThumb.as class.
See image below


// FLASH DOCUMENT CLASS
package {

import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.MouseEvent;
import caurina.transitions.*
import flash.display.DisplayObject;

public class VideoMain extends Sprite
{

// Horizontal Gap between Video Thumbs
private const HORIZONTAL_GAP:uint = 50;

// Total of VideoThumbs to show
private const VIDEO_TOTAL:uint = 6;

// Thumbnails original Y position
private const Y_POS:uint = 125;

// Thumbnails original Z position
private const Z_POS:uint = 550;



public function VideoMain()
{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;


// Create video thumbs
for (var i:uint = 0; i < VIDEO_TOTAL; i++) {

// Create a new VideoThumb istance
var thumb:VideoThumb = new VideoThumb();

// Save original Index VideoThumb
thumb.originalIndex = i;

// Set Thumb Position (x, y, z)
thumb.x = thumb.originalX = HORIZONTAL_GAP * i
thumb.y = Y_POS
thumb.z = Z_POS;

// Set Thumb Rotation
thumb.rotationY = -90;

thumb.addEventListener(MouseEvent.CLICK, onClick)
thumb.buttonMode = true;

addChild(thumb)
}
}



/**
* Click Video MovieClip
*/
private function onClick(event:MouseEvent):void
{
// If clicked videoThumb is already opened
if(event.currentTarget.isOpened) {

// Back to the original position
Tweener.addTween(event.currentTarget, {
rotationY: -90 ,
x: event.currentTarget.originalX,
y: Y_POS,
z: Z_POS,
time:0.5,
transition:"easeInOutSine",
onComplete: event.currentTarget.videoFLB.stop()});


// Set depth to the original Position
this.swapChildrenAt(getChildIndex(event.currentTarget as DisplayObject), event.currentTarget.originalIndex)



} else {

// Enlarge Video and PLay it when animation is completed
Tweener.addTween(event.currentTarget, {
rotationY: 0 ,
x: 230,
y: 200,
z: 0,
rotationY: 0,
time:0.5,
transition:"easeInOutSine",
onComplete: event.currentTarget.videoFLB.play()});

// Bring to Front
this.swapChildrenAt(event.currentTarget.originalIndex, this.numChildren -1 )

}


// Change isOpened Status (to always know if a thumb is opened )
event.currentTarget.isOpened = !event.currentTarget.isOpened;

}


}
}





// VideoThumb.as Class
package {


import flash.display.MovieClip;


public class VideoThumb extends MovieClip
{

private var _originalIndex:Number ;
private var _originalX:Number ;
private var _isOpened:Boolean = false;


/**
* Constructor
*/
public function VideoThumb(){}


/**
* Original Index position (usefull to know the Thumb depth)
*/
public function set originalIndex(val:Number):void {
_originalIndex = val;
}

public function get originalX():Number {
return _originalX ;
}




/**
* Original x position (usefull to position Thumb to the original Position)
*/
public function set originalX(val:Number):void {
_originalX = val;
}


public function get originalIndex():Number {
return _originalIndex ;
}




/**
* If the VideoThumb is opened or not
*/
public function set isOpened(val:Boolean):void {
_isOpened = val;
}


public function get isOpened():Boolean {
return _isOpened ;
}


}
}