ActionScript 3.0 :: Access Textfield On Stage From Another Class?
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.
I'm just now learning the new object oriented way of scripting. It's been a wild ride, but I've finally learned how to keep script off my frames (very hard coming from as2).Here's my problem:
I have a TextField on the stage in my main .fla file named loadPercent.
I'm loading a jpg with preLoad.as and displaying the bytes loaded in loadPercent.
I can access my loadPercent TextField from my MainClass
I get three '#1120 access of undefined propery' errors for each time i try to access loadPercent.
a few basic questions: 1. all my files are in a folder in my documents, not in the flash directory, is this bad? I've seen people using com.whatever etc.
2. my main .fla file does not share the same name as my MainClass.as (it's not named MainClass.fla) Is that a problem?
I'm assuming these are inconsequential because my code seems to work up to a certain point.
I have an input textfield on my stage. I have created a AS3 Document as the Main Class for my work. Now I need to access the user input in the textfield and work with it in my class.
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.
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?
I have created a class, that is simply a group of text fields. In the main app, I create instances of this class, and add them to the main app.How can i access the textFields that are in the class, to say, change the text, etc...
I am having trouble referencing dynamically generated textfield in a document class. I gives me the assigned name when traced, but generates an error when I refer to the name. Here are the documents:
I'm trying to access a text field from what I believe is called a sub-class. The text field is defined in the .fla file and the .fla file is set up to use Main.as as its document class.I got three files; scrollText.fla, Main.as and TextUtils.as.I know most of the code is working as I programmed it all in Main.as first, but when I moved the code to target the text field into its own class file I ran into error "1120: Access of undefined property" although I have declared the variable correctly and early enough to be used at this point in my code.This is the code I got so far:Main.as
Actionscript Code: package{ import flash.display.Sprite; import TextUtils; public class Main extends Sprite public function Main()
How can I achieve this ? I tried MovieClip(root), MovieClip(parent), stage,mytextfield.text = ... etc. They all throw an null object reference problem.
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");
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.
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?
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.
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:
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?
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]...
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.
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..
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.
I have a "box_mc" movieclip on the root of my stage and I need to select it from within my Document Class. I thought Stage.getChildByName("box_mc") would work, but it just returns null.