Actionscript 3 :: Is There Any Advantage To Using Properties Over Public Variables

Jun 14, 2011

This might be a very stupid question, but I have to ask it anyway. I am graduating in about a month and while studying, I have always been taught to use properties instead of public variables. So I started wondering what the advantage was and I must say that in some cases, I have no clue at all. Of course it is handy when some other logic needs to be executed when setting properties or getting properties, but is there any advantage to using properties when you are only getting/setting a variable? An example of what I mean is shown below (As3).

[Code]...

View 2 Replies


Similar Posts:


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.0 :: Is It Really THAT Bad To Use Public Properties

Jul 26, 2011

So the reason I'm asking is..I have like 2000+ lines of code in 5 different separate classes. And they ALL have public properties and methods (as in, ALL the properties and methods are public). This is a fairly complex tile game 2d platformer. And yet everything is working fine. From what I've read, it seems that it 'MAY' cause problems later, where you might make a mistake and call a property twice, or call it 'wrongly', which then 'MAY' cause a bug that would be hard to backtrack.

There are surely many other reasons why not to do this..but if everything is working smoothly so far, should I really go back and try to make every variable private and recode this engine before I get to far?

View 8 Replies

Actionscript 3 :: Overriding Properties Of Public Field?

Aug 6, 2011

I have a custom button with a textfield inside:

