ActionScript 3.0 :: Using Static Variable To Create External Classes?

Feb 25, 2011

I've rarely used static variables or methods when creating external classes, but I have on occasion, and it's very useful when I need global access to a value. I've seen negative criticism on the use of the "static" keyword, but never understood why. Is there a right and wrong way of using it, or is this not true? I'd like to use it in a context similar to classes such as MouseEvent or TextFieldAutoSize, where there is a list of values globally accessible for identification purposes.

It allows better code readability, and also allows for easy customization in the future. The value of TextFieldAutoSize.NONE is "none", but as long as a programmer used the reference TextFieldAutoSize.NONE and not the string literal "none", Adobe could change the value of TextFieldAutoSize.NONE to be "hahahahaha" and everything would still work just dandy because (TextFieldAutoSize.NONE == TextFieldAutoSize.NONE) is still true even though ("none" == "hahahahaha") is not.

Is there any kind of negative impact on using static variables this way? Or even functions for that matter? I'd just like to clarify this before I go and build a large project around the idea this is perfectly okay.

View 0 Replies


Similar Posts:


ActionScript 3.0 :: Static Classes And Static Methods?

Feb 21, 2007

Yesterday I found myself wondering, what is the difference between either having a class with methods that are all static, or simply giving your class the static attribute?

View 9 Replies

ActionScript 3.0 :: Alternative To Static Classes?

Feb 19, 2012

At the moment, my main classes game variable, is static, so I can access any class in the game, from any class in the game. However I keep getting errors related to the fact it is static; is there any alternative to this?

View 5 Replies

Xml :: Structure Classes To Avoid Using Static Functions?

Nov 16, 2011

I have a Flash application that creates a sort of powerpoint presentation. All the 'slides' are stored in an XML files which is read and processed.

I'm trying to build the presentation using this XML file. At the moment, my main class has it's initial function main and a static function processXML main initiates my database class with a function called initDB. One of my issues is that initDB forgoes processing because it's dependant on an event listener. On completion of loading the XML files, the event listener initiates my static function on my main to create objects from this file.

The issue is that because the event listener continues the processing (after an indeterminate amount of time), the functions are no longer controlled by the main class.

[Code]...

View 1 Replies

ActionScript 2.0 :: Static Classes Shared Across Multiple SWF's?

Apr 11, 2009

How do Static classes work in projects where child swf's use the same Static class as their parent?

For simplicity... lets say we have some older content swf files that are using TweenLite version 8 ( a common enough Static class.) But the parent SWF is being updated and uses a more recent version of TweenLite (version 10). The child SWF's are loaded into the parent SWF. Do the child SWF exist in there own sandbox and have TweenLite version 8 running and the Parent runs it's own copy of TweenLite 10? Or does the parents clips Static class of TweenLite (version 10) overwrite the children Static class using some sort of magical shared memory space when JIT (runtime) compiling?

View 3 Replies

ActionScript 3.0 :: Dynamically Create Variable In External Class?

Oct 11, 2009

I have a movieclip (listBtn) defined in my document class and need to use it in my view class to dynamically create multiple instances of it in a loop. For some reason I'm getting 1180: Call to a possibly undefined method listBtn but can't figure out why since the listBtn is defined as you can see in the view class [code]...

View 2 Replies

ActionScript 3.0 :: How To Access Static Function From Runtime Classes

Jun 1, 2011

I load many classes in at runtime from external SWF's, accessing those classes is pretty simple, like so -
var currentDomain:ApplicationDomain = ApplicationDomain.currentDomain;
var modelClass:Class = currentDomain.getDefinition(className) as Class;
var model:Model3D = new modelClass();
However I've never tried to access static functions from a runtime class, and now I need to. How is it done? It seems like something that should be simple, but I haven't worked it out yet.

View 3 Replies

ActionScript 3.0 :: Make Application Variable Or Static Variable?

Oct 16, 2010

The Idea is i want to make avariable that stores his value after i close the swf and open ti again,

an example:

i make acounter

var i:int = 0;
var timer:Timer = new Timer(1000);
timer.start();

[Code]....

the value of i will increase but after i close the application and open it again the value will return to 0 , keep the variable stores his value after closing the application ?

View 3 Replies

ActionScript 3.0 :: Classes - Why Static’s (not Available To Any Instances) Properties And / Or Methods Can Have A Public

Feb 17, 2009

I have a question about classes. I just learn that static means that functions and/or properties are specifics to a class, but is it a synonym of private? And why statics (not available to any instances?) properties and/or methods can have a public (available anywhere else (timeline)) access modifier? PS: I just start with classes.

View 6 Replies

ActionScript 2.0 :: Override Static Functions Of Flash Top Level Classes?

Jun 6, 2006

Is there any way to override static functions of Flash top level classes? Lets take Stage or Math for example. What if we want to change Stage.addListener functionality, is there any solution to this problem?

View 3 Replies

ActionScript 2.0 :: Classes - If I Change The Atrribute Instead Of Being Dynamic, To Be Static, It Does Work?

Jul 26, 2006

i'm trying to learn about clases, and i tried to make an easy XML loader, but i gotta a problem with the attributes that doen't take the value i provide with the att variable. it shows me on the trace statement like undefined, and for example if i change the atrribute instead of being dynamic, to be static, it does work.

Code:
class XMLS {
function XMLS(Path:String, textfield:TextField, att:String, n:Number) {
var miXML:XML = new XML();[code].....

View 2 Replies

ActionScript 2.0 :: Create A String Then Use It To Reference A Variable In An External Text File

Jan 19, 2011

So i have an external text file organized like this:

/* $file: data.txt */
&title0=Sacrum
&detail0=Detail text for Sacrum
&title1=L5

[Code].....

There are 28 of these 'title' and 'detail' pairs. The 'title' text is to fill a dynamic text box and the 'detail' to fill another dynamic text box depending on which section the user is mousing over.

My issue is getting the text from the file stored into arrays. For my test loop I keep getting undefined as the stored value, and i know it has something to do with converting a string value to object..

var lv:LoadVars = new LoadVars();
lv.onLoad = handleDataLoad;
lv.load('data.txt');
function handleDataLoad (success:Boolean) {

[Code]....

View 1 Replies

ActionScript 3.0 :: 1195: Attempted Access Of Inaccessible Method Start Through A Reference With Static Type Classes:RollableChar.

Mar 12, 2009

This .as file was working fine yesterday and now Im getting this error.

View 3 Replies

ActionScript 3.0 :: Interacting Classes - 1119: Access Of Possibly Undefined Property DoWork Through A Reference With Static Type Class

May 12, 2009

I have two custom classes in the same package - sGallery and vChange - within sGallery how can I call a function thats inside vChange?

[Code]...

but gave me error: 1119: Access of possibly undefined property doWork through a reference with static type Class.

[Code]...

View 15 Replies

Actionscript 3.0 :: Classes - Error: 1119: Access Of Possibly Undefined Property Web2 Through A Reference With Static Type Class

Jun 29, 2009

I have a site with ScrollPanes, that are calling a Class on what to display. (so the movieclip that I want displayed in the ScrollPane has a Class name.) Within that movieclip (webScroll) that is being displayed in the scrollpane, I have 2 other movieclips (web1 & web2), with unique instance names and eventlisteners targeting those instances. when I preview my site, i get this error: 1119: Access of possibly undefined property web2 through a reference with static type Class.

View 1 Replies

ActionScript 3.0 :: What Is Static Variable

Apr 13, 2011

What is static variable. what is difference between  static variable and public variable?

View 2 Replies

ActionScript 3.0 :: Make Function In To A Static Function And Call It From Other Classes

Sep 23, 2009

this is the function i want to turn in to a static function. just dont know how to make it a static function and call it from other classes. i think this would have its own file.

[Code]....

View 2 Replies

ActionScript 2.0 :: Create A String Variable...and Then Use The Value Of That Variable To Declare Another Variable?

Jan 3, 2006

f you know PHP...then you know that you can create a string variable...and then use the value of that variable to declare another variable. like this:

PHP Code:

<?php$foo = "haha";$i{$foo} = "success";print $i{haha};?>

and it would display "success"...or like this:

PHP Code:

<?php$foo = "haha";$$foo = "success";print $haha;?>

and it would also display "success".

View 6 Replies

ActionScript 3.0 :: Keeping A Static Variable Within A Loop?

Feb 7, 2011

I need to keep my "grid" + [o] value from 1-9 but add to the to the gridArray number (hence currentNo) within this double loop.

[Code].....

View 10 Replies

Actionscript 3 :: Variable That Refers To A Static Class?

Nov 10, 2011

How can I replace

public function Mainclass()
{
Calculations.getDistance(5,9,4,2);
}

[Code]....

I'm not lazy (lying? :p), but I use the class more than 20 times, and it looks better if I replace al these long classnames.

View 1 Replies

Flash :: Static Variable Showing As Null

Feb 13, 2012

I have a class named Locator that I use to GeoLocate a user. There's a static method in that class called "locate()". This method then calls another method which sets a static variable called "loc" to an instance of a LngLat class.The issue I'm having is, when I call the locate method at Frame 1 on the scene, and then try to access the loc variable it shows as null... but when I trace the loc variable after it's set in the Locator class it shows as an object.[code]and then trace the variable at the end of the static method in the Locator class it shows as a object and the city is traced as expected.

View 1 Replies

ActionScript 3.0 :: Using A String To Call A STATIC Variable?

Sep 26, 2010

It is possible to call variables using this[ "stringname" ] for instance, to refer to a variable called "stringname".

However, when referencing a static variable by the name "stringname", the "this" attribute no longer works if applied.

Is it possible to use this technique with statics?

View 5 Replies

ActionScript 2.0 :: Current Time As Static Variable?

Oct 7, 2008

I've been trying to create a script that pulls the current time and turns it into a variable, the problem is the variable keeps updating as the time changes, where as I need it to remain static as the time that is was when the variable was first created...it's just a simple:

Code:

var theTime = today.getTime();

View 2 Replies

ActionScript 3.0 :: Accessing A Static XML Variable From Within A Switch Statement

Jun 1, 2009

In the following class

Code:
package
{
public class Factory
{

[Code]]....

A break point on the "Okay" line shows that x1 is null but x2 is equal to "<entity id="DRONE" points="100"/>".

If I take the whole block out of the switch statement, both x1 and x2 are equal to the expected xml.

View 6 Replies

Flash :: Access Of Undefined Property (Static Variable)?

Jul 12, 2011

I'm trying to change a static variable in the class's constructor. At the start I have:

public static var mainReference:Main;
public static var timerReference:Timer;
public var timer:Timer = new Timer(1000);

This is so my static functions can access main and timer. At Main's constructor I have:

mainReference = this;
timerReference = timer;

The problem is, the first gives no error when I compile it, but the second tells me Access of undefined property (timerReference).

View 1 Replies

Flash :: Dynamic Variable Names In Static Function?

Dec 14, 2011

Is there any way that you can have dynamic variables inside of a static function considering that you can't use "this" inside a dynamic function.

What I am trying to do:

public static function convertToDynamicString(pString:String):String
{
if(pString == "" || pString == null) return "";

[Code]....

View 3 Replies

ActionScript 3.0 :: How To Create A Static Class

Oct 17, 2009

I need to created a static AS3 class to pass variables between modules/ views. For some reason I don't see how to do this in my book or on Adobe. I want a class of "get" and "set" functions.

View 9 Replies

IDE :: Create Static Text In My FLA File?

Nov 11, 2009

I have created a static text in my FLA file and for some reason when I convert it to a movieclip symbol, my setting of the text - such as the letter spacing - are no longer. It scrunches together and looks pixelated. Any knowledge as to why? It was not doing this a while ago but I don't see what I have changed!

View 6 Replies

Professional :: Access Timeline Variable From Static Class / Singleton?

Nov 3, 2010

How can I access a timeline variable from a static class / singleton?

View 14 Replies

Actionscript 3 :: Why Is Static Class Member Variable Not The Same When Accessed From Different Parts Of App

Apr 5, 2010

I have an actionscript class with a static member variable defined.

public class A
{
public static var x:int;
}

When I try to access it from different parts in my code I don't get the same value in each spot.

A.x

I am accessing the variable in different modules that are loaded, so they are all in their own separate .swf file.

View 1 Replies







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