Variables :: Initialization - "proper" Place To Initialize Class Variables?

Jun 23, 2010

Is it "better" to initialize AS3 class variables in the class constructor? Or can I just initialize them to their default value when I declare them at the top of my class? I ask because when there's a lot of class variables, it appears inefficient to declare them in one place and then initialize them in another when I could easily do both in the same place. It one option is better than the other,

[Code]...

View 2 Replies


Similar Posts:


Flex :: Setting Variables During Component Initialization

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

Flash :: Proper Place To Put My ActionScript Class?

Jun 22, 2010

I am writing an ActionScript class and I don't know where the standard place to put it is.In other words, where should I put the package in regards to the hierarchy? In flash.myname.mypackage? What is the standard naming convention? As you can probably tell, I haven't had a lot of experience writing ActionScript classes :)

View 2 Replies

ActionScript 3.0 :: Proper Way To Pass Variables To SWF

Nov 11, 2009

So using AS3 with Adobe Flash CS4, what is the correct way to pass a variable from a server side script "PHP" to my SWF?

View 3 Replies

ActionScript 2.0 :: Proper Use Of Static Variables

Dec 19, 2004

I have created a class to define my main navigation buttons. I would like to handle which button is clicked/pressed as simply and elegantly as possible, and I figured the best way would be to add a static variable to the class that keeps track of the current button pressed. Here's some quick pseudo-code. Code: class MainButton ext MC static var currentButton:MainButton public var sectionToLoad:String public static function getCurrentButton() public function getSection() button.onPress = currentButton = this // other button actions. // then i can check for what the currently clicked button // is and now access its variables. MainButton.getCurrentButton().getSection() etc. etc. etc. I am curious if this is a "proper" way to go about tracking the buttons. I find it is pretty elegant, but i'd rather make sure that this is a good practice of using static class variables. Also, it looks to me that all custom class definitions become a _global object?

View 1 Replies

Flex :: Initialization - Completely Initialize A Component But Not Add It To The Display?

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

Flex :: Initialize Some Variables After CreationComplete Event Is Dispatched?

Mar 7, 2011

I tried to send some services to fetch data in the creationComplete handler. Then I need to process the server raw data before displaying some sub components. Where should I put these kind of code?

View 2 Replies

Flex :: Initialize And Make Condition For 2 Variables In Single For Loop?

Oct 28, 2010

How to initialize and make condition for 2 variables in single for loop in Flex let keep i and j are two variables

View 2 Replies

ActionScript 3.0 :: Make A Proper NavigateToURL Sending Variables Using POST Method?

Apr 11, 2012

I really need to send a variable via POST method to an URL and the navigate to it. navigateToURL sends variables using GET method, although I specified POST. URLLoader sends variables using POST method, but does not navigate to the URL.

View 4 Replies

ActionScript 2.0 :: Initialize The Object With A String Variable Which Holds The Initialization Properties (without Parsing The Text)

Dec 5, 2005

I initialize the "point" object like:

point = {x:'209', y:'270'};
trace(point.x);

this is working fine, But I have to initialize the "point" object with a string variable which holds the initialization properties like:

[Code]...

I know this is not working. Is there any method to initialize the object with a string variable which holds the initialization properties (without parsing the text) ?

View 7 Replies

Flex :: Initialization Order Of Static Variables In Flex Causing Bug?

May 10, 2011

I've got a component written for my app by a third party developer and am trying to integrate it, but I've found a bug that seems like it's either a compiler bug, or there's something with how Flex and static variables work that I wasn't aware of.Basically, I have this:

public class ModeChangeController {
public static const DISPLAY_MODE:String = "DisplayMode";
}[code]...

If I use //V2 (i.e. comment out V1), a bug occurs at the startup of the application (some TextFields are uneditable and contains no text), but with //V1 and not V2, it works fine. If I comment out both, that also works fine (I don't get the TextField bug).It took me a while to figure out that it was that static const String that was causing the issue, but I'm still not sure why or if there's something I can do about it except for just moving the DISPLAY_MODE to Events (which is what I've done at the moment, but it's not a particularly nice solution).There are no errors in the log. The order of the includes in my BorderContainer code doesn't matter. I've googled for "as3/flex static initialization order" but haven't found anything.

Clarification: showInitialView() never gets called. It doesn't get there before the other bug shows up. Just having the V2 line there causes the problem.

Update: I've fixed my problem with the TextInput strings not showing: Turns out that adding the component caused the Tahoma font to not show up. However, setting the font-weight to bold fixed that problem, or switching to Arial. With that said, the original question still stands, because when I ran it without V2, it found Tahoma with normal font-weight.

View 1 Replies

Php :: Place Variables In HTML Swf Wrapper?

Dec 15, 2011

Can you place php varibles in the html wrapper for a swf, that could be read into the swf when it loads?Perhaps using a param?

$myVariable = "$var1,$var2,$var3";

like this with php in the html?