package com.company.utils.ui
{
import flash.display.Shape;

[Code].....

But my problem is that I need to do something else (call a private customButton private method) when I assign a text to label.

playButton.label.text = "myText";

View 2 Replies

Flex :: Access The Public Properties And Methods Of A Loaded SWF

Mar 18, 2011

How would you go about calling the public properties and methods of a SWF you load in actionscript?

I have been using stackoverflow for years to answer my programming questions so I wanted to give back by writing a guide to an issue I had a lot of trouble figuring out. This is my first user guide so tell me if there is anything I can do to improve it.

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 3.0 :: Unable To Access The Public Properties Of Custom Class

Nov 28, 2008

i wonder why i am unable to access the public properties of this custom class the public var w:Number; and the Public var h:Number; i am tracing them and on an instance of the PreLoader() Class.. and ia m getting NAN;

View 12 Replies

Flex :: Getter And Setter Methods Versus Public Properties

Jul 27, 2009

Which is a much better practice in binding a value in Flex?

View 2 Replies

Flex :: Undefined Public Variables - Value Of MyVar?

Oct 11, 2009

I have a class like this..
public class Doc {
public function Doc():void {}
public var myVar:Boolean;
}
How can I know if the value held by myVar is default false, or someone has assigned false to it? Isn't there an undefined state? How can I achieve such a thing?

View 2 Replies

Actionscript 3 :: Use MouseEvent For Getting Object`s Public Variables?

Sep 5, 2011

I have a simple problem which is not easy at the moment. this is a text field class which add a text field to a movieclip (passed from root class) and also save(buffer) some data (like xml file name) in it`s public variables:

package src {
import flash.display.Shape;
import flash.display.MovieClip;[code]............

.. now I use a for loop to add instance of that class to a movie clip on stage:

for (var i:int = 0; i<Bunker[0]["trans0size"]; i++) {
menuData[i] = new menuitem00(i, menu_mc, Bunker[0]["transfile0" + i]);// pass i , a movieclip named menu_mc and an xml file name
menuData[i].name00 = Bunker[0]["transtitle0" + i]; // pass text
menuData[i].activateFlag = true; // set actveFlag to true
menuData[i].init(); // run init() inside the instance. it adds textfield to the menu_mc and also set name00 as Text for the textField
}[code].........

I want to get "xml00" var from that instance on the stage by mouse click but, trace (evt.target.xml00); is not working .. also trace (evt.target.name00); is not working. I can get everything like .alpha or .text from txt00 but not other variables in my object.

View 1 Replies

ActionScript 3.0 :: Public Variables From Init Space?

Nov 10, 2010

I have a bunch of variables I need to pass to some class from frame where I instance classes. Is there any other way do make Class read that variable values beside this?

Sample:

ActionScript Code:
var _imgPaddingVert:Number  = 2;
var _imgPaddingHor:Number   = 3;
var _minTopMargin:Number    = 30;

[Code].....

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

ActionScript 3.0 :: Private Static Properties With Public Static Getters/setters

Oct 22, 2009

how bad is this practice? I am having trouble getting to some stuff so i am taking the easy way out

Code:
private static var _interrupted:Boolean;
public static function setInterrupted(value:Boolean):void{
_interrupted = value;
}

View 1 Replies

Actionscript 3 :: Calling Private Functions By Changing Public Variables?

Jun 13, 2010

i've never tried to do this before, so my head a swimming a bit. i'd like to have a public boolean called enabled in myClass custom class. if it's called to be changed, how do i trigger a function from the change? should i add an Event.CHANGE event listener to my variable?

View 1 Replies

ActionScript 3.0 :: Using Variables In Properties?

Jun 8, 2009

I'm trying to craft a simple image gallery with 6 thumbnails on the left and a large image container on the right. I've assigned a MOUSE_OVER listener that executes the following function when activated:

Code:
function viewLargeImage(evt:MouseEvent):void {
var imageName:String = evt.target.name + "_large";
this.mc_tabRight.imageName.visible = true;
}

The instance names of the thumbnails are img1, img2, and so on, and their larger counterparts are img1_large, img2_large, and so on. When the MOUSE_OVER occurs, the larger version becomes visible. The gallery is within a movie clip (mc_tabRight; a tab that pulls out from the right side).So in my mind, the second line of the function should make visible the instance passed from the variable in the first line based on the rollover. I tested the code using trace("imageName"); and it returned the correct instance name, but when executed and the thumbnails rolled-over, it returns this error: TypeError: Error #1010: A term is undefined and has no properties.

The larger images are all present on the stage when the function is called. I'm sure I'm making some fundamental error here,

View 2 Replies

ActionScript 2.0 :: Can Properties Be Replaced By Variables

Apr 20, 2007

What I am trying to do is write a class that could function on the x axis, or y axis, so when an instance of the class is called, the axis is specified. For example:

Code:
Scroll:ScrollFunction = new ScrollFunction(_x, MC);
class ScrollFunction {
function ScrollFunction(axis, targetMC) {

[Code]....

That's a very simplified version, but you get the idea. This won't work though because although Flash recognizes 'axis' as being equal to '_x', it does not recognize 'axis' as a property.

All I want to know is if it is possible or not. I could, of course use an if statement, but that would mean I would have to have to write the function twice, once for each axis, which is what I want to avoid.

View 5 Replies

ActionScript 3.0 :: Take Advantage Of FP 11 New Features?

Oct 18, 2011

I'm compiling with the SDK 4.5.1 (latest I think) in FlashDevelop, and I have the settings of the project to export for Flash Player 11. I also have set the wmode param to "direct", and my browser flash player is version 11 also.

Is there anything else I should do in order to use the Flash player 11 hardware acceleration features. To be honest... I can not see any difference in my game between flash player 10 or flash player 11...

View 3 Replies

Flex - Advantage Of Using Mx:Text Over Mx:Label?

Aug 18, 2011

What is the advantage of using mx:Text over mx:Label in Flex?

View 1 Replies

ActionScript 2.0 :: Advantage Of Using XML Over Text Files?

Apr 26, 2006

Is the only advantage that you can now create the XML files using a database, or a script,Or is there something else? Because reading the XML files (through AS) isn't easy at all !

View 14 Replies

Actionscript 3 :: Unexpected Behavior Accessing Properties Of Script Variables

Nov 7, 2011

I tried to execute the following actionscript3 program and I am surprised of the result of the call to f() function. I was expecting that the result of f() was "1" or at least "undefined" but the "0" value does not makes any sense for me. I will be pleased to have a good explanation of this behavior if you have one, or to know if you consider this behavior as "normal". I want to precise that I'm studying the behavior of Action Script programs in order to understand how the AVM2 really works and therefore I am not asking equivalent code to do the same thing. As a consequence if you have other tricky examples I am also interested.

[Cdoe]..

View 1 Replies

ActionScript 2.0 :: Load Variables From A .txt-file To Edit The Properties Of A MovieClip?

Feb 26, 2002

I want to load Variables from a .txt-file to edit the properties of a movieClip. For example: 700 is written in the .txt-file. After loading the Clip the x-position of the clip should be set to 700. How can I do this?

View 14 Replies

Flex :: Advantage Of An Adobe AIR App Over A Traditional Desktop App?

Jun 3, 2010

I'm pretty familiar with using Adobe Flex & AS3, and compared with writing apps in JS/HTML I think it's very cool. However, since AIR is essentially a non-browser version of Flex with benefits like local storage, it seems to be competing as a cross-platform desktop application platform... and in that space it's much less mature than more established desktop technologies.

So what's the advantage of creating a desktop application using AIR compared to something like Java (or C++ using a cross-platform GUI library like wxWidgets)? Java's equally capable of communicating with the server for instance, I'm not quite sure what AIR adds when competing head-to-head in the desktop development world?

View 5 Replies

ActionScript 3.0 :: Advantage/disadvantage To Designing Multimedia ?

Jun 3, 2011

Is there an advantage/disadvantage to designing multimedia (for example a simple animation with music) using fully as3, or is it the same as using the the editor (timeline)? will it boost performance/speed to code the tweens, clips and textfields?

View 2 Replies

ActionScript 3.0 :: Advantage To Store Loaded Images Into A Sprite?

Mar 10, 2011

Is there an advantage to store loaded images into a sprite?
 
var container:Sprite = new Sprite();addChild(container);var pictLdr:Loader = new Loader();var pictURL:String = "banana.jpg"var pictURLReq:URLRequest = new URLRequest(pictURL);pictLdr.load(pictURLReq);pictLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);function imgLoaded(event:Event):void{     container.addChild(pictLdr.content);}

View 13 Replies

Actionscript 3 :: Advantage / Disadvantage Of Using Weak References In EventListeners?

Aug 5, 2009

I've been teaching myself actionscript 3 over the past month or so and recently ran into an issue where an object kept doing things after I thought it had been removed. I figured out that the problem was caused by an event listener using the default of useWeakReference = false and I'm wondering why that's the default. what is the advantage to not using a weak reference? and why is that the default? it seems to me that in general you'd want to use weak references, so I must be missing something.

View 4 Replies

Actionscript 3 :: Any Advantage In Using Vector.<Object> In Place Of A Standard Array?

Jan 17, 2012

Because of the inability to create Vectors dynamically, I'm forced to create one with a very primitive type, i.e. Object: var list:Vector.<Object> = new Vector.<Object>(); I'm assuming that Vector gains its power from being typed as closely as possible, rather than the above, but I may be wrong and there are in-fact still gains when using the above in place of a normal Array or Object:

[Code]...

View 3 Replies

ActionScript 2.0 :: Use Local Instance Variables Vs Attach New Properties To The Instance Object?

Mar 14, 2006

I am wrapping my brain around OOP in AS2. I am making two posts on two different subjects. My question here is: when should I use local instance variables, and when should I attach new properties to the instance object? (Feel free to correct my terminology.) Let's say I have a class for a scrolling background, which scrolls when I mouse over its edge. I want to put these values somewhere:

1) How wide is the border in which a mouseOver makes it scroll? This is basically a semi-constant I set it up once and keep it the same, unless the user changes it in an options menu to make the border wider or narrower. Call this scrollBorderWidth.

2) How fast is the background scrolling now? I want to track this so I can smoothly change the scroll speed over several frames. This is often changed. Call this scrollSpeed.

It seems I have two ways I can store and access these values and darned if I know which is better practice. METHOD A: Make them local variables in the class, so the scrolling background instance has them as local vars. I set them up thusly:

[Code]....

View 4 Replies

Media Server :: Advantage Of Writing A SSAS File Over An External AS3 File?

Jul 23, 2011

I do understand the differance between ssas and as3. Not all, but all most everything I see written in SSAS can be writen into a external AS3 file. This leads me to quite a few questions I'm hoping you kind people can shed some light on for me.
 
1)  What is the advantage of writing a SSAS file over an external AS3 file?
 
2) Can I write an .asc file in AS3 or do I have to use AS1? Please understand I'm using tuts from fmsguru.com and the books "Learning Flash Media Server" (pdf) and "Programming Flash Communication Server". I'm not a javascript programmer so nothing I do in AS1 seems to make any sence while everything I do in AS3 does. It may not seem like it to you people that are programmers, but to those of us that aren't, AS1 and AS3 are miles apart.
 
3) kind of off topic, but a security question. I'm not a "hacker" and don't like the jerks that are. My question is on external AS / SSAS files and swf files. When my fla is compiled into a swf does my external AS files remain external? I assume they do, but then what is the threat of the swf being decompiled? In most projects I would do I could care less if somebody had access to my fla as long as they don't have my actionscript files.
 
I don't know. Maybe on questions one and two I'm getting confused becasue I'm using out dated material. Again I assume that even though fms was built off of the javascript engine it should be able to read and execute my AS3 file. Other wise what was the point of the evolution of actionscript into a fully functional programming language?

View 1 Replies

ActionScript 2.0 :: Set Properties - Get Properties - Change An Mc Name Dynamically?

Sep 14, 2005

Just been playing around with the tutorials, on the Set properties/Get properties. Everything is all cool, except the "instance name" aspect. I dnt really understand that too well. Is it possible to change an Mc Name dynamically? If you look at my FLA when you hit the top left red button you will get a trace of the mcName as "square". Now if you input a new mc Name on the right hand side, you will see it change on the left hand side. But i want to know why it doesnt remain as the new mc Name, it still goes back to square.

View 3 Replies

ActionScript 2.0 :: Trace The Properties Of An Object's Properties?

Jan 30, 2008

I forgot to put it in the title so I'll just place it here; I am using AS 2.0. I know that there are other ways to accomplish the goal that am after, but I was wondering if anyone knows of a way to access the properties of an object's properties?

Here is the code that I thought of, even though it doesn't work

var a:Object = new Object();
a.bproperty = 0; //lowerlevel properties
a.cproperty = 1; // lowerlevel properties

[Code].....

This really just boils down to how I am organizing the code(I have ideas on what do next, and i am 99% sure that I can get them to work), and if there is a way to dynamically access the properties of the objects properties, It will save me from creating yet another large block of code for my project. If you want to see the unfinished project, go to [URL]

View 3 Replies







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