HTML 5 and CSS3 Useful Jquery and JS Adobe Flash Basics,tips and tricks Flickr http://www.flickr.com/photos/53336704@N05/
Friday, April 22, 2011
Learning AS3
Load Movie() in AS3
var swfToLoad: String = "mySwf.swf"; var loader: Loader = new Loader(); loader.load(new URLRequest(swfToLoad)); addChild(loader);
var myLoader:Loader = new Loader();
myLoader.load(new URLRequest("load.swf"));
------------------------------------------------------------------------------------------------
Load Movie using BUTTONS and Progress BAR
import fl.controls.ProgressBar;
import fl.controls.Button;
var my_loader:Loader = new Loader();
var my_btn:Button = new Button();
my_btn.label = "Load Image";
my_btn.x = 100;
my_btn.y = 200;
addChild (my_btn);
var my_pb:ProgressBar = new ProgressBar();
my_pb.source = my_loader.contentLoaderInfo;
my_pb.x = 100;
my_pb.y = 200;
my_btn.addEventListener(MouseEvent.CLICK, startLoading);
function startLoading(e:MouseEvent):void{
my_loader.load(new URLRequest("myPhoto.jpg"));
addChild(my_pb);
removeChild(my_btn);
my_btn=null;
}
my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading);
function finishLoading(e:Event):void{
addChild(my_loader);
removeChild(my_pb);
my_pb = null;
}
------------------------------------------------------------------------------------------------
Add mouse click event to SimpleButton package { import flash.display.*; import flash.events.*; public class SimpleButtonDemo extends Sprite { public function SimpleButtonDemo( ) { var button:SimpleButton = new SimpleButton( ); button.x = 20; button.y = 20; button.upState = createCircle( 0x00FF00, 15 ); button.overState = createCircle( 0xFFFFFF, 16 ); button.downState = createCircle( 0xCCCCCC, 15 ); button.hitTestState = createCircle( 0x000000, 50 ); button.addEventListener( MouseEvent.CLICK, handleClick ); addChild( button ); } private function createCircle( color:uint, radius:Number ):Shape { var circle:Shape = new Shape( ); circle.graphics.lineStyle( 1, 0x000000 ); circle.graphics.beginFill( color ); circle.graphics.drawCircle( 0, 0, radius ); circle.graphics.endFill( ); return circle; } private function handleClick( event:MouseEvent ):void { trace( "Mouse clicked on the button" ); } } } | |
|
Subscribe to:
Posts (Atom)