Game Weapon System Class (OOP)
I’ve been working on a weapon class to add to the space shooter game. Will post a demo as soon as it’s ready.
The weapon will be composed of independent systems: a targeting system (fire towards mouse, fire at closest target), a launching system (projectile, rocket, missile, laser), and an ammo loading system.
Each system will be completely independent and will not need to know how other systems operate to do it’s own job.
Here’s a little diagram to make it easier to understand (work in progress):

Player Movement with Velocity
Expending on the previous space shooter example, I’ve added velocity to player movement.
AS3 Basics - Naming Conventions
Use precise, meaningful, contextually relevant names that are as descriptive as possible. Limit the use of unnecessary abbreviations.
- Example: defaultImagePreview
NOT: dfltImgPrv
Start each instance name with a lowercase letter, and intercap the remaining words.
- Examples: menuItem, sectionTitle
Apply the same conventions to variable names.
- Examples: accountNumber, startingPoint, currentProductName
Begin a class name with an uppercase letter. Write class names in mixed case when it’s a compound or concatenated word. Keep package names as short as possible, using reverse domain naming conventions.
- Examples: com.client.project.component.ClassName
Name functions and methods in the form of verbs, since they perform actions.
- Examples: getUserName(), calculateTaxes(), createSubMenu()
Name booleans with an appropriate, positive prefix, such as “is”, “has”, “can”, or “should”, for an easier determination between true and false.
- Examples: isSoundOn, isFinished, isOpen, isLoggedIn, hasLicense, canEvaluate
Use complement names for complement entities: get/set, add/remove, create/destroy, start/stop, insert/delete, increment/decrement, old/new, begin/end, first/last, up/down, min/max, next/previous, open/close, show/hide.
- Examples: getUserName, setUserName
addThumbnailImage, removeThumbnailImage
showAnimation, hideAnimation
Private variable names may be prefixed with an underscore or $ symbol as long as consistency is maintained.
Center MovieClip based on browser size
Put the code below on the first frame of your flash movie. Add a movieclip to stage and give it the instance name “myMovie”. This AS3 code will dynamically center your movieclip based on browser size.
import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event; function resizeHandler(e:Event):void { myMovie.x = (myMovie.stage.stageWidth / 2) - (myMovie.width / 2); myMovie.y = (myMovie.stage.stageHeight / 2) - (myMovie.height / 2); } stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.addEventListener(Event.RESIZE, resizeHandler); stage.dispatchEvent(new Event(Event.RESIZE)); //the end |
Simple Accordion Menu
This is a very simple accordion menu. It uses the free TweenLite tweener for movement.
Custom number range sliders
I needed a custom range slider for selecting prices. It needed to have two draggers. One of low price, one for high price. Here is the result.
Low and High value is calculated based on the size of the slider track.
Easy to use and easy to customize. Only 3 movieclips make up the whole thing. Doesn’t use annoying built in flash components.
CategoriesLinks |