ActionScript 2.0 :: Multiple Classes Accessing The Same Variable Without Making It Public?
Dec 26, 2006
i've got two classes and i'm not extending to MovieClip. I like to attach the mc in the constructor just because i'll be working with different MC's that have the same purpose.
however, im using private var loadedMC:Movieclip and now i've got another class that needs to be able to access the instance's variable.
for example, myClass.loadedMC , but this would mean having to make it public and I rather not go that route.
View 2 Replies
Similar Posts:
May 25, 2009
I've got two classes running...one is a document class (EgoGame.as) and another is a class linked to several similar movie clips (Ball.as).I'm trying to access a public variable from Ball.as which has been declared in the doucment class EgoGame.as.When I run the test the outputs states the following...1120: Access of undefined property _ballPlaced.Here's my code. What I'm trying to do is remove the event listeners from the Ball.as when the _ballPlaced variable is true, so that the user can't drag and drop the balls after they've been placed in a zone.
Document ClassEgoGame.as
package
{
[code].....
View 3 Replies
Jan 15, 2011
I'd have thought this to be simple, but nothing works. I have a game I'm working on, and in it, there will be a speed stat. The fast you are going, the faster everything else has to move to make it look like you are moving faster.The problem is, the speed stat (obviously not called speed) is one of the upgradable stats, and needs to be available for the class handling upgrades for it to be changed, and it needs to be read by the class handling moving objects.The second class however, has absolutely no idea the variable even exists. I've tried for weeks to look up a tutorial on it, but there doesn't seem to be any at all that I can find. (I am using public variables, and have tried various ways of trying to point at the class it's from but apparently I must be using the wrong syntax)
View 12 Replies
Nov 7, 2009
I have a issue where I'm working with a particular interface for quite a lot of things. However, I have a particular method that I want to be available only to a particular group of classes (basically, an internal method). [code]...
View 4 Replies
Jan 9, 2010
If I have a class that extends another, e.g.,
package {
import flash.display.Sprite;
public class MySprite extends Sprite{
[Code]....
and extend that class, if more than one internal classes are defined:
package {
public class MainClass extends MySprite {
public function MainClass():void{}
[Code]....
ReferenceError: Error #1065: Variable MainClass is not defined.Note that this only happens (as far as I can tell) when the public class of the package extends another class, and multiple internal classes are defined. The internal classes don't even need to be instanced or referenced to generate the error (the bare-bones code above will error out). If only a single internal class is defined, it works fine (no error). Even if the internal class is instanced.
View 11 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
Feb 13, 2012
AS3 says you need to load variables into a class?my variables look like this... (the whole point of playing around with variables was that if I had to make a change I could access one place and change them but now I realse that I can't access or call them outside the movie clip they are in.[code] The Wholesale price. A wholesaler is usually a big shed where goods are stored.
View 7 Replies
May 4, 2009
I have (may be a simple solution needed) a problem with a class I've wrote. I've wrote a class named Navigation [URL] and in there I make all the buttons for the navigation. Next to that I have a Ipage class [URL] and in there I have all the pages stored. When I click on a button, the Navigation Class is called and tries to access the public function ChangePage in the Ipage class. In the ChangePage function I trace if the function is called and the trace comes back. So it works... BUT if I want to access another object it's not working. I can't even set sprites on visible = false.
View 7 Replies
Jan 5, 2011
i've put some public functions in one as-file. how an i call the functions in the .fla-code?
just calling the name "go();" doesn't make it:
View 2 Replies
May 28, 2010
I work with Flash CS4 and lately I've been looking for certain classes to ease my work. To be more precise Atom/RSS2.0 parsing classes. But the best result I found needed me to work with FLEX. Now I can't get this to work with flash CS4. There's no apparent way to make this work. I can build my own parser or look for one that doesn't need Flex. But it looks like the future is more FLEX oriented.
EDIT : I know how Flex Code and SWC files should work. But every time I try to use them I get some bizarre error about missing classes and methods that are part of FLEX but not included in Flash...
View 1 Replies
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
Sep 13, 2010
I need to be able to call a method from a component located under the main application in Flex 4. Can anyone tell me please how to do this without using FlexGlobals please?[code]
View 3 Replies
Jan 9, 2010
The examples I'll use don't do anything - they're classes without ANY members - no variables, methods, anything.
Let's say I extends Sprite and call it MySprite.
I save it in test.core
[code]...
Now I create another custom class called MyWindow that extends MySprite.
I save it in test.windows
[code]...
Then I create another class that extends MyWindows (the example I'll use is a document class - but that doesn't matter - I've tested using an instance too).
[code]...
Notice that I'm not even trying to instantiate the helper classes - just having them there throws the error.
If there is only a single helper class, everything runs fine.
Also note that - as far as I can tell - this only happens when extending one class from another package, then extending that class with more than one helper object.I'm pretty sure there's no namespace bumps or typographical errors, as this is a very pared-down version of the original application.
EDIT: seems the problem exists even without the crossing packages - even extending MySprite in the document class with multiple internal classes generates this error.
View 4 Replies
Jun 9, 2009
I've created 2 public variables in my Document Class...
public var _wall1:Wall=new Wall();public var _wall2:Wall=new Wall();I've then added them to the stage and given them relevant instance names...
stage.addChild(_wall1);_wall1.x=32; _wall1.y=510;_wall1.name = "wall1";I then want to use these variables in another Class (Ball.as). They need to be accessed in a function within the Ball Class constructor.
function bubble(event:Event):void{if(this.hitTestObject(_wall1)){ this.x += 1;}else if(this.hitTestObject(_wall2)) { this.x -= 1;}However, the following Error message keeps appearing...
1120: Access of undefined property _wall1.1120: Access of undefined property _wall2.Any pointers? Do I need to import something into the Ball Class to point to the _wall# public variables in the Document Class?
View 1 Replies
Oct 17, 2011
I have a base class like this
class Base {
public var space:Number;
}
which gets extended by
class Desc extends Base {
[Code]...
This doesn't compile. Say, you don't have control of the base class, what ways is there implement the same thing? The obvious is create a function setSpace(), but this object is being embedded in an already existing system that use the public space.
View 2 Replies
Oct 7, 2010
display an variable to the public, also use variable in middle of string.
ActionScript Code:
Exampel 1:
var i:Int = 0;
"show" Int
ActionScript Code:
[Code]...
View 9 Replies
Jan 23, 2012
I om trying to make one class with:[code]...
but i cant acess the var from class 1 with class 2. how could i make it a public var? ive tryed:
public var velocity;
and
var velocity:string;
make the var accessable for all classes?
View 0 Replies
Apr 29, 2009
finally have a working hitTest (YAY!!!!), now, my code is setup to create 3 'sasquatches', the problem is for the hitTest to work, the variable "one" has to be public. Now, in the next bit of code we create 3 instances of one using a for loop, BUT they all three are in the same spot cause I can't figure out how to pass Random numbers to the variable each time it creates.
Code:
package{
import flash.display.*;
import flash.events.*;
[code]....
View 2 Replies
Nov 28, 2009
I think I've made some fundamental error here... I have a public variable a in class A, and I want to access it in class B, but I cant (access of possibly undefined property...) now every time I want to refer to a variable in class A I need to pass the variable reference to class B's constructor
View 4 Replies
Jul 14, 2009
As I've been working with AS I've developed a collection of utility functions. For example:
$ cat utils/curried.as
package utils {
public function curried(f:Function, ...boundArgs):Function {
[Code]....
And I've found that, some times, I want to keep more than one public function in each file... But ActionScript restricts me to one public definition per file, if that file defines its self as being part of a package.
So, without creating a class with static methods, how could I get more than one public function in a single .as file?
View 1 Replies
Dec 13, 2009
How can i declare a Global Variable or Public Variable?
View 6 Replies
Sep 7, 2010
I have a simple problem. I have two document classes. One is Main.as the other is Step2.as. I want to declare a public variable in Main.as then need to give it a value from Step2.as. That value will later be used in my next Document class Step3.as How would I write the code that gives the value in my Step2.as and then how would I write the code that retrieves the value in my Step3.as?
Note I can't import my Step2/ or Step3 document class into my Main.as.
View 3 Replies
Dec 3, 2007
Let's say I have a class, and I created a new object of this class in my document class. Inside this class, there is a public variable. How would I be able to detect a change in that public variable?
View 7 Replies
Aug 7, 2009
What would be the scoping to reach a variable within a external class public function FROM a function on the main timeline?In menu.as public function buttonClick()Need to reach a starFunction variable(var starFunction = such and such.@fn) within an if statement within buttonClick function.On main timeline(menu.as declared on first frame main timeline as var menuH:Menu = new Menu()In function aboutUs()here is where I need to use that variable for an if statement
View 1 Replies
Apr 9, 2010
I have a project that i'm working on, and in the project it's important that i have an object that i can create with actionscript that already has two arrays inside of it. To do this, i made the movieclip, i checked export for actionscript in the library, and in the custom class that corresponds to that object i made the arrays with the following code:
package {
import flash.display.*;
public class cont extends MovieClip {
[code]......
View 6 Replies
Sep 8, 2011
I've been working my way towards better OOP design lately and I've come across a problem with accessing functions in other classes from my Main class. Here is the code:
Main.as
ActionScript Code:
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
stage.addEventListener(KeyboardEvent.KEY_DOWN, fireBullet);
They are listening for functions that are within the Player.as class, these functions control the dynamics/movement of the player itelf. But for some reason I'm getting a 1120 error(access of undefined property). Basically how do you listen/access for functions within a different class?
View 5 Replies
Jan 7, 2012
I want to access an object from a class in which it was not created in. I have a main class (A) in which I create and instantiate an object (of class B), from this class I can obviously do whatever I want with the object, no problem. The issue I'm having is another class (C) needs to access the object in question to change its x and y location values. Class C doesn't know what the instance of class B, created in class A, is; this doesn't surprise me, but I can't figure out how to allow class C to get access to what class A created.
View 7 Replies
Jun 22, 2009
I have 2 swfs, one is main and it loads other file "skin.swf". skin contains object of custom class SkinClass. I can access it from main swf, but when I try to cast that object, the result is null. This happens when I use absolute url, when I load skin from relative url, everything is ok.
View 3 Replies
May 3, 2011
I am having this issue were I can not access any variables from any other class![code]Now, from my other variables, that is what I do, I don't understand what I am doing wrong?
View 5 Replies
Mar 31, 2012
I've recently started development on my first proper AS3 project and I�ve hit a sort of brick wall with my knowledge of how to make AS3 classes do what I want. I could do this in AS2 no problem with referencing the stage, but now that only the document class has access I'm stuck.I have instances of a MC called activity. These sit inside a container MC that is the source of a scroll pane (that sits on the stage).
When I click a button inside the Activity MC I need to generate a new MC and set that as the content of another scroll pane on the stage. I�ve tried several things, even gotten the stage passed to the activity MC class but it can't then be used to addChild to items on the stage just reference then (much to my aggravation). And I can�t set an event listener for the new activity�s button when it�s created as it throws a static display object error of some sort.What methods can I use to pass information from a MC class back to the stage so i can call a function or just paste a MC onto the stage? I'm at my wits end after about 10 hours of exhausting everything the internet seems to have to offer on the subject.
View 2 Replies