ActionScript 3.0 :: Class/Object & Stage Access?
Jan 6, 2010
I have a document class called Main, and a class called DispatchEventExample. In DispatchEventExample, I'm trying to add an event listener to the stage but get an 1120 error, access of undefined property stage.
If I understand things correctly, even though I create an instance of DispatchEventExample in Main, it's not added to the display list & therefore cannot access stage.
[Code]...
View 1 Replies
Similar Posts:
Nov 16, 2010
I have a class that have a method to do some work and return a MovieClip. How can I access the stage from the class ? I don't add the class object to stage.
My code is like this :
Code:
import com.ClassName
.
.
.
var c:ClassName= new ClassName();
var mc:MovieClip;
mc = ClassName.create("some parameter");
I want to get access to the stage from ClassName class file.
View 3 Replies
Jan 1, 2012
I'm currently trying to add the resulting XML (xmlResult) to a textbox that is on the stage. I did try using MovieClip(root).[instancename].text = ..... however it didn't work - null object reference?
package {
public class ChatHistory extends MovieClip {
public function ChatHistory()
[Code]....
View 1 Replies
Mar 7, 2012
How to access a display object on the stage in a class which is not a document class?
I am looking for a solution that doesn't involve passing the stage as a parameter to the class.
One solution i always come across is using "TopLevel.as". Is it a good method because as far as I have heard using global variables is not recommended because it might cause some problems while working on big projects.
View 1 Replies
Jul 2, 2009
I was wondering how do you access the stage property from a different class that's not the principal class tied to the fla? Essentially, I have main.as which calls another class menu.as, and I can't seem to be able to use the stage.stageWidth property from menu.as. What's the proper way to be able to use the stage property from any class? Do I have to import it separately each time?
View 2 Replies
Jan 29, 2012
If I have three classes:
public class Example {
public function Example () {
}[code]............
You can see that the two last classes extend the first one, and both have the 'variable' property. In case that I have an instance of Example and I am sure it is also an ExtendedExample OR AnotherExtendedExample instance, is there some way to access the 'variable' property? Something like
function functionThatReceivesAnExtendedExample (ex:Example):void {
if(some condition that I may need) {
ex.func()
View 3 Replies
Jul 23, 2011
i am trying to access an object within a class and the object is comming up as null but i dont understand why.
this is the object:
btnLMain = new MovieClip(); //variable declared earlier in code
btnLMain.name = "btnLMain";
[Code].....
View 2 Replies
Jul 23, 2011
i am trying to access an object within a class and the object is comming up as null but i dont understand why.this is the object:
btnLMain = new MovieClip(); //variable declared earlier in code
btnLMain.name = "btnLMain";
btnLMain.clickNum = 0;
addChild(btnLMain);
this was created in the class: LanguageButton. here is how i declared the above class within the class i am trying to instantiate it:
var btnL:LanguageButton;
then i try to access the btnLMain from the LanguageButton Class and it, (btnLMain) is comming out null:
btnL = new LanguageButton(cssLoader);
main.addChild(btnL);
btnL.btnLMain.addEventListener(MouseEvent.CLICK, btnLClick);
View 2 Replies
Sep 14, 2010
Ok. So heres what I am trying to do. I want one movie clip to follow another one that I move around with actions on the main timeline.The problem is that the follower clip is linked to a class file and I cannot find a way to find the players position.
[Code]...
View 8 Replies
Jan 6, 2011
I have created a class, call it Class1, that has various objects drawn on the stage (drawn in the IDE). It also has a function, called setColour, for changing the colour of those objects. The function works fine if I call it from within Class1.
Now I have another class, call it testClass1, that imports Class1 and calls the setColour function. First of all, none of the stage objects from Class1 are visible. Secondly, when setColour tries to modify the colour of an object, I get the error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
This is the code for testClass1:
ActionScript Code:
package
{
import flash.display.*;
[Code].....
So, what is the problem? Is it possible to change objects that are drawn on the stage of an imported class?
View 3 Replies
Aug 2, 2010
The following is that long only because I gave examples of what I want to know, not because it is complex .I have three basic questions regarding AS 3.0 classes.
1. How can I make a class object interact with an object on stage?
For example, when I have a square (mc_Square) with class "square" attached to it and I want it to trace "Colliding!" and print the X and Y of the mc_Box on contact with an on-stage *hollow* box (mc_Box) that has no class attached to it.how to do it vice-versa would also be awesome .
2. How can I make a class object interact with the same class object? For example, when I have two squares (mc_Square) that both have the class "square" attached to it and when they collide, it prints the X and Y of both of them.
3. How can I make a class object interact with a different class object?
For example, when I have two squares mc_Square1 with class "square1 (that also has a variable Primary=true written in it)" and a mc_Square2 with class "square2"; When they collide, the one with Primary=true would be removed and it's X,Y position traced.
View 2 Replies
Apr 16, 2009
I have a MC, instance name "jez_mc" this is inside an MC, instance name "container_mc". container_mc on on the stage.I then have an MC dynamically added to the stage. In this MCs timeline I want to access a variable stored in the class that is linked to jez_mc. This var that I want is named "score"So i figured in my timeline I could use something like:
var _jez_mc:MovieClip;
_jez_mc = MovieClip(root).container_mc.jez_mc;
trace("_jez_mc.score");
[code]....
View 4 Replies
Feb 10, 2010
how can i access Stage. inside a class?
View 9 Replies
Feb 27, 2009
How can i access the stage from a class? Let's say i have
Code: Select all
public class Photo extends MovieClip {
....
//contains a photo
[Code].....
View 3 Replies
Feb 18, 2010
I have var on my stage and i want my class to be able to accessthat var.Here's what is on my main.fla:
Code:
import ShapeOuts;
var ShapeDetect = 0;
[code].....
View 3 Replies
Mar 12, 2012
I have tried for days to solve this. I am trying to access the "newsData" object from my .fla to populate my manually created textfields.
Here is the class:
package {
import com.adobe.serialization.json.JSON;
import flash.net.URLLoader;
import flash.net.URLRequest;
[code]....
View 9 Replies
Feb 24, 2010
I'm trying to access a MovieClip created within the authoring tool from an ActionScript class. Here is my code:
PHP Code:
package {
import flash.display.*;
public class MoreVideos extends Sprite {
[Code].....
I also tried changing that to [stage.moreVideosBox.visible = false;], but I then got "1119: Access of possibly undefined property moreVideosBox through a reference with static type flash.display:Stage."
Is it possible to directly alter items in the authoring tool from a class? If I move 'moreVideosBox.visible = false;' outside of the class, in the main .as file, it works fine.
View 3 Replies
Mar 3, 2011
i have textfield myTxt on stage, and i have Room.as class file.
Actionscript Code:
package { public class Room { public function Room() { // constructor code myTxt.text = "yo!"; }
I need to access objects on stage from within class.
View 3 Replies
Jan 13, 2009
This is for AIR: My document class imports a separate class "ConnMonitor" and uses it to constantly monitor the network connection. It's at the very end of that class where it's supposed to update a textfield on the stage as the connection changes, but the class can't access the textfield.
View 8 Replies
Jan 28, 2010
How do I access the stage in Actionscript 3 in a class which is not my main class and not a displayobject?
View 4 Replies
Sep 2, 2011
public class MyClass extends MovieClip {
public function MyClass():void {
my_mc.addEventListener(MouseEvent.CLICK, action);
}
private function action(e:MouseEvent):void {
[Code]...
I can't able to access the my_mc(placed in FLA) movieclip. How do I access?
View 2 Replies
Jan 28, 2009
I need a class code to access a child instance of another class code that is on the stage. I have a class code named Ball.as. On the Time Line is a child of the Thing class. It is call newThing. Here is the code in the Ball.as file:
Code:
package {
import flash.display.MovieClip;
import flash.events.*;
[Code]....
I get an error message saying that newThing is an undefined property.
View 2 Replies
Jan 6, 2010
I've created a custom class (not the document class, otherwise there would be no problem) and I want to be able to access a MovieClip that is sitting on the stage.
How? MovieClip(parent), MovieClip(root)... don't work. What's the proper procedure?
Also, can I pass the MovieClip from the Document Class to another custom Class?
View 6 Replies
Aug 30, 2010
Just tried using cs5 on my new macbook and I have a tlf text object on the stage with an instance name of mText. I tried to access (mText.text = "test") it like this and got a null object reference. I tried to trace the stage from my document class and it was null when the tlftextbox was on the stage but i could trace stage correctly when I deleted the textbox. [code]...
View 2 Replies
Aug 18, 2009
I try to access to the class of an Actionscript Object like the method getClass() in java.
example :
I have this class with a method 'myMethod(clazz:Class)'
public class Class2
{
...
public function myMethod(clazz:Class):void
[Code].....
View 3 Replies
May 20, 2010
i have a movie clip in my library which has a text box inside it , and it is Exported for Action Script , with a name "MenuItem"and i am creating objects in my AS file like ..
menuItem = new MenuItem();
menuItem.menuLabel.text ="i am object 1";
addChild (menuItem)
[code].....
View 4 Replies
Feb 22, 2009
I have a dynamic text field on my stage, instance name: "lives_txt"
I want to populate this field from my Document class "Ball.as"
So in my Ball.as class I have tried: parent.lives_txt.text = String (lives);
where: public var lives:int = 3;
I get an error: access of possibily undefined property lives_mc through a reference with static type flash.display:DisplayObjectContainer.
View 2 Replies
Nov 20, 2010
I can access the targetObj instance inside the document class, but when I try to access it in another .as class,get this error:
Access of undefined property targetObj.
View 9 Replies
Jan 28, 2011
I m trying to access stage.width property but sometimes it trace 650 and 720 but i see my flash file dimension is 500x400, I need to align objects on stage..
View 1 Replies
Jul 26, 2009
How do I access Stage Class properties in Custom Class?
Class:
package {
import Main;
import flash.events.*;
import flash.display.Sprite;
import flash.display.Stage;
public class Run extends Sprite {
[Code] ....
Output:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
View 3 Replies