<param name=FlashVars value="$myVariable" />

or perhaps ?

<param name=FlashVars value="myVariable=$myVariable" />

Then perhaps in the swf with as3 using something like this?

var myloader:URLLoader = new URLLoader()
myloader.load(new URLRequest(this.root.loaderInfo).parameters))
myloader.addEventListener(Event.COMPLETE, onLoaded)

[code]...

Unsure how to access it using the correct path to the param and then how to get the php variable $myVariable into myloader.data?

View 2 Replies

ActionScript 2.0 :: Focus Doesn't Go To Proper Place?

May 28, 2010

i have created a dialpad kind of application which has a bach button at top which takes u to previous screen, a display text box and buttons. all of them are movieclips.

Now the issue is when i press down button, focus is expected to go from prevBtn->display->oneBtn, but the focus goes like prevBtn->oneBtn. Other thing is that if i press up key after going on the screen, the focus goes like callBtn->zeroBtn->eightBtn->fiveBtn->twoBtn->display->prevBtn.

one more observation is if i take the display down after all the buttons, the behavior is normal and focus goes to display.

View 1 Replies

ActionScript 2.0 :: Levels / Loading A Swf Into The Proper Place

Jul 6, 2007

I am apparently having problem loading a swf onto the proper level. Anyways, the short of it is that I now need to create all my movieclips on their proper layers and when they are needed call them to the screen.My main screen is on the first level/layer. I then created a movieclip on layer two. I then try to load the swf into that MC on layer 2 and it doesn't display.

View 1 Replies

Actionscript 3 :: Access Variables In Main Application Class From Instantiated Class?

Apr 8, 2010

I have a initApp.as which instantiates a class which needs to access the "currentState" property and the States array as well. However we cannot get this to work as we cannot see how we can access this information.

Within initApp.as currentState is accessed via "this.currentState". This does not work in the class which is instatiated within initApp.as. The following error is thrown:

"Access of undefined property currentState."

View 1 Replies

ActionScript 2.0 :: Defining Variables - Unique To Load SWFs Instead Of Declaring All The Variables

Mar 21, 2012

I have an empty SWF that's sole purpose is to call loadMovieNum and start the project. Each loaded movie has a few variables defined within them - unique to those loaded SWFs. Instead of declaring all the variables in each SWF can I declare all of them in one place, in the first frame of the empty loader it all starts from? I'm thinking I can then declare a variable which each loaded movie can increment as needed for me.

View 2 Replies

ActionScript 3.0 :: Variables True/false Custom Variables Work In Flash?

Aug 20, 2008

How do variables true/false custom variables work in flash?

For example, what I want to do is create a simple true=false variable that I can call on an if statement later.

For example:

