ActionScript :: Recommended Initialization Values For Numbers
Jul 12, 2009
Assume you have a variety of number or int based variables that you want to be initialized to some default value. But using 0 could be problematic because 0 is meaningful and could have side affects. I have been working in Actionscript lately and have a variety of value objects with optional parameters so for most variables I set null but for numbers or ints I can't use null. An example:
package com.website.app.model.vo {
public class MyValueObject {
public function MyValueObject (
_id:String=null,
_amount:Number=0,
[Code] .....
The difficulty is that using 0 in the above code might be problematic if the value is not ever changed from its initial value. It is easy to detect if a variable has a null value. But detecting 0 may not be so easy because 0 might be a legitimate value. I want to set a default value to make the parameter optional but I also want to later detect in my code if the value was changed from its default without hard to debug side affects. I suppose I could use something like -1 for a value. I suppose it depends on the nature of the variable and the data.
View 7 Replies
Similar Posts:
Feb 19, 2009
I need to load anywhere from 100 - 100,000 lines of data. Currently I am reading the data letter by letter which is taking Flash a god awful long time to load it.
Code:
///looop length of file
for (h=0; h<GWords.length; h++) {
///Slice each part of the Gcode
curr_word = GWords.slice(h, Number(h+1));
[Code]....
Example of how I bring it into the datagrid:
Code:
file_parsed.addItem({G:G_Value, F:F_Value, Y:Y_Value, X:X_Value, C:Comment_value});
The file is vector values that I take and draw it out after it is loaded.
Is there a better way to grab the a value between Letters to make things happen quicker?
View 9 Replies
Mar 31, 2007
How do I add array values that are numbers when loaded dynamically via sql?Example script doesn't calculate. Instead it just adds as though the elements of ycor array are string based. So ycor[0] = 2 and ycor[1] = 3 added equals 23 not 5. Of course these elements are being dynamically set via mysql db that generates a xml table. I've left out file locations and passwords for obvious reasons. Why are the elements being treated as strings?
Code:
var theXML:XML = new XML();
theXML.ignoreWhite = true;[code].....
View 3 Replies
May 17, 2011
I have plans to make an RPG that is similar to those on the SNES as far as movement goes- you walk one tile in a direction at a time and if the tile that you are trying to move to has been marked as one that can't be walked on, it stops the character from going there. That means that conventional collision wouldn't quite cut it.
So I decided that I would make it to where every tile will have a specific value (one to say that there is no collision, another to say there is, etc.), and every object will have an X and Y value that changes in relation to the character (because there is scrolling in this project).
The thing is, there will be a lot of objects, and there will be a lot of tiles; this will quickly become an unimaginably huge project if I just go ahead and throw objects in.
So, what would be the most efficient way of storing these values? I was thinking of storing it in an XML file or a class, but I haven't really done it before, so I want to get a second opinion before I try and do so.
View 2 Replies
Nov 4, 2011
How can I adjust flash so it values can only be whole numbers for dimensions and positions? For some reason flash likes to adjust the numbers I enter in the properties flash changes the number slightly. i.e i set the width to 500 and it'll adjust it to 500.05 or 499.05.
View 1 Replies
Jun 11, 2010
how can i restrict the values inputted into my TextInput control in my mxml page to only numbers.
View 1 Replies
Jul 20, 2009
benefit a Flash/Action Script beginner?
View 2 Replies
Jul 21, 2009
I'm producing an interactive video piece for my New Media masters project. I've put it up on my website, and was wondering out of curiousity, whats the recommended upper limit for the size of a .SWF file on the internet to run smoothly? I realise CPU and internet speeds vary greatly from machine to machine along with RAM, but is there a general upper limit which shouldn't be exceeded for .SWFs?
My project's .SWF is currently at 260kb. It also pulls in .FLVs that are between 800kb - 1.5mb and .mp3s between 1.5mb - 2mb via XML.
View 2 Replies
Jun 29, 2009
I would like to know Adobe's Recommended system requirements for a PC running Flash Catalyst (not simply the minimum that are posted on this page: url...
View 1 Replies
Aug 3, 2009
With the following recommended spec from Adobe website, how many concurrent users ? Flash Media Streaming Server system requirements OS : Windows Server 2003 SP2 or Windows 2008
H/W Requirements
- 3.2GHz Intel Pentium 4 Processor (dual Intel Xeon or faster recommended)
- 2GB RAM ( 4GB recommended)
- 1Gb Ethernet card
View 3 Replies
Jul 12, 2011
So, after just being dumped on from a great height by our development company I need to create an entire site in flash with login and dynamic addition of content etc etc.. What would be the recommended maximum size (pixel wise) for a flash site... what I have here is 1600px sq? It's mostly database driven so shouldn't lag too much from a point of view of file size, I'm just concerned because of the short deadline and I find this kind of large size wise to do 100% in flash..
View 10 Replies
Dec 10, 2009
Currently I have a flash based application (game) which I need to put on facebook, the users could save their scores and resume their game. For the task I was wondering which scripting language would be appropriate. And are there any API's available which could in the process. Or does one has to make all of it from scratch.
View 1 Replies
Mar 29, 2011
A client needs a standard consumer color printer for printing name badges from my flash app. Last time we used the app, I couldn't do any pre-testing of their computer and printer beforehand. So, of course, the margins were completely wrong when the time came to print. Ideally, I'll have the flash app's bugs worked out for the next run, but for safety's sake does anyone know of a printer that has good controls for custom margins and offsets, in case some minor adjustments are needed?
View 1 Replies
Jul 5, 2007
make a trivia game though the big question is how shuld i load the questions (with multiple answers) from flash or from txt or from asp?
View 1 Replies
Apr 10, 2011
There are a few things regarding best practices in ActionScript that I would like to know about:1. When a class uses other classes located in the same package, I know that it is not necessary to import them.But what is the best practice ? Should they be imported, just for the sake of clarity and order or is it recommended not to import them ?2. Is there a recommended order in which to arrange the imported classes ? I am just interested if there is a general idea regarding the order.Maybe display object classes before event classes, maybe event classes before component classes, and so on.3. Is there a recommended order in which to arrange the class properties and methods Regarding the properties, private, public, protected, constants. Regarding the methods, private, public, protected, getters, setters.Again, I am simply looking for best practices and recommended practices regarding these issues, I am aware that they are not essential to the code and that each person can choose to do different things.
View 12 Replies
Apr 20, 2010
I need to do an in-place upgrade from 3.5.2 to 3.5.3 on my origin servers. Is there a recommended precedure to acheive this? I want to have the minimum downtime possible. CentOS, x64. I think something along the lines of :
[Code]...
View 1 Replies
Nov 16, 2009
is it neccessary or recommended to close netstream and netconnection and create a new one before moving to next video?
View 1 Replies
Jan 26, 2010
Once you load an actionscript page from scratch (in my case loading XML data from a file, initializing various other elements in a fairly time consuming way) if you navigate away from that page and then return to it, (via the browser 'back' key for example) is their a way to forego the previous initialization and just immediately bring up the previous Actionscript page in its fully initialized state.
View 2 Replies
Nov 7, 2010
I have created an X*Y grid of rectangles that cover up a movieclip (R). I put these into a 2d array (for easy access) and in a container movieclip which I use as mask over R. Now when I move one of the small rectangles R.width to the right when I am still in the constructor, a small bit of R will become invisible. But when I do this inside the function which handles mouse events, nothing seems to happen.
ActionScript Code:
package documentClass{
import flash.display.MovieClip;
import flash.events.Event;
[code]....
View 0 Replies
Feb 7, 2011
I installed cs5 creative suite on windows 7 64bit, I've got cs4 creative suite installed, all programs work fine, only flash cs5 has a problem, when I try to launch it, it loop after the write "I'm creating the workspace ... " (similar). It loop to infinite, I see the logo and a window with label = "flash cs5", into the window there isn't nothing, only a white page with the "cursor wait".I tried all the advise by adobe (on google cpsid_82252) but nothing work fine ... I re-installed all creative (after WinCS5Cleanupscript) but nothing ...
View 3 Replies
Apr 19, 2010
As I currently understand, if an event listener is added to an object with useWeakReference set to true, then it is eligible for garbage collection and will be removed if and when the garbage collection does a sweep.
public function myCustomSpriteClass() //constructor {
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener, false, 0, true);
this.addEventListener(MouseEvent.MOUSE_UP, mouseUpListener, false, 0, true);
}
In this case, is it not appropriate to initialize an object with weak references event listeners, incase the garbage collector does activate a sweep removing the objects event listeners since they were added during initialization of the object? In this case, would it only be appropriate to create a type of deallocate() method which removes the event listeners before the object is nullified?
View 1 Replies
Oct 25, 2010
I am loading a component which makes a HTTPService call to get data that will then be used to set certain variables in the component. I make the HTTPService call in an init() function (for the initialization event) and then set the variables according to the data received in the HTTPService result handler. However, the variables are still null at both the initialize stage and at the creationComplete stage. If I try and read the variables in a creationComp() function (for the creationComplete event), those variables are still null. Is this correct?
I guess I don't understand the flex initialization cycle very well. When are those variables actually set and available to be used? I need to manipulate those variables automatically after the component loads. Is there an event that comes after creationComplete that is appropriate or some other way to approach this? I am using Flex 3.
View 2 Replies
Sep 16, 2010
I work mainly in C++, and at work we use this awesome autonomous singleton pattern where you automatically add statically instantiated classes to some global list. If you're familiar with c++, imagine something ala:
class CuteSingleton : public ISomeInterface
{
*** stuff ***[code]...
So basically, CuteSingleton is instantiated at DLL load time and added to a global list of ISomeInterface interfaces. This is really powerful because it lets us rapidly prototype tons of code without polluting our existing codebase by having to include these prototype files, instantiating classes like CuteSingleton in a big initializer list somewhere, etc.I've been trying to figure out how to do something similar in actionscript for a few days now and I'm coming up empty handed. All I want to do is have this code instantiate this class without having to reference it in some other files:
package EntitySystem
{
public class EntityManager extends AutoGameSystem [code].............
View 4 Replies
Feb 21, 2009
I have two questions.First: I created this class, which supposed to create sort of 3D cube
Code:
package
{
[code].....
View 3 Replies
Dec 3, 2010
I'm trying to buid a video player application usin the Youtube API, which is loaded remotely from their servers as described [URL]...reference.html Basically I want to add a playList via XML or flashVars which would be stored in the Model among other data taken from the video feeds of youtube by HTTP request. The issues are:
1.- I don't know where the youtube API would fit in the MVC pattern, because it has two parts, the Loader instance that you can add to the display list and the API Object itself that is more like a controller. My first approach has been to create a controller class which loads it and initiates it. But then I have to provide a reference of the loader to the View. Should I do it using a setter in the view, dispatching an event and then a listener in the view gets this reference from the controller, or including the reference in the model??? I'm a little bit lost here.
2.- On the other side, I don't know how to implement the strategy pattern betwen the view and the controller in this scenario. Should I leave the whole initialization process outside the MVC pattern? It's not that I'm obsesed with design patters, I'm just trying to learn how to use them and put myself this as an exercise: Build a videolist player for youtube so that it's easy to add, let's say Vimeo support later.
View 1 Replies
Feb 22, 2011
Following error is arising if I use NavigatorContent in Repeater. Is there a way to initialize image and lable on which I am encountering following error: Unable to generate initialization codewithin Repeater, due to id or databinding on a component that is not a visual child.
Code:
<mx:Repeater id="rep" dataProvider="{usersArray}">
<s:NavigatorContent width="100%" height="100%" label="{rep.currentItem.name}" >
[code]....
View 1 Replies
Dec 20, 2011
I need to completely initialize a custom component in my Flex app (i.e. I should be able to access it from action script and get its properties and its children etc), But I do not want to add it to the display or make it visible. I have tried to add it to my visible component, but keep it visible, but often many of its properties are set only when it is drawn, so i don't get what i need. Is there a way to add a custom component to some sort of 'Virtual' display, that is not visible to the user?
View 3 Replies
Apr 27, 2006
So I have a movieclip that I want to play nice with my class file. So I set the linkage and all that and it works. But, my initialization function gets called with no parameters, because I have not set any. How do I do that with this method?
I've tried something like:
Code:
import tab;
tab1_mc = new tab("left", 5, 55, "testclip.swf", 0);
And that sets the parameters, but not before the linkage on the MovieClip fires. how to get the best of both worlds?
View 7 Replies
Nov 2, 2004
how to do this and not found much, so here goes:
I want to generate a variable number of random numbers less than 16 with no duplicate numbers
Ive posted the fla, and what i'm doing is generating a random number and putting it into an array then using a for loop to cycle through the array for each new random number to check if its already there. if it is, then i want to regenerate that number.
if you test the fla you'll see that all i get in my array is some lovely zero's and i sort of know why this is, but don't know how to stop it.
View 3 Replies
Feb 18, 2010
I am trying to convert a string having numbers to an integer.
//15 9's are there
var str:String="999999999999999"
var res:Number = new Number(str);
But it is not able to convert correctly as the the var res now has the value 100000000000000000. I know that the number has 52 bits of memory, then why is it not able to do the conversion?
View 6 Replies