In this post I’m going to show you a few more advanced features of AS3 functions. I think you’ll find they certainly help, at least when it comes to coding an API for the general public.
In this post I’m going to show you a few more advanced features of AS3 functions. I think you’ll find they certainly help, at least when it comes to coding an API for the general public.
I just realized that there are some hidden games in my banner. This may seem like a strange statement since I made the banner and all the artwork. Well, originally the banner was a concept design for a company that we do projects for called “ThinkFun”. I stripped down the banner but apparently left some ‘hidden’ games.. See if you can find the games hidden in the header banner of this site! I believe there are anywhere from 3 to 6 or so.
Here is a class that you can use to load swf’s into an object that you can display or do whatever you’d like with:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | // SWFLoader Class by Rick Nuthman // 2.10.10 // // Usage: /* var mySWF:Object; mySWF = SWFLoader.create("urlToSWF.swf", 0,0); mySWF.dispatcher.addEventListener("ready", displaySwf); function displaySwf(event:Event){ addChild(mySWF.swf); } */ package com.frigidfish{ import flash.display.Sprite; import flash.display.Loader; import flash.events.Event; import flash.net.URLRequest; import flash.events.EventDispatcher public class SWFLoader{ public function SWFLoader() { } public static function create(url, x=0,y=0):Object { var loaded:Event = new Event("ready"); var dispatcher:EventDispatcher = new EventDispatcher(); var swf:Sprite = new Sprite ; var mLoader:Loader = new Loader ; var obj:Object = new Object; obj.swf = swf; obj.dispatcher = dispatcher; swf.x = x; swf.y = y; var mRequest:URLRequest = new URLRequest(url); mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,swfLoaded); mLoader.load(mRequest); function swfLoaded(event:Event) { var target = event.currentTarget.content; swf.addChild(target); dispatcher.dispatchEvent(loaded); } return obj; } } } |
You don’t need to make an instance of the class, just use the static function ‘create’ like so:
Sorry about the trouble with the site the last couple of days. I have moved my domain to another account and everything should be working fine now.
Have you ever embedded an swf into an html docuement and all seemed fine until you started getting calls from customers saying that the preloader is stuck at 100%?
Well I have, and it took me quite some time to figure this out.
So basically I have been annoyed by the fact that it is so hard for new users to find answers to simple everyday problems when using Actionscript 3 for flash development. This is especially true when transitioning from Actionscript 1 or 2.