Sometimes you may want to store information on the clients machine. You can do this using a Flash Shared Object, this is basically a Flash Cookie. A Flash Cookie is actually a little better than a normal cookie. Flash Cookies are a little more secure and cannot be deleted like your browser's normal cookies are. Very few users know how to delete them, which is pretty cool for us Flash Developers.
Here is how you set a SharedObject in ActionScript 3:
var __so:SharedObject = SharedObject.getLocal("theactionscripter");
__so.data.favoriteWebsite = "http://www.theactionscripter.com";
__so.data.userId = "123";
__so.flush(); //Immediately writes a locally persistent shared object to a local file. var __so:SharedObject = SharedObject.getLocal("theactionscripter");
trace(__so.data.favoriteWebsite ); //http://www.theactionscripter.com Here is how you clear a SharedObject in ActionScript 3:
var __so:SharedObject = SharedObject.getLocal("theactionscripter");
__so.clear(); What is so special about it, is how easy it is to learn and use. When you download the TweenMax framework you will receive a swf that you can demo any of the animations and at the bottom of the demo the code will be written for you. What could be easier than that? Nothing. This is why I'm becoming lazy.
import gs.TweenMax;
TweenMax.to(mc, 1, {x:46, y:43});If you need to tween multiple items all you have to do is set up a tween for each item, add them to an array and set them to the TweenGroup class. You can even squence your tweens in any order, add delays between each of them and more.TweenGroup(tweens:Array, DefaultTweenClass:Class, align:String, stagger:Number)Or if you want to apply the same tween to the a number of items you can do the following:TweenGroup.allTo([mc1, mc2, mc3, mc4, mc5], 1, {y:"100", alpha:0, stagger:0.2}); TweenMax is a great framework and worth taking a look at. It makes coding a lot faster and I haven't had any performance issue I could blame on the framework. It is worth your time to check it out (http://blog.greensock.com).
stop();
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("mySWF.swf"));
function loop(e: progressEvent):void{
var perc:Number = Math.round(e.bytesLoaded*100 / e.bytesTotal);
mcLoader.txtPercent.text = perc + "%";
}
function done(e:Event):void{
l.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.removeEventListener(Event.COMPLETE, done);
removeChild(mcLoader);
addChild(l);
}
The only thing to be aware of is how to access you FlashVars and that the swf for the preloading is now your stage.var _url:URLRequest = new URLRequest("http://www.theactionscripter.com/");
navigateToURL(targetURL);
var _url:URLRequest = new URLRequest("http://www.theactionscripter.com/");
navigateToURL(targetURL, "_blank");
|
This is a cool Papervision version of Google Maps. You are able to look at New York at angles and zooms. http://www.pixelcase.com.au/vr/2009/newyork/ |
|
Jordan was a master on the court and on the web. http://www.nike.com/jumpman23/aj2009/ |
scaleMode property is set to StageScaleMode.NO_SCALE, the stageWidth property represents the width of Flash Player. This means that the stageWidth property varies as you resize the Flash Player window. When the value of the scaleMode property is not set to StageScaleMode.NO_SCALE, the stageWidth property represents the width of the SWF file as set during authoring in the Document Properties dialog box. This means that the value of the stageWidth property stays constant as you resize the Flash Player window. This property cannot be set. stage.width vs stage.stageWidth Demo
In the example below you can dynamically adjust the width of the box to see the difference between stage.width and stage.stageWidth. The stage.width will never be smaller than 234 because of the size of the toolbox at the bottom.unloadMovie() has also been removed in AS3. Instead of using unloadMovie(), you need to use removeChild().var item:item_one_mc = new item_one_mc(); //first declare library item
this.addChild(item); //add child to the stage
The example below uses AS3 to attach an item from the library then remove it.this.removeChild(item);