ActionScript 2.0 :: Difference Between Private And Public Method In Custom Class
Jun 12, 2007
I have this sample class
Code:
class TestPrivate{
public function TestPrivate(){};
private function getGo(){
trace("can execute");
}}
And then after instantiate I just calling the method...for testing the "public" and "private" keyword purposing only...
Code:
import TestPrivate;
var obj1 = new TestPrivate();
obj1.getGo();
The result is still can be execute even though I put the private keyword in front of the methods. So what's the private keyword stands for actually...I thought it prevent been get accessed from outside...
View 2 Replies
Similar Posts:
Sep 10, 2004
Im just starting to get my hands into Action Script v2, and Im having a really hard time working out what the difference is between Public, Private and Static Variables, it seems that declaring variables in these types makes no difference what so ever to the avaliablility of my variables... Could someone be so kind as to put me on the right path?
View 2 Replies
Jul 31, 2010
I have .fla file where I have instantiated an object of a class( testclass.as ) like this in frame 1
[Code]...
View 9 Replies
Jul 24, 2010
Why static method cant access private properties in the same class?
View 1 Replies
Jul 16, 2009
I have to know if a public method has been called from outside the class or from inside. The reason is that depending on this, one of the actions to be executed in this method vary a bit.
View 3 Replies
Feb 2, 2011
is there a difference between classifying a function 'private' or 'private static' in a singleton? It seems that they both do the same thing. Maybe some difference in performance?
[Code].....
View 10 Replies
Aug 22, 2010
I have two SWFs: main.swf and external.swf. main.swf needs to access some methods in external.swf, so it loads external.swf into itself and uses getDefinitionByName("package.Class") to access the class and one of its methods:
var ExternalClass = getDefinitionByName("package.Class") as Class;
var ClassInstance = new ExternalClass();
var NeededFunction:Function = ClassInstance["NeededFunction"] as Function;
var response:String = NeededFunction(param);
Now, I need to extend the functionality of NeededFunction (which is a public method)... I know it's possible to override public methods, but how would I go about this with a dynamically loaded class?
I was thinking I could do something like this, but it doesn't work:
var ClassInstance["NeededFunction"] = function(param1:uint):String {
var newString = "Your number is: "+param1.toString(); //New functionality
return newString;
}
View 2 Replies
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
Jan 25, 2009
what does public and private mean in this statement and when do I need to use it?this is not my code just using it as an example.
package {
import flash.display.Sprite;
import flash.net.URLRequest;
import flash.net.URLLoader;
[code]...
View 5 Replies
Feb 15, 2011
I have written a framework that facilitates RPC calls between AS3 and PHP 5 called FlashMOG. I recently got a forum request that has introduced a pretty bizarre question regarding access control. This will be a lot easier to discuss if you have access to the FlashMOG 0.3.1 client source which is here:
[code]...
The basic idea is that I have a FlashMOGService class which has an RPCSocket member that it may share with other FlashMOGService objects. The idea is that you can create two distinct FlashMOGService objects and have them both connect to the same host/port via socket. I use my special RPCSocket class for two reasons:
1) Let developers use one port but separate functionality into two distinct services...a form of multiplexing i guess
2) RPCSocket adds functionality to the standard Socket class that works to serialize and unserialize data and get it where it needs to go. The essence of the problem here is that created a class with a FlashMOGService object as a member and has tried to assign a private method of his class as an event handler to the FlashMOGService object:
[Code]....
My initial thought is that this should be fine because it's all done within the class. However, when I consider the monkey chain that results in this function being called, it seems almost logical that it wouldn't work. The problem is that the browser freezes when a socket message arrives that tries to call the service's client method, _service.client.firstClientMethod. This client firstClientMethod is attempted when data arrives from the server on the Socket (an RPCSocket, actually). The RPCSocket class deserializes the socket data and extracts an array with a service name, a method name, and an array of arguments. It looks into its own private class variable (an array of services using the RPCSocket) and tries to invoke whatever function was assigned thusly:
[Code]....
I'm guessing there's some kind of infinite loop going on to check access control for the various intertwined classes.
View 5 Replies
Jan 3, 2011
Is it possible to add my own custom property to the flash.display.Bitmap using a public static method? I'm trying to write a bitmap utility that does something to a bitmap, and stores a Number property onto it afterwards.
[Code]....
I'm still learning AS3.0 OOP, I think that this can't be done with this method. I think I have to make a new Class that extends 'Bitmap', add the prop there, and then in the Main.as make a new instance of that class, point to the target Bitmap, and run the method in the extended 'Bitmap' class (?).
View 6 Replies
Feb 25, 2005
In my project I've defined a Point class to build Point objects. I also built a Polygon class with a (private) array property, Points. The polygon class contains a method getPoints() which return the current Points array. My objective is to built one or more Polygon objects and assign several Point objects to the Polygon's Points array. Let's say I've created two Polygon objects, plgPolygon01 and plgPolygon02. To both objects I insert three new Point objects into the Points array.
As I call the plgPolygon01.getPoints() method, i expect to get an array with three values. But when I do this, I get an array with six values. So I conclude: while I was inserting Point objects into the Points array of a Polygon object, this Points array seems to be public instead of private. Otherwise, I'd only get the Points I assigned to the first Polygon object and not all the Points assigned to polygons.
View 3 Replies
Jul 26, 2010
How to configure Public and private IP address in Flash Media Server?
View 6 Replies
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
Jan 20, 2011
I am developing a chat server were my users log in using any of my clients applications with a very simple implementation of the TCP protocol. When the user logs into, the client sends a raw text to the server indicating some parameters like username, others, and the most important the WAN ip. This data gets stored on ther server database. After the execution of a algorithm who search for other online user in the database, the server sends to a pair of users the ip and the username of the other user, so later the clients can connect to each other directly wihtout using the server anymore. So, the server acts only like a meet point. Well all this works fine is the users arent inside of a private network, like a wireless router. The clients are programed in AS3 using XMLSocket and the server using VB6 with winsock.
View 1 Replies
Apr 27, 2010
I have the below script as part of a small application I'm building. The script just creates cue-points along a movies timeline so we can add events etc to those cue-points.
[Code]....
It's creating the cue-points well, although I'd like to use the below variable outside of this function.
Code: var stampName When I try and use it I get an access of undefined property error, which I believe relates to the variables being private and within the function - but I can't seem to find a method to get this varibale public.
View 2 Replies
Nov 26, 2006
Okay so you've got your private vars in your AS2 Class, you think they're all safe right? Wrong.
Doing a trace(MyClass.myvar); will spit out an error that the var is private and you can't touch it.
But a trace(MyClass["myvar"]); will work perfectly fine. You can use it normal, without any setters getters outside the class.
Is there a way to protect against this? I think this is a huge security flaw. I know it's simple OOP, but a private var in an object should have rules.
View 7 Replies
Feb 19, 2010
I'm tryng to make a public static method call another method, but Flash throws error 1180, sayng that the method called by the static method is undefined.
Code: Select allpackage
{
import flash.display.MovieClip;[code]....
View 2 Replies
Jun 28, 2009
i dont get the advantages of using getter and setter instead of setting the var public.
View 7 Replies
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
Sep 7, 2011
I am trying to call a method that has some xml functionality and It keeps coming up null.What I am trying to do is; I have a page that has four dynamic text fields that get their content from an xml file. I would like to create a method that will output the contents to display in the dynamic field. Maybe my approach is WAY off here, but my supervisor wants all xml related tasks contained in a xml.as fileMain.as
package classes
{
import flash.display.*;
[code]....
View 1 Replies
Mar 30, 2009
What's the preferred OOP way to run a method of a custom class when you reach a certain frame in a movieclip?
View 1 Replies
Sep 23, 2004
What's the preferred OOP way to run a method of a custom class when you reach a certain frame in a movieclip?
View 1 Replies
May 15, 2010
I need it in FlexUnit to test private methods. Is there any possibility to do this via reflection by using describeType or maybe flexUnit has some build in facility? I dislike artificial limitation that i cannot test private functions, it greatly reduces flexibility. Yes it is good design for me to test private functions, so please do not advise me to refactor my code. I do not want to break the encapsulation for the sake of unit testing.
View 4 Replies
Mar 28, 2011
one thing i've never really understood about AS3 is that you can't have a private set method and a public get method together. from within my class i would like to assign values that would call a private set function:
[Code]...
is there no way to use the set keyword on a private function?
View 4 Replies
Jul 12, 2010
I have a MainClass on a FLA file that defines both public, private, statics or not, properties and methods.I also have a package named 'components' that stocks Sprite sub-classes for my movie exportable clips. In one of them, I use the "this.root" property to access my main class instance elements at runtime.When I access public method references, same thing, I can trace them and have a true reponse to the question : [myPublicMethod is Function] ? BUT, when I want to execute the public methods, like MainClass (this.root). myPublicMethod(), the compiler boldly throws this at me :Error 1195: Attempted access of inaccessible method myPublicMethod through a reference with static type MainClass.
View 1 Replies
Mar 3, 2011
In Flash CS5 I'm getting 1195: Attempted access of inaccessible method testFunc through a reference with static type Doc. when compiling and can not understand the circumstances, which I have boiled down thoroughly.
MyDoc.as - My document class.
package {
import flash.display.MovieClip;
public class MyDoc extends MovieClip {
[code]....
I can get an error-free compile if I take the seemingly unrelated TLF text box out of the equation, either by changing it to a classic text box, deleting it, or unlinking its containing MC from MyClass.
I can also get rid of the error by removing myOtherFunc()'s definition or moving it below myFunc()'s, which I had to do a few times just to convince myself that it was true.
Update: I just confirmed the same behavior on a friend's version of CS5. He's using a Mac as opposed to my Windows setup, and he only has the CS5 version installed, whereas I have both CS5 and CS4.
View 1 Replies
May 12, 2011
If I have a .mxml file that has a method in it and a public property, can I have the method execute whenever the property changes.
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
[Code].....
In another .mxml file I have added this .mxml file like so:
<viewComponents:MyViewComponent myProperty="{myVariable}" />
View 3 Replies
Jul 29, 2009
How to access a public method in the swf loaded in a new ApplicationDomain?
ActionScript Code:
var appDomainA:ApplicationDomain = new ApplicationDomain();
*
var contextA:LoaderContext = new LoaderContext(false, appDomainA);
var loaderA:Loader = new Loader();
loaderA.load(new URLRequest("application2.swf"), contextA)
I want to access a public method in application2.swf from the main swf that loaded it.
View 8 Replies
Nov 20, 2010
I have two classes that I am trying to get to intereact, main.as which is the class attached to the stage and then light_mc.as which is attached to a movieclip.
I have a function in main that I would like to access in light_mc. I have set it up so main stores "this" in a variable called instance so I can easily access the functions within main.
Here is the code the main.as
Code:
package
{
import flash.utils.Timer;
[Code].....
View 6 Replies