ActionScript 3.0 :: Can't Access Parent Class Variables
Feb 11, 2010Look at this example [code]...
How come the trace in the SlotsSetup function is printing out NaN ?
Look at this example [code]...
How come the trace in the SlotsSetup function is printing out NaN ?
I have a child class that is loaded into the parent class when the swf begins, like so: var myvar = 'hello'; public function Parent() { this.child = new Child(); }; How can I retrieve the variable 'myvar' from within child?
View 1 RepliesThe external swf is located at:[url]....In the parent.swf, I put System.security.allowDomain(url....)When you click a button on the child.swf it's suppose to trace data from the parent.swf, but it returns undefined.What am I doing wrong? I MUST access data from the parent.swf
View 4 RepliesFrom the two .as files below, I get the following error when I run: 1119: Access of possibly undefined property importantNumber through a reference with static type flash.display:Sprite.
[Code]...
I just started programming OOP and I'm running into a scope problem. In the following project, I have a masterClass called App. The App-class has Screens:Screen-class and a Navigation-class as it's children. From the navigation class I want to control which screens will be displayed. I don't know how to do this.
[Code]...
Ok im rather new to flash so ill do best i can to describe this. I have a HealthBar movie clip with 3 layers, bottom layer is just a red rectangle, middle layer is a green rectangle that is a movie clip, and the top layer is just a border. the green rectangle movie clip has an instance name of bar. i put my HealthBar on my stage with an instance name of healthBar and i change it when the players health goes down by calling _root.healthBar.bar._xscale = health where health is 0-100.
this works all fine and dandy. now i have a movie clip of MiniBoss with an instance name of miniBoss# where # is a number of the layer depth when it is created. in the MiniBoss movie clip i have an instance of the HealthBar with an instance name of bossHealthBar. i tried to call from within the MiniBoss class bossHealthBar.bar._xscale = health but i get an error that there is no property of bossHealthBar.bar._xscale. how do i access the bar in the HealthBar in the MiniBoss clip from the MiniBoss class in its onEnterFrame() method?
I have a Main class that has a public var "foo" which is a string. my subClass is a movi clip that has a text field called txt. I want to access the document variable from the sub class but get error 1119: Access of possibly undefined property foo through a reference with static type flash.displayisplayObjectContainer.[code]...
View 5 Repliesi'm trying to assign a parent's variable from the parent's child
//Parent
public class Main extends Sprite
{
public var selectedSquare:Sprite;
[Code]....
i'm receiving this error, but i'm casting parent from displayObjectContainer to a Sprite so i have no idea why it's not working.
1119: Access of possibly undefined property selectedSquare through a reference with static type flash.display:Sprite.
I have a initApp.as which instantiates a class which needs to access the "currentState" property and the States array as well. However we cannot get this to work as we cannot see how we can access this information.
Within initApp.as currentState is accessed via "this.currentState". This does not work in the class which is instatiated within initApp.as. The following error is thrown:
"Access of undefined property currentState."
Assign an event listener to a protected timer variable in the parent class.
I am working with Adobe LCCS, and created a BatonProperty which implements Baton
Now, Baton has a protected timer variable declared like this, and for some reason, I am unable to get access to this _autoPutDownTimer, from a BatonProperty instance.[code]...
I want to access a variable from subclass which is in a parent class.Something like this:
class a extends b
{
private var a;
public function a()
[code]....
I cant access to var in parent movie from class in child.I have two swf's: parent.swf and child.swf. In parent.swf in frame 6 is:
Code:
stop();
var TestVar:String = "hello!";[code]....
I was trying use parent, parent.parent, parent.parent.parent etc. and any result - null object error.
When I add a TextInput to the stage I can access it with instanceName.text. this works. Now I have one Movieclip with one TextInput inside (the textinput's instance name is testetxt). This MovieClip has a corresponding class and its code is the following:
class com.sck.testeT extends MovieClip
{
public var testetxt:MovieClip;
[Code]....
The textinput gets transparent but the text isn't changed... I realized it was because the textinput wasn't initialized yet. so I have to wait a while, but how can I know that it was initialized and I can set the initial text by code?
i've got an inheritance chain of AS2 classes set up where i have an array in the 'child' class that i'd like to be able to access from the 'parent' class:
bottomClass.as -'parent'
topClass.as -'child'
my question/dilemma is: how can the parent access the properties of a child class...is this even possible, or am i just looking at it wrong?
i've got an inheritance chain of AS2 classes set up where i have an array in the 'child' class that i'd like to be able to access from the 'parent' class:
bottomClass.as -'parent'
topClass.as -'child'
my question/dilemma is: how can the parent access the properties of a child class...is this even possible,
I have one movieclip object with a custom class.
That class has a loop that creates / instantiates a number of copies of another movieclip from the library. This second movieclip has a textfield child in it. When I convert this textfield to a movieclip I can access the properties of it fine, but just as a dynamic textbox I can't access it.
This is the custom class of the second movieclip that gets instatiated a few times by the first custom class...
This custom class relates to a movieclip that has a child MC called recent_text (which I can access ok) and in that child is another child (a dynamic text field called "aDynamicTextBox", which I can't access)[code]...
I'm trying to create an XML class to load some images on a stage, but my problem is that I can't access variables in my XML class(which I need to load the images) from the main timeline after I've created a new instance on the XML class.[code]...
View 1 RepliesI am just writing this test code in AS1.0. Now the problem, I am not able to get access to my class variables. I am doing this stuff for learning As1.0. Although in 2.0 I get through those using static variable. But in As1.0 I don't know how to do this.
Code:
function main(){
this._xml=new XML();
this._arImages=[];
this._xml.ignoreWhite=true;
this._xml.onLoad=this.LoadData;
} main.prototype.showImage=function() {
[Code] .....
I have a MC with a class attached to it, and I have other MCs within that MC. I need those MCs to be able to access variables within the main MC class. Here is a quick'n'dirty:
Code:
class Foo extends MovieClip{private var h:Number;
private var subMC:MovieClip;function Foo(_h:Number){h = _h;}
subMC.onEnterFrame = function(){trace(h);}}
How can I access variables in the Foo class from another MCs scope? I have tried using static var but aren't they constant regardless of instance?
The system i am trying to make is structured like this: How can i acess the vars of the class var from the other classes?
View 4 RepliesAnyways, I've been trying to figure this out for quite some time.Let's say I have my document class. I'm guessing the document class can correspond to the first thing that gets run? (such as the "main" function in most C++/low level languages).If I set a variable in it:var myNumber:Number = 10;how would Iaccess: "myNumber" from other objects in my stage?Like a movieclip on my stage for example.If I go inside that movieclip into the movieclip's first frame, how would I say:trace(TheDocumentClass.myNumber);Another similar question is, what about the actual stage frame?If I click on frame 1 of my stage, set a variable:var aNumber:Number = 5;how would I access it from other objects?In my movieclip's first frame, what would I put?trace(root.aNumber); ?trace(stage.aNumber); ?
View 9 RepliesI am unable to access variables written in a class file.
This is the class file:
class readXML {
public var modArray:Array;
public function setModule() {
[Code]....
When I access the getModule method from flash (on click of a button), I get modArray as undefined.
how I could get the data of modArray?
I've created a class that utilizes setInterval...I call it in a different class...and I can't get it to make the setInterval call. I'm thinking there's a scope problem but I don't see it.
Class w/ setInterval:
Code:
class Foo {
private var id:Number;
public function Foo() {[code]....
The function will get called but I need access to the class's instance variables inside display().
i am creating my own component. the problem is how can i access the variables inside the Class without using _root.myComponentName.variableName.
[Code]....
I am trying to access a function that is on my document class for my AS3 project, from a nested class. That is, the Document Class calls Class A which then calls Class B. So I am trying to access a function from Class B, I am trying to use MovieClip(parent).function(); but I am getting error 1120. The MovieClip(parent) (fixed to reflect my document class, etc) works when I try it from other classes but not from this nested class.
View 9 RepliesI think this is a pretty simply problem but I do not seem to be able to pull it off. Basically I have a parent class A, and a child class B.Class A instantiates class B with addChild.There is a shared object which is being updated from a java server (red5) that has an event listener attached to it in class A.I have a function in class A which will pass certain, specific updates from this shared object to class B.The problem occurs is that when class B is instantiated, the event listener from class A doesn't work anymore. I have not removed the event listener from A.?
View 1 RepliesI have the following parent class that I'm working with:
Code:
package {
import com.poptent.SubClassOne;
import com.poptent.SubClassTwo;
[Code].....
I am trying to set it up so that a parent method called by subClassOneInstance can affect subClassTwoInstance.
Lets say I have a Main Document Class called Main. I also have a child class called childClass that call a function from the Main class and is also imported in the Main class. How should I call the function? I tried this , but when calling the function, it's getting me error.
Main class :
Code:
package {
import flash.display.Sprite;
import com.childClass;
[Code].....
I'm trying to access the AchievementScreen's textfield from a medal object. Point being to have a mouseover event of the medal, change the content of the textfield shown. I tried a trace first: trace(this.parent.parent.parent.parent.textLineCon tainer); 1119: Access of possibly undefined property textLineContainer through a reference with static type flash.displayisplayObjectContainer. trace(this.parent.parent.parent.parent) shows me it is a AchievementScreen object. textLineContainer is the instance name of the MC nesting the textfield (I actually drew the achievement screen then exported it to actionscript.
[Code]....
var some="someone" some main.swf. mc:MovieClip.mc in main.swf. Iam load a mainMenu.swf file into mc. how can call some variable in mainmenu.
View 1 Replies