ActionScript 3.0 :: Getter Methods Good Practices?
Mar 11, 2010
If I've got a getter method, say a(), that returns the private variable _a. Obviously from outside the class I call instanceOfClass.a. But from inside the class, should I use the getter or directly _a? Suppose I'm writing a method that uses _a: should I use _a or a? var b = a; or var b = _a? Maybe for performance reasons it's better to directly access _a? Or since there's a getter a(), it's a good practice using always and only the getter?
View 8 Replies
Similar Posts:
Jun 24, 2010
Anyone have any tips for good practice with using event listeners? I've gotten into the habit for checking for event listeners (hasEventListener()) prior to removing them, but no errors are thrown if you try to remove an event listener that does not exist, so should I even bother?
Also, I've often gotten into the habit of checking for a listener prior to adding it sometimes, just to make sure I'm not adding it twice (mostly due to slightly sloppy code when they're added/removed on an as-needed basis). But doing a quick test, it seems this is also not needed. It seems adding an event listener of the same type with the same handler twice overwrites the first:
Code:
stage.addEventListener(MouseEvent.MOUSE_DOWN, downHandler);
stage.addEventListener(MouseEvent.MOUSE_DOWN, downHandler);
// traces 'true'
trace(stage.hasEventListener(MouseEvent.MOUSE_DOWN));
[Code]...
View 12 Replies
Jul 20, 2010
I have a bit of Flash experience, did a full featured movie player, other stuff in AS3 and got plenty of programming skills in other languages, BUT now I need to create a multi paged website. Quite easy, a few pages, some animations here and there, nothing fancy, got all the graphics.
But time is short on this one, so I need some advice about good practices (pack everything into one main MC or make separate swfs and load them in, etc.), where to begin, or what kind of book should I grab to make the job pretty.
View 2 Replies
Nov 20, 2009
I'm trying to make a class that extends the Sprite, have some private properties attached to it and be able to read and write those properties using getters and setters. Simple... but the compiler throw this error "Access of possibly undefined property speed through a reference with static type flash.display:Sprite."It works if I set my class to extend the MovieClip object.Could someone explain me the logic behind this? why I can't use getter and setters with a Sprite?Here is a sample code:
package {
import flash.display.Sprite;
public class Vehicle extends Sprite{
[code].....
View 5 Replies
Aug 2, 2011
I'm trying to make a class that extends the Sprite, have some private properties attached to it and be able to read and write those properties using getters and setters. Simple... but the compiler throw this error "Access of possibly undefined property speed through a reference with static type flash.display:Sprite."It works if I set my class to extend the MovieClip object. someone explain me the logic behind this? why I can't use getter and setters with a Sprite?
[Code]...
View 1 Replies
Jul 27, 2009
Which is a much better practice in binding a value in Flex?
View 2 Replies
Feb 26, 2007
"Getting" the hang of Getter/Setter methods, but could use a review of my syntax. Does the follwing demonstrate best practices, meaning the least awarkward application of the technique?
Code:
// in Calculator.as
class Calculator {
private var _priceCD:Number;
private var _priceShocks:Number;
private var _priceCover:Number;
[Code]...
View 6 Replies
Nov 27, 2010
Looking for a programming book that is in tutorial approach. Example this chapter teaches you how to do a login form. In the second chapter it teaches you how to integrate the login for to another app.Basically I'm looking for a book that teaches you real working application rather than abstract ideas. Programming language I have in mind is Adobe Air/Flex, Visual Basic. Functions I have in mind should at least cover Drag and Drops, Integration to a web form (form entry) and customizable interfaces.The languages i had in mind isn't fix. If you know a programming platform that has little code or easy to learn but still be able to develop a cool application.
View 3 Replies
Oct 27, 2010
Using CS5 AS2.I'm creating a website in flash (all the files will be in one directory/folder on SharePoint) and want to make sure that what seems to be working fine is best practice.I have an index.swf with many buttons which will take the user to landing pages/content/other swfs. On these different buttons I have the script [code]The movie transitions nicely to name.swf and on this page I have a button that returns the user to the index.swf on (release) {loadMovieNum("index.swf", 0);}Things move back to index.swf nicely and user can chose to go to another landing page.It looks like I'm on the right track, bc nothing is going awry? but want to check. Am I following best practices for moving from one swf to another within a website?
View 3 Replies
Jul 16, 2011
I'm using this simple code to retrieve a value from a PHP script:
package
{
import flash.display.MovieClip;
[code]....
View 1 Replies
Feb 27, 2010
I've been working on a game the past few days where there is to be a LARGE amount of stored data. By a large amount, I'm talking something like 200+ entries of around 12 fields.The game is being designed with the intent of playing it online (per say), so I can't rely on storing specially made files on one's computer (Not that I think I could and do it in a way where players cannot modify it). I also do not want to rely on a stored XML file on the internet or on a database, because if the website that has this data goes down or if the person loses internet access, then the game becomes unplayable.So, I need to store this data in the game itself, but I am unfamiliar with the best way to go about doing this. I've normally worked with outside sources for data storage, as they were designed in closed environments (aka intranet) or the website that the SWF would be on would also be where the database used is stored. Neither apply to this game, as the game will likely be put up on Flash portals like Newgrounds.
View 17 Replies
Nov 25, 2009
We have recently deployed Flash Media Streaming server 3.5.2 and Flash Media Encoder on a Windows 2003 machine. Do you guys know of any security best practices to follow for the FMS server deployment on a Windows machine, could you please point me to that resource.
View 2 Replies
Jul 18, 2010
What are, nowadays, the best practices for uploading a large file (which may cause a timeout) with ASP.NET Web Forms and/or MVC? Increase Server.ScriptTimeout (only for the specific POST request); Use some flash client-side uploader like swfupload ([URL]) or plupload ([URL]), but Flash uploads have some issues with proxies; Use some gmail-like javascript (like [URL]
View 2 Replies
Jul 17, 2009
When I create a website,I always end up with 2 preloaders... one to load the main swf (library items, etc...), and then a second preload takes place to load all the external images from XML.Is there a better way?I don't like the fact that there are two progress bars that run or a long pause in the beginning prior to the 2nd preloader. Please let me know if I'm missing something or if you follow any design patterns or best practices.I often run across sites that have one load and then images throughout the site load rather quickly.
View 0 Replies
Apr 3, 2009
I have a question about how best to remove display objects.removeChild(object);Given that there are no other reference to this object, does using removeChild alone make the object eligible for garbage collection, or does it also need to be given a null value as well?[code]In both these cases, I get the classic 1009 error. That leads me to believe that if you use removeChild, you don't also need to give the object a null value.?url...
View 2 Replies
Aug 6, 2009
I've been building Flash web sites for a long time now, as a freelance developer. I usually work alone, and so I'm the only one that touches the production work I do.Since I'm in this working position, I don't get a lot of exposure to other styles of flash production. I was wondering if any of you have examples of the best ways to produce high quality flash websites. I'm not talking about huge team projects, but small 40-50 work hour sites.[code]
View 2 Replies
May 8, 2010
What are the best practices for optimizing a transparant png image? What things can be done to make such a png file as small as possible without loosing to much of its quality? Best tools? Best Photoshop plugins? Other tips?
View 2 Replies
Nov 13, 2009
Let me start off by stating that I am a novice developer, so please excuse the elementary nature of my question(s). I am currently working on a Flex Application, and am getting more and more confused about when to use server side scripting, and when to develop web services. For most of the functionality I am working on, I am taking various files from the user (client), uploading to the server for processing/conversion, then sending back to client in new format.
I am accomplishing most of this using asp.net generic handlers (ashx) files, but not very confident this is best practice. But at the same time, does making web services make any more sense? What would be considered best practice for this?
View 3 Replies
Feb 22, 2010
Are there any standard practices for Video encoding, streaming, etc?
View 1 Replies
Jun 1, 2011
I have a website that has a Flash banner. For devices that do not support Flash (like iPads) I want to display an image instead. What is the best practice to deal with this situation? Should this be handled from the front-end with JavaScript?Should this rather be handled from the back-end? (I am using Java on the back-end)
View 1 Replies
Oct 3, 2011
I have an application with about 20 models and controllers and am not using any particular framework. What is the best practice for using multiple remote objects in Flex performance-wise?
1) Method 1 - One per Component - Each component instantiates a RemoteObject for itself
2) Method 2 - Multiple in Application Root - Each controller is handled by a RemoteObject in the root
3) Method 3 - One in Application Root - Combine all controllers into one class and handle them with one RemoteObject
I'm guessing 3 will have the best performance but will be too messy to maintain and 1 would be the cleanest but would take a performance hit.
View 3 Replies
Aug 6, 2010
I'm building my first Flash application. It's a stand alone barcode scanner - the scanner is built-in to the monitor. Basically it has a welcome screen with a video, and at any time you can either scan a product to get product info, or touch the screen for more options (more info, more videos, etc.), respectively.I'm looking for articles, tutorials, etc. that can give me best practices and tips for efficiently designing and organizing it. For example, what's the best way to switch between screens, keep track of which screen is showing, etc.
I've looked all over the web and can't find an article or tutorial on this, and while my app is working, the code is looking pretty spaghetti-ish and I really would like to learn the best way to plan and organize a project like this.
View 1 Replies
Mar 7, 2006
I thought i'd start this thread to uncover peoples habits and practices when it comes to the simple operation of adding and removing elements on stage. I ask because there are so many alternatives, and I keep wondering what might be the best/most eficcient way of doing it. Let me explain by giving an example:
Your user has chosen to click that flashing button that says "Sign up for our mailing list" and you need to prompt the user for a valid e-mail address by presenting him/her with an alert box on top of everything else. Do you.[code]....
View 3 Replies
Nov 3, 2010
Since there's so much potential pollution within namespaces, particularly with the parser automatically declaring any MXML component with an id to be publicly-accessible using that ID I'm finding it dangerous to use just camelCase for MXML element ids. eg:
[Code]...
In Flash development, a lot of us did this for (automatically) declared stage instances like "mcMyTabBar" or "navMC" or "playPauseBTN". I'm looking for input from the Flex community about this. Am I just overthinking things? All of the related Style Guides and best practices documents I've read on the topic just say "use camelCase for ids, and make sure the id property is the first property". What's your take?
View 2 Replies
Jan 14, 2009
I have a setter and getter method , the getter method should return an array collection but it's always returning an empty array collection even when I've run trace to check on it.[code]...
View 1 Replies
Jun 3, 2010
I've created an AS class to use as a data model, shown here:
package
{
import mx.controls.Alert;
[code].....
View 5 Replies
Nov 9, 2009
I'm having trouble updating a property value of a custom class (SubLoader) using a getter and setter. Inside the if() statement of the main fla you can see my attempt to set the percent value. Running a trace() method before the if() statement always outputs '0' for some reason. Tracing after the if() statment outputs an actual value. I can't figure out why the percent property always traces as '0' before the if statement even though I am updating it with each progress event.
[Code]...
View 3 Replies
Nov 15, 2009
I'm finally reading up on commenting code with ASDoc (http:url]....) but the way ASDoc is set up doesn't seem to agree with the way I write my getter/setters.Here is how I write them:
Code:
//I want to add the ASDoc tags here, before this chunk of code
private var _enabled:Boolean = true;
public function get enabled():Boolean[code]...
if I ad the tags where I want them, if I understand correctly, they will comment the private variable instead. Bummer.So, either I change the coding style I have been using for the past three years, or insert the tags inside of my code, making it ugly and less structured. I'm leaning towards option A.how do YOU write your getter/setters so they are ASDoc friendly?
View 1 Replies
Dec 7, 2009
I frequently find myself wanting more granular control of the width/height properties. Consider either of the following cases:
- The DisplayObject is clipped with DisplayObject.mask, but Flash reports unmasked width.
- An image is displayed with a transform cage drawn over it. The width of the cage shouldn't be calculated when determining the DisplayObject's width.
The naive way to solve this problem is to override the width getter of the DisplayObject in question. The problem is that the core implementation of DisplayObject.width is written in native code. If after overriding the width getter, I call overridenObject.width, I get what I want; however, if I call overriddenObject.parent.width, DisplayObject.width ignores my override and calculates the dimensions based on its own internal display list representation.
Does anyone know of a technique to limit which children are considered when calculating width without having to override every parent's width getter? I've tried overriding width, getRect, getBounds, and scrollRect, but none of them seem to be referenced by DisplayObject.width's native implementation.
View 15 Replies
Dec 29, 2009
Anyone know a workaround to make static getter/setters?
View 2 Replies