Code:
Var1 = true;
if (!Var1)
{

[Code]....

I noticed that neither the "Var1 = true;" part or the if(!Var1) part worked in flash.

View 4 Replies

ActionScript 3.0 :: Declaring Variables In A Sub Class But Using Them In The Base Class Constructor?

Sep 20, 2009

I am creating a Weapon class for a game and the weapons itself will be the sub classes. The sub classes will hard code some values (such as max ammo and the weapon name).

I trying to access this declared data in the base class constructor, at the moment it's not outputting the values. Is this possible?

I've broken my Weapon class for simplicity:

ActionScript Code:
package
{
import flash.display.MovieClip;

[Code]....

My current workaround is creating a protected method in the base class to trace the information and calling that method in the sub class's constructor, this works fine but this doesn't seem like the most efficient technique?

View 7 Replies

ActionScript 3.0 :: Array Of Variables - Make A Bunch Of Variables From A For Loop

Feb 21, 2009

How can I make a bunch of variables from a for loop. for example for (var i=0; i<total; i++) {var bunch(i);}. that i make a bunch of variables named bunch1, bunch2, bunch3. I keep getting errors. I program and use so many different languages that I dont know if that can be done with AS3. my only other alternative i can think of is to create some sort of event dispatcher object array. but I dont know how to get them all to send events to one listener with there index number.

View 5 Replies

Actionscript 3 :: Changes To Array Of String Variables Doesn't Update The Variables Themselves

Jul 30, 2010

I have a list of strings that I add to an array, then attempt to set those values in a for-loop using data that I read in. The array gets updated, but the values the array contains do not. I also have an array of buttons that I update this same way that works great, but strings don't seem to work the same way. I have tried moving the string array to give it full scope, and still nothing...

public class test extends Sprite
{
// Declare a list of strings
protected var title0:String = undefined;

[Code]....

View 1 Replies

ActionScript 3.0 :: Load Data From Different Variables - The New Variables Come Back As Undefined?

Jun 15, 2010

I'm writing code that takes data from mysql that's processed by a PHP script. It's actually a bit bizarre, at least to me. Anyway, here's some basic AS3 code that's moving toward what I want to do:

var loader:URLLoader = new URLLoader();
var urlRequest:URLRequest=new URLRequest("receive.php");
urlRequest.method=URLRequestMethod.GET;[code]....

For some reason, the statement "trace(evt.target.data);" produces a whole pile of garbled text before the actual stuff that it's supposed to show Because of problem #1, I've had to include a throwaway variable at the beginning, otherwise the first variable I try to pass into AS3 comes back as undefined. This causes errors when I run my flash movie in the IDE, but when I run it from the browser it doesn't seem to have any effect.But this is the strangest thing of all whenever I make any changes to the database (and subsequently try to load data from different variables), the new variables come back as undefined. For example, let's say that I add another entry to the database, and decide to load students 2, 3, and 4 instead of 1, 2, and 3. When I do that, any new data I've added comes back as undefined, even though when I view the PHP output in my browser, it looks just fine.

And now for the REALLY bizarre part: I'll copy that output, paste it into my PHP script as an echo statement, comment everything else out, and my flash movie runs fine. Even though the output from the PHP script is exactly the same, it gives me errors.

View 9 Replies

ActionScript 3.0 :: Change Variables From Class In A Deffirent Class?

Oct 16, 2009

Now I would like to use the variable out of class1 in class2 and change the value there.Afterwords use class2 in the main, but I get an error message. Why?

ActionScript Code:
//class No. 1 "MyClass1.as"
package MyPackage

[code].....

View 3 Replies

ActionScript 3.0 :: Class Variables Passed Into Class With Labels?

Apr 28, 2010

What is the correct syntax to initiate a function in a class similar to constructing an associative array? I have a function that's custom variables is ballooning out and I'd like to label them in the call for sanity sake.

currently:
myClass.myClassFunction("hello world",999,0xff0000);
desired:
myClass.myClassFunction(myText:"hello world",myNumber:999,myColor:0xff0000);

and the class itself for reference:

class com.myClass {
public var myText:String;
public var myNumber:Number;

[code]....

View 6 Replies

ActionScript 3.0 :: Array Variables, Variables Not Working Correctly?

Jul 11, 2011

There is a bird, and you control its upwards movement with a key. It has thrust, gravity, it works fine. The problem is I have a bunch of icicles that come at the bird that he is supposed to avoid. I tried this first with math random to use as an x coordinate and than move across the screen, but the icicles had the same x-coordinates sometimes. I tried does not equal(!=) but that doesn't work. I made an array and each number that came out of the array I assigned a different variable. This works fine. I put this variable into the x-coordinate such as mc.x=((n)*60)+480. I did this for five different icicles. All their differnt variables have a different value, and I put them into the same function for each individual video clip, but they still don't go to the right coordinate. Here is the test code just for the initial coordinate of each icicle before it moves...////////////////////////////Quote:

var temp:Array = new Array()
for (var i:int=0;i<8;i++) {
temp.push(i);

[code]......

View 1 Replies

ActionScript 3.0 :: Create Several Variables To Aasign Each One Of Those Variables One Number?

Apr 9, 2011

i am trying to do a loop to create several variables to aasign each one of those variables one number.when i write

[Code]...

View 4 Replies

ActionScript 2.0 :: Check Variables In MyPictures.onLoad, The Variables Are Always The Same?

Aug 5, 2004

I have 2 loadVars - myVars, myPictures

basically i have defined their onLoad functions

so in myVars, i call for

Code:
myPictures.load("http://www.fakedevil.com/lurgee/pictures2.php?id="+this._parent.link2.text+"&time=" add getTimer(), "");

pictures2.php is working cos I just check so by rite the variables loaded should change.. but somehow each time I check those variables in myPictures.onLoad, the variables are always the same.

View 5 Replies

ActionScript 3.0 :: Load Variables, Remembering Variables

Nov 19, 2008

I am trying to load variables from a text file, and have them available from then onwards in the movie, globally so to speak.

While I can read the variable values in a loader function which executes when the text file is loaded, I don't seem to be able to keep those variables available afterwards.

View 10 Replies

ActionScript 3.0 :: Regular String Variables Vs XML Variables?

Jun 20, 2009

I'm trying to figure out which is more efficient in terms of memory and speed. What I'm doing is having a series of messages loaded to the screen. Is it just faster to write them in string variable or in an XML document which is more versatile in terms of editing and adding on to the document.

View 1 Replies

ActionScript 2.0 :: Append 3 Variables To A Url That Already Has 2 Variables Appended?

Jun 8, 2006

iam trying to append 3 variables to a url that already has 2 variables appended .. iam using the LoadVars -> "send" method but it wont work. it works if i use a url like "form.aspx" but it wont work if i use "form.aspx?var=nun" which is what i need so i can append 3 more variables to that URL.

View 1 Replies

ActionScript 3.0 :: How To Name Variables In Class

Aug 9, 2010

I was wondering how do you name variable in your class? I mean like i give function params and variables names like these:[code]Where the "i" would show the type and so on. So how do you name your variables to make it easier for you to work with them?

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved