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.
Have you had trouble with Adobe’s Tween class? (Used for so called “easy” ActionScript animation of display objects) I sure have, so I thought I’d write a post about it. When I was first taught how to animate with ActionScript, I had many a lock up and stutter from the Tween class. For awhile I was quite annoyed, seeing theĀ benefitĀ of animation using ActionScript but thinking that it was totally unreliable. Now there are a number of methods to fix the problems with Tween, using Dictionaries, new objects and so on; all of which seemed tedious and time consuming. Thankfully, I found a better solution, third party tweening engines! I’m going to tell you about what I think is the best one, TweenLite.
In this post I’ll be talking about a class I’ve made called AMFPHPConnection that extends Flash’s NetConnection object. This class eases and enhances the process of using AMFPHP for Flash remoting. But before we begin, just a few notes: I’m not the usual author, and you’ll need to know how to use AMFPHP the normal way, or you may not get some of the terminology. If you want to learn how to use it, I have a series on my YouTube channel for that purpose, go here to watch it: http://www.youtube.com/user/BlackBulletIV#grid/user/CAD2DAE46A04939D
At some point you may need to display a number that must always occupy a predetermined number of character spaces. An example would be a rolling game timer with a 5 digit display. For example, when the timer hits 33 seconds, the digits would display like so: 0 0 0 3 3
Something that I’ve been noticing lately is the need to pay close attention to how you are cleaning up your objects after you are done with them.
I’ve been working with a great as3 debugging tool called “De MonsterDebugger”. Strange name but great tool. Check it out here: http://www.demonsterdebugger.com/
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.
Many of the examples that I use in my blog come in the form of a “Class” file. Without going into too deep an explanation, I will attempt to explain how to implement a class into your project. The following is a class for our example:
This is going to be a very simple example of how to dispatch an event. In actionscript 3, you dispatch an event by extending the EventDispatcher class. I’m not going to get into a big complicated explanation right now, but I will show you a couple of simple examples.
One things that you have to do a lot when developing grid based games is obviously lay out the grid. This is confusing to a lot of people but is really quite simple. I created a simple class just for this blog to demonstrate how this can be achieved.
There is a game that I have been working on that I’ve had to load into an as3 interface and I noticed that my previous class will not work to do this.
There were a few modifications that I had to make… Here is the class:
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 | // SWFLoader Class by Rick Nuthman // 2.16.10 // // Usage: /* var game:SWFLoaderAs2 = new SWFLoaderAs2("yourSwf.swf",20,0) game.dispatcher.addEventListener("ready", gameLoaded); function gameLoaded(event:Event){ addChild(game); } */ 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 SWFLoaderAs2 extends Sprite { public var dispatcher:EventDispatcher = new EventDispatcher(); private var contentLoader:Loader; public function SWFLoaderAs2(pathToTheContent,x,y) { this.x = x; this.y = y; loadSWF(pathToTheContent); } private function loadSWF(pathToTheContent):void { var request:URLRequest = new URLRequest(pathToTheContent); contentLoader = new Loader(); contentLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,swfLoaded); contentLoader.load(request); } private function swfLoaded(e:Event):void { addChild(contentLoader); dispatcher.dispatchEvent(new Event("ready")); } } } |
usage: