ActionScript 3.0 :: Is It Good Practice To Use Static Variables?

Feb 5, 2010

I've always used this way to refer to variables on my document class
Code:
MovieClip(root).variablename
But that complicates things because I would need to extend my class as a displayObject and then add it to the displaylist to be able to use "MovieClip(root)" to access the variables in my document class.. as long as variables in my document class are set out as public variables..

I didn't realise you could refer to variables on the document class by just using something like:
Code:
documentclassname.variablename
With the the variable on the document class as "public static var". This solves a lot of problems.. as now I do not need to keep adding objects to the displaylist to get access to the document class variables..

Now.. My question is..Since I want to access most of my variables on my document class.. I would need to set them all to "public static var".. Would setting 100 or so variables to "public static var".. have any disadvantages? Like performance issues... Or anything else which may make it not be as efficent if I were to keep them simply as "public var" and use "MovieClip(root).variable" to access them?

View 10 Replies


Similar Posts:


Visual Studio :: Good Programming Book With Good Working Examples And Is Tutorial Approach

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

Actionscript 3 :: Get All Static Variables In A Class?

Mar 17, 2011

I have this ObjectType class which is a class to help me do something like this:

object.type = ObjectType.TWO
//ObjectType.as
package

[Code].....

View 4 Replies

Actionscript 3 :: Prototypes - Are They Just Static Variables?

Sep 13, 2011

A reference to the prototype object of a class or function object. The prototype property is automatically created and attached to any class or function object that you create.This property is static in that it
is specific to the class or function that you create. For example, if you create a class, the value of the prototype property is shared by all instances of the class and is accessible only as a class property.Instances of your class cannot directly access the prototype property. A class's prototype object is a special instance of that class that provides a mechanism for sharing state across all instances of a class. At run time, when a property is not found on a class instance, the delegate, which is the class prototype object, is checked for that property. If the prototype object does not contain the property, the
process continues with the prototype object's delegate checking in consecutively higher levels in the hierarchy until Flash Player or the Adobe Integrated Runtime finds the property.

Note: In ActionScript 3.0, prototype inheritance is not the primary mechanism for inheritance. Class inheritance, which drives the inheritance of fixed properties in class definitions, is the primary inheritance mechanism in ActionScript 3.0.

from this I get the impression that prototypes are just static variables.. am I right?

View 1 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

ActionScript 3.0 :: Static Variables Strange Behavior?

Feb 22, 2011

I'm a .net developer making a small website on Flash. I noticed that when I initialize a static variable during runtime in one place I cannot get its new value at another place, why?

View 2 Replies

ActionScript 3.0 :: Accessing Static Variables Using The Class Name Itself

Jun 18, 2009

Say I have a class called Ball (movieclip) and I create a number of instances of it. There is a static variable, say, ballArray and need to access that from a different class, say, Bat. How do I go through with it? Can I access that using the class name itself (Ball.ballArray like in Java)?

View 1 Replies

Flash :: Referencing Static Variables From Frame Scripts?

Oct 27, 2009

Got some external classes, say MyClass.as MyClass.as has a static variable called foo

So, ordinarily in other AS files I can call this with MyClass.foo = bar;

However, this seems to be different in timeline scripts. Every time I try this I get the reference with a static type error 1119: Access of possibly undefined property foo through a reference with static type flash.display:DisplayObjectContainer.

I've tried doing an import MyClass, etc... nothing seems to be firing.

View 1 Replies

ActionScript 3.0 :: Imported Class Reference And Static Variables

Jun 8, 2010

I'm trying to make methods available like so:
ActionScript Code:
MyClass.myFunc();
Instead of
ActionScript Code:
var myVar:MyClass = new MyClass();
myVar.myFunc();

I know that to do so I need to declare the functions/variables/constants as static:
ActionScript Code:
package MyPackage {
public class MyClass extends Object {
public static function myFunc():void {
} public function MyClass() {
[Code] .....

When I try to access the static function through the full reference (i.e trace(MyPackage.MyClass.myFunc);), it works, while trace(MyClass.myFunc); returns undefined. This contradicts what I've read in tutorials and posts on the Internet. They all use the short syntax, not the full path.

View 9 Replies

Actionscript 3.0 :: Access Public Static Variables In A Loaded Swf?

Feb 27, 2009

I'm literally new in AS3 and slowly trying to migrate in thats why im here seeking for help. Can someone help me how to access/control a certain public variable in a loaded swf from the main swf? this problem has been paralyzing me for days. (sigh...) [code]...

View 1 Replies

Flex :: Debugging Or Watching Static Variables Within Flash Builder 4

Dec 16, 2010

When I set a breakpoint and debug my application, Flash Builder 4 is not displaying static variables within the variables window. I'm using flash builder 4 to execute flex unit tests on one of my AS3 classes. I set a static variable within the [Before] function, which is accessed in each of the tests. I've set a breakpoint within one of the tests to see why it is failing, but I notice that static variables don't appear when I expand the 'this' object within the variables window. (In this case my static variable is the only variable associated with the class, so the only object in the variables window is the "this" object). How to make static variables appear in the variables window?

View 2 Replies

ActionScript 3.0 :: Global Variables: Singleton Versus Static Vars?

May 29, 2009

pros and cons of either using a Singleton that enforces only one instantiation of itself, versus creating one common class with static vars which can be accessed by all other classes that import it?

In my testing, importing but never instantiating works fine. I can even change the value of one of the variables and then have another class see that changed value later on in the program.

If I *know* I will never actually create an instance of my Global class using the New command (but will instead just reference the variables using the class's name), then why should I need to make it a strict Singleton?

View 9 Replies

ActionScript 3.0 :: Static Variables - Access Of Undefined Property OtherClass

Jan 29, 2011

I get this error 1120: Access of undefined property OtherClass.

Ths is the code:
Code:
public class SomeClass extends MovieClip {
function SomeClass():void {
} public function SomeFunction():void {
var i:int = OtherClass.myVar;
trace(i);
}}

Code:
public class OtherClass {
public static var myVar:int = 2;
public function OtherClass():void {
}}

View 4 Replies

ActionScript 3.0 :: Accessing Static Variables Of A Super Class Through A Subclass?

Aug 10, 2011

I'm trying access a static variable located of a super class through an instance of one of it's subclasses and I'm receiving an access of undefined property error (example of which below).  Creating another static variable in the subclass and assigning the value from the super class will allow me to dot operate to it. 

[Code]....

View 1 Replies

ActionScript 3.0 :: Use Public Variables Or Public Static Variables?

Feb 4, 2010

is it better to use public variables or public static variables?

View 6 Replies

Actionscript 3 :: Best Practice About Xml Deserialization In It?

Mar 31, 2012

What is the best practice about xml deserialization in ActionScript 3?

I'm developing a real time multiplayer Facebook game. I prefered writing client side with Flash. Beside, server-side is written with Java. Communication between server and client is provided with "socket".Server and client sends xml to each other. As might be expected those Xmls contains "objects" which are derived from classes located in both side.[code]...

View 1 Replies

ActionScript 3.0 :: Displaying Movieclips Best Practice?

Dec 11, 2009

I am working on a new project involving displaying and playing different movie clips depending on choices made by the user. What is the best aproach for this sort of thing, ie addChild/removeChild or visibility or whatever?

View 1 Replies

ActionScript 3.0 :: Best Practice For Multiplying Swf In Flash Page?

Oct 16, 2010

In my page i use animated swf for button. And at the moment page knows how many buttons there needs to be via category nodes in xml so i made a loop to load in the right number of same swf-s. Is there a bettery way to do that like load swf only once and than duplicate it via script?

View 4 Replies

Silverlight :: Which Is The Best Design Practice For Edit Data In RIA

Feb 26, 2011

First of all it is a UI design question Which is the best design practice for edit data in RIA, for example in Flex or Silverlight? I would like to show customer's details, but there will be an edit window, than the datas of customer will be editable. I would like to show a new form where the data can be edited. What is the simplest way to show this form. I can make my ui tabbed, so I can open the form in a new tab, or I can open the form in a popup/modal dialog (Save-cancel). Maybe I can use in line editing. What is the most user friendly solution in a Silverlight or Flex GUI? What is your opinion?

View 3 Replies

ActionScript 3.0 :: Db In Flash Or Best Practice Data Store

Nov 9, 2009

I have a particular problem where I normally would use a db and php for back end but in this case I cant. its a small app that would consist of 4 tables category, price, product, and product_association. the product_association would store which category and type the products are associated with. so as an example if you have cars. you might have off road as the category the cost would be 20-25k could be suv. now a product can belong to more then one category but only one price. trying to figure what the best way to simulate a relational database with in flash. thinking objects, arrays, how to do the relationships.

View 0 Replies

ActionScript 3.0 :: Best Practice For Multiplying Swf In Flash Page

Oct 16, 2010

In my page i use animated swf for button. And at the moment page knows how many buttons there needs to be via category nodes in xml so i made a loop to load in the right number of same swf-s. Is there a bettery way to do that like load swf only once and than duplicate it via script?

View 2 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

Web Development :: Using Flash On A Website Homepage Considered Bad Practice?

Jan 6, 2010

We are revising our company website and I wondered if it considered bad practise to use flash on the home page.This would cause issues for those users who dont have flash installed (and maybe dont want flash)

View 3 Replies

Actionscript 3 :: Practice Making A Simple Video Phone?

Apr 29, 2011

I'm trying to practice making a simple video phone app so I'm trying to make a program to send a video and recieve a video using Cirrus from Adobe. I'm having trouble recieving the stream though. Here is the cod that I'm using:

[code]...

Inside of the getVideoReveiver() function I'm getting the flag to go off from writeText("flag") then I get and output in the text box of:

NetStream.Play.Reset
NetStream.Play.Start

from the netStreamHandler, but the video never shows up in the receiving video element.I'm running this is two different videos of the same computer and taking the nearID from one stream and pasting it into the textInput theirID. I'm not sure what to try next?

View 1 Replies

ActionScript 2.0 :: Where Is The Drawback To Just Making _global Standard Practice

Mar 4, 2004

I recently read an article about prefacing your variable w/ _global. And I think it rocks!hy is this practice taboo?Why do so many tutorials insist you remember the scope of every movie clip?It seems to me that memory space is memory space

View 2 Replies

ActionScript 3.0 :: Best Practice : Keep Track Of Multiple Dynamic Buttons?

Feb 13, 2009

Using the for loop i create many buttons and add events to them;

[AS]
for (var j:Number = 0; j < all_objects.length; j++) {
var dump = new Sprite ;
dump.graphics.beginFill (0x41C5D2,.5);// flash button color default=0x41C5D2[code]....

I need to know which button is pressed, so i use the (tricky) unprofessional methode: event.target.name.the question is; how can I know which button is pressed, using a custom event, this custom event should pass some vars to the called function, including the j var (from the loop)actually I tried setting a custom event using the example at the noponies accordion menue class, but it's so complicated to get working.

View 5 Replies

Professional :: Best Practice For Speeding Up Animation - - Increase The Frame Rate

Mar 5, 2010

What would be best practice for speeding up an animation? - Increase the frame rate, or is that considered cheating (already set to 25)? The alternative would be to manually adjust the length of the tweens on each layer.

View 2 Replies

Media Server :: Live Stream Reconnect / Disconnect Best Practice

Apr 19, 2010

When streaming a live event through FMS 3.5, is there a list of guidelines or best practices to handle the situation when the stream disconnects and should reconnect.Basically, what I do now is wait 20 seconds after the initial disconnect, then close the stream and ask the user to ty to reconnect to the stream again.

View 3 Replies

ActionScript 3.0 :: Toggling Video Fullscreen And Positioning Videoplayer UI - Best Practice?

Oct 12, 2011

I've landed a project which is centered around building a custom video player with some special functionality (so I can't just use the default Flash video player, unfortunately). I have two small 'problems' in the sense that I could probably solve them myself, but I'd like some input on best practice for solving them: (The project is for Flash Player 10 and the video is intended to run inside a browser.)

Problem 1: Toggling between normal / fullscreen playback Ok, so my custom video player needs to be able to toggle between fullscreen and normal embedded-in-webpage player size. How does fullscreen toggling currently work in AS3 -is there a specific AS3 method for fullscreening a specified video object in the swf (without stretching the video player UI overlay), and if so, does it automatically black out the background if the screen format doesn't match the video format? - or do I need to download a class for this?

Problem 2: Positioning video player UI when going fullscreen As opposed to YouTube, I want the player UI to still show up when the video is toggled to fullscreen mode - but as mentioned above, I don't want to stretch its size along with the video. So is there a best practice for repositioning the video player UI to the vertical bottom and horizontal center of the screen when the user clicks full screen? I'm not entirely familiar with what happens to the Flash stage when it goes full screen, How to deal with not knowing the coordinates of the vertical bottom/horizontal center when screens have different ratios and resolutions?

View 3 Replies

ActionScript 3.0 :: Best Practice - Recommended Order In Which To Arrange The Imported Classes?

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







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