ActionScript 3.0 :: Access Vars Between Document Class And Other Classes?

Apr 19, 2009

For the example, there's a single FLA with a document class "main.as." In the public class main.as package, there is a public variable: "var example:String='example';." Inside of the FLA, there is one movie clip in the library and it is assigned a custom base class "sub.as." The movie clip is then placed on the first frame of the stage so its constructor is run at runtime and reads the value of example.

What is the proper way to get the value of "example" in the root document class? Using "root.example" in the sub.as class to target the document class returns an error and when I trace "root", I get "null." Main.example naturally throws an error because that's looking at the actual class and not the movie / stage its attached to.The round-about way I've done it before is to dynamically add the object in the library and pass in the root path when I create a new instance of it (example: submc:sub = new sub(this); ).Is there anyway to get back to the document class with a built-in method like root, etc?

View 2 Replies


Similar Posts:


ActionScript 3.0 :: Access Some Vars From A Document Class?

Sep 30, 2009

if i want from a document class to access some variables in other classes (which are imported into that document class) does these variables need to be public to access them or they can be something else?

View 9 Replies

ActionScript 3.0 :: Sharing Vars Between Document Class And An Imported Class?

Jan 27, 2009

I've been sorting through the XML docs and i've bumped my head into a bit of a question. So, to preface, I have been able to load the XML successfully, but I want to be able to use my own XML loader class to load the XML and then be able to reference it from the document class. Also, I'd like to be able to send a file path to the loader class when I call it.

The document class:

ActionScript Code:
package rg.sites{
// flash classes

[code]....

View 8 Replies

ActionScript 3.0 :: Pass Vars From XML To A Document Class?

Aug 2, 2009

I'm creating a flash project and would like to pilot the most variables (eg: colors, texts, sizes, ...) from a single XML file and then spread them in my document class.

Code:
public var yourName:String;
public var myXMLLoader:URLLoader = new URLLoader();
public function intro():void {

[Code]....

Right now I got no errors but I got nothing when tracing the "yourName" var.

View 3 Replies

ActionScript 3.0 :: Dynamic Vars Created Within Document Class

Jan 26, 2009

I am a bit puzzled why this does not work when placed in my document class, but works when directly added a key frame in the Flash IDE.
ActionScript Code:
this['myVar1'] = new Object();
When within the document class I get this error when compiled,
ReferenceError: Error #1056: Cannot create property myVar1

I have tried the following but I still get an error.
ActionScript Code:
public static var root_Ref:Object;
root_Ref = root;
root_Ref['myVar1'] = new Object();

View 2 Replies

ActionScript 3.0 :: Importing Classes Without Using Document Class

Feb 2, 2011

I have 2 as3 files, which are the classes used . I have to use it with the main flash movie.. How will I include those as3 files without using document class..

View 4 Replies

ActionScript 3.0 :: Access Vars In Parent.swf From Child.swf Class?

Aug 10, 2010

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.

View 2 Replies

ActionScript 3.0 :: Import Classes Without Declaring A Document Class?

Sep 25, 2009

The header says it all. I am trying to import a couple of classes without attaching a document class to the fla file. Is this possible? I have the class path set as appropriate (I think) in the publish settings since my fla is located inside a swf folder and my classes folder is located outside the swf folder. Its how my project is organized.

Class path set: "..classes"

View 8 Replies

ActionScript 3.0 :: Loading External Classes Into Document Class?

Sep 7, 2010

I am trying to load external classes into a document class and initialize the page by loading one of them (which loads xml and videos) I feel like I should be able to do this but have not found documentation on this. Below is the code i am using...

package {
import flash.display.MovieClip;
import flash.net.URLLoader;

[code]....

View 1 Replies

Actionscript 3 :: Access A Displayobject On Stage In A Class That Is Not A Document Class?

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

Actionscript 3.0 :: Make Non-document-class Classes Aware Of Stage Comp?

Dec 2, 2010

I am working on text adventure game which will have at least a few components (a text area for narrative and text input for user input) on the stage at all times. Therefore, I have created those components statically through Flash's WYSIWYG design environment. I gave them instance names "myTA" and "myTI" respectively. I was able to get my main class (the document class for the stage) to interact with them (dynamically adding text one character at a time like a typewriter at runtime), but other classes in the same package don't seem able to recognize the stage components. Below is the relevant code:

Case A, in which everything happens within the Main class:
Code: Select allpackage {
public class Main extends MovieClip {

[code].....

View 1 Replies

ActionScript 3.0 :: Access A Movieclip On Document Class From Another Class?

Mar 3, 2011

Going further on my app, I felt in another problem. Despite having lots of posts on the web regarding this, none of the solutions worked for me In my document class (Main.as) ve two containers. One empty and another with a star that is being imported from the library. Here´s the main class:

package
{
import flash.display.*;

[code]......

View 4 Replies

Actionscript 3 :: Make Non-document-class Classes 'aware' Of Stage Components In Flash?

Dec 2, 2010

I am working on a text adventure game which will have at least a few components (a text area for narrative and text input for user input) on the stage at all times. Therefore, I have created those components statically through Flash's WYSIWYG design environment. I gave them instance names "myTA" and "myTI" respectively. I was able to get my main class (the document class for the stage) to interact with them (dynamically adding text one character at a time like a typewriter at runtime), but other classes in the same package don't seem able to recognize the stage components. Below is the relevant [code]...

View 5 Replies

CS4 Non-document Class Can't Access Library

Jan 27, 2010

Got two classes "Engine.as" and "Player.as". Engine.as is the document class that is calling Player.as.

The point is to have Player.as create a movieclip on the stage, but it seems it cannot access the library or something. Because when the player class is at the createHero() method it gives me the "error 1009 cannot access a property or method of a null object reference"

Engine class:

Code:
package test{
import flash.display.*;
import flash.events.*;

[Code]....

View 2 Replies

ActionScript 3.0 :: Access File Class From Document?

Oct 3, 2011

It seems simple, but it doesn't seem to be working I have 2 as3 files as classes "mainclass.as3 (this is the document class)" and GamePlay.as3

the GamePlay class works flawlessly on it's own, but when i try to create the var to access it ... var gp:GamePlay=new GamePlay(); ... i get the following error.

I have looked at tutorial etc, but i cant get it to work i am currently getting the following error.[code]...

View 1 Replies

ActionScript 3.0 :: Access A Mc Or Textfeild From A Non Document Class?

Sep 21, 2010

It used to be simple to access an object you put on the stage like a mc or dynamic text field by simply using _root.instanceName ect.  Now I see references to making references to the Stage and such like:
 
private var stage:Stage;
stage = stageRef; 
and I am still confused.
 
What I have going on is, I have placed a movieclip on the stage in Flash and gave it an instance name of Cell_mc.I have a cusom class that extends MovieClip with the following imports

import flash.display.MovieClip;
import flash.events.Event;
import flash.events.EventDispatcher;

[code]....
 
This Class is tied to a set of MovieClips in my Library.

I have a listener: this.addEventListener(MouseEvent.MOUSE_DOWN,pickUp);
 
And a function:

private function pickUp(event:MouseEvent):void
{
this.startDrag();

[code]....
 
I get the following error whenever I try to access an object I placed on the stage from anywhere other than the document class:
 
1120: Access of undefined property Cell_mc.
 
How do I access the cell_mc that is already on the stage from this non-document class?

View 5 Replies

ActionScript 3.0 :: Access The Timeline From Document Class?

Nov 14, 2010

How do I access the timeline from the document class? I tried: trace(this.parent as MovieClip)

but I got a null object.

View 9 Replies

ActionScript 3.0 :: Access Document Class From Within Movieclip?

Jan 30, 2009

I was wondering if it was possible to access the document class from within a movieclip.

I am creating a slideshow type project, and I'm using a document class to switch between the frames using the arrow keys. However, in one of the "slideshow screen" movieclips, I want to have it stop, and then play another part when the arrow key is pressed again.

I tried to access my nextScreenToPlay method within the document class, but whenever I try to do it within a movie clip, I get this error: Call to a possibly undefined method nextScreenToPlay through a reference with static type class.

If I do a trace(Main), within a movieclip, it shows the class.

View 1 Replies

ActionScript 3.0 :: Access Document Class Var From Movieclip?

Sep 18, 2009

trace(MovieClip(root).TRACE);

so at pesent I am using this to try and access

Code:
public var TRACE:String

in the the document class.

however I am getting this

"1180: Call to a possibly undefined method addFrameScript.�"

my document class extends to Sprite as I have some stage resizing that occurs on Initialise

Code:
StaticInheritance extends Sprite

Im sure it has something to do with the way the document class extends.

View 1 Replies

ActionScript 3.0 :: Access Modifiers In Document Class

Jun 15, 2010

I tend to give my Document class all public access modifiers. Would there be any reasons not to do this?

View 3 Replies

ActionScript 3.0 :: Can't Have Access To Stage In Document Class

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

ActionScript 3.0 :: Access Class Variables From Another Classes

Jan 10, 2012

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 Replies

ActionScript 3.0 :: Access Stage Instances Outside Of Document Class?

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

ActionScript 3.0 :: Access Stage Property Through Document Class?

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

ActionScript 3.0 :: Access Variable Within Fla File From Document Class?

Oct 17, 2011

I want to know how you access a variable within the fla file from the Document class?I want an int inside the fla or swf file to be accessed from the class that is being used to run the file?

View 5 Replies

Flash :: Access A MovieClip On The Stage From The Document Class?

Jan 7, 2010

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.

View 2 Replies

Flash - How To Access Stage Instances Outside Of Document Class

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 2 Replies

Actionscript 3 :: Flash - Access Stage Outside Document Class

Jun 23, 2011

I am trying to add a keyboard event listener to the stage, to detect when a user clicks the left or right arrow keys. But this listener is called from inside a class file which is imported into the document class, therefore I think it doesn't know what "stage" refers to. How do I solve this?

[Code]...

View 2 Replies

Flash 9 :: Access Document Class Methods From Within MovieClip?

Aug 27, 2008

Let's say I have a FLA file with document class called main. In main, let's say I have a method called test1 that just outputs "hello world" via trace. On the FLA I have a movie clip. In that movie clip, when the timeline reaches frame 123, I want it to invoke the test1 method (I just set up a simple action on the frame). However, I get an error saying that the method is undefined. I try this.parent.test1() too but that gives me the same error. Is it not possible to invoke a document class property from within the timeline of a movie clip that's on the stage?

View 2 Replies

ActionScript 3.0 :: Direct Access Of Document Class Static Var?

Sep 19, 2009

I often write apps in flash where I wrap all the display elements into one parent display object container (not the stage). Let this parent container be mc_world for example. I declare this in my Document class (Main) as:

ActionScript Code:
public static var mc_world:MovieClip;

Since this container is unique and often times needs to be referenced from various classes in the project (that are not its children) I find myself often doing Main.mc_world across my project to access this container.

Is it bad practice to directly access static members of the Document class throughout my project? Are there any simple alternatives? I don't want to dispatch events every time I need to access mc_world. And using a singleton class doesn't seem all that different from the Document Class (which only has one instance right?).

View 0 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved