ActionScript 3.0 :: Accessing Variables Within Class File?

May 4, 2010

Say I define a variable in a  class file:
 
public var container:sprite;
 
I add the sprite to the stage and define it's x and y in the class file. How would I go about changing the x and y of the container within my fla file?

View 5 Replies


Similar Posts:


Actionscript 3 :: Accessing Variables In Another Class?

Jul 25, 2010

First off I don't understand classes, how to "call" or "initiate" them. I'm class ignorant.

I have two .fla files. One of my .fla files consist of 15+ .as files; we'll call this one XML editor. The other .fla file consists of 10+ .as files; we'll call it the interface.

The xmleditor.swf loads the interface.swf. Within the xmleditor.swf, a login screen appears and the enduser logs in as either a "user" or an "admin". The "user" or "admin" is stored in a public variable called "userType". The userType variable is created in one of the many xmleditor.fla .as files called Login.as.

Once logged in, xmleditor loads the interface.swf. interface.fla uses 10+ .as files. one is called nodeNames.as I need an if statement in nodeNames.as that is something like this:

if (Login.userType == "user"){
trace("do something");
}

I have the following FlashVars.as file but I have no idea what the steps are to make it work.

package extras.utils {
import flash.display.Sprite;
import flash.display.LoaderInfo;

[code]....

Should I use this FlashVars? and if so, how?

Or is there an easier way to access the variable?

View 1 Replies

ActionScript 2.0 :: Accessing Variables In MovieClip From A Class

Feb 16, 2006

I'm writing a little application to run a course, and the engine creates the navigation menu putting labels in the button etc...

So, as far as I change things like a dynamic text that's on the stage with something like

mybutton.itemText.text = my_xml.childNodes[0].childNodes[index-1].attributes["Label"];

this works, but what If I want to change a variable declared in the button?

I would like to retrieve from an XML the movie I want to load pressing this particular button, but seems like the scope of the "designed" objects and the programmed object is a little different, since with

[Code]....

I've included a simplified version of the interface, the classes and the code is not 100% functional...

View 4 Replies

ActionScript 3.0 :: Accessing Static Variables Using The Class Name Itself

Jun 18, 2009

Say I have a class called Ball (movieclip) and I create a number of instances of it. There is a static variable, say, ballArray and need to access that from a different class, say, Bat. How do I go through with it? Can I access that using the class name itself (Ball.ballArray like in Java)?

View 1 Replies

ActionScript 3.0 :: Accessing Variables Form Within A Class?

Jan 19, 2010

having trouble accessing variables from the main timeline from within my class...this is a function within my class...(not the constructor function)

Code:
public function createPanorama():void {
var url:String = "../../../panorama/panoramaImg/fenway.jpg";

[code]......

View 6 Replies

Actionscript 3 :: Accessing Variables Of Parent Class From Child?

Apr 11, 2010

i'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.

View 2 Replies

Flash :: Accessing Super Class Variables From Subclass?

Aug 16, 2010

I am hoping someone can explain about subclasses accessing variables from the super class. I found that the subclass can only access variables which are set in the constructor of the super class. Is there any way around this?

[Code]...

View 3 Replies

ActionScript 3.0 :: Accessing The Private Variables Of One Instance Of A Class?

Aug 18, 2010

Currently I have two classes which are "bullet" and "enemy".There are two instances of the enemy class.Code from an ENTER_FRAME event in the Bullet Class:

ActionScript Code:
try
{
for(var k:int=0; k<getEnemys.length; k++)

[code]....

The Enemy Class has a private variable called "hits".What do I have to do in order to reduce the hits of the instance of the enemy that was hit by the bullet?

View 5 Replies

ActionScript 2.0 :: Accessing Class Functions/variables In OnLoadInit?

Jan 27, 2008

class fial
{
public var num = 5;

[code].....

View 1 Replies

ActionScript 3.0 :: Accessing Stage Variables From Class Object

Oct 11, 2010

I was wondering if there is a simple way to access variables from a class object, where the variables are not actually a part of that class. So if you had an array defined on the first frame of the stage, and added some elements to it, you could use the methods of the custom class to manipulate the array's data.

Stage Frame 1
Code:
var myArray:Array = new Array( "apple", "banana", "pear" );
var myClass:someFunctions = new someFunctions();
myClass.addValue( "orange" );
myClass.sortValues();
[Code] .....

It might not seem logical as to why you would ever want to do that, but it's a very simple example, and it's the means I'm after, not the result. I'm creating a list of functions available to execute by a user via an input field. To keep things simple I made them the methods of a class. The issue, however, is that these methods need to manipulate objects which are on the stage, added and removed by a separate controller class. Passing the objects by reference to the class as a parameter would not be viable with what I'm trying to do either.

View 4 Replies

Javascript :: Error Accessing Class Variables Within An ExternalInterface Callback

Aug 28, 2011

Here's my actionscript (compiled with mxmlc, embedded into html, and the functions are called with js):

[Code]...

View 1 Replies

ActionScript 3.0 :: Accessing Static Variables Of A Super Class Through A Subclass?

Aug 10, 2011

I'm trying access a static variable located of a super class through an instance of one of it's subclasses and I'm receiving an access of undefined property error (example of which below).&nbsp; Creating another static variable in the subclass and assigning the value from the super class will allow me to dot operate to it.&nbsp;

[Code]....

View 1 Replies

ActionScript 3.0 :: Loading A CSV File And Accessing The Variables?

May 6, 2009

I'm new to AS3 and dealt with AS2 before (just getting the grasp when the change it). Is it possible in AS3 to load an excel .csv file into Flash using the URLLoader (or ???) and the data as variables?I can get the .csv to load and trace the values (cell1,cell2,cell3 but I'm not sure how to collect the data and place it into variables. Can I just create an array and access it like so.... myArray[0], myArray[1]? If so, I'm not sure why it's not working.
 
I must be on the completely wrong path. Here's what I have so far..

[Code]...

View 2 Replies

ActionScript 3.0 :: Accessing Random Variables In External .txt File?

Sep 8, 2010

I have a .txt file with 10 variables containing 10 sentences. The variables are named myText1, myText2, myText3, etc.

I want to be able to load one of these sentences at random into a dynamic text box.

My plan was to generate a random number i and concatonate it to the variable name (ie myText + i) then call that in a LoadVars.

However, I am not able to properly reference it.

View 1 Replies

ActionScript 2.0 :: Accessing A Memberfunction Of A Class From The FLA-file

May 12, 2004

I have a problem accessing a memberfunction of a class I made. Simplified, this is the class:

[Code]....

View 5 Replies

ActionScript 3.0 :: Flex Accessing External Class File

Jan 25, 2010

I have downloaded an AS 3 class file, designed to create an MD5 hash from a string. I have put the class file in my /components directory (with / being the root of my Flex project source).[code]...

View 2 Replies

ActionScript 3.0 :: Accessing A MovieClip From An External File That Is Not The Document Class?

Apr 17, 2009

Instead of posting my entire files and such, I'll make a brief example of my situation and my desired outcome.My files consist of my document class entitled Engine.as and another class Abilities.as all within the same folder.On my stage I have a MovieClip with the instance name of item1_mc. On its personal timeline I have 2 frames, one entitled "inactive" and the other "active". Here's a sample of very similar code....

Code:
package
{
import flash.display.MovieClip;

[code]....

How do I access item1_mc? In reality I have 6 different clips and I desire to access much more than frame changes...what's the overall best way to be able to interact with an item placed on the stage via an external .as file that is not the document class?

View 11 Replies

Actionscript 3 :: Accessing GUI-created Elements In A Class Definition File?

Mar 18, 2010

I've used the GUI to create a rectangle that I turned into a button symbol (SimpleButton). I then edited the button so that it had 4 different button states and a text layer on top. I then created a class definition file for this object so that I could dynamically change the label text (the text layer) when adding instances of this button to the stage.

I was able to create and link a class file (DynamicButton.as) just fine, but when I try to access the text field that I created on the button, I get the error:

"Access of possibly undefined property btnLabel through a reference with static type com.examples:DynamicButton."

when i couldn't get that to work, I decided I'd try adding the TextField directly within the class definition file, using the following code:

package com.examples
{
import flash.display.Sprite;
import flash.display.SimpleButton;

[Code].....

The problem is that I can't seem to add the TextField to the SimpleButton, as it's not a display object. So, I tried adding it to the parent of the simple button (and I figured, I'd just place it exactly above the button). But then I get a "null object reference." error.

is there a way to access GUI-created elements from w/i a class definition file? How would I add the TextField to the button using only AS3 inside of a my class definition file?

View 1 Replies

ActionScript 3.0 :: Flash - Accessing Stage Objects From Class File?

Mar 11, 2011

i have an issue in accessing stage objects from class files.Here is my code

package
{
import flash.display.MovieClip;

[code].....

View 1 Replies

ActionScript 2.0 :: Unable To Access Variables In A Class File

Aug 21, 2007

I 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?

View 2 Replies

ActionScript 3.0 :: Send Off Multiple Variables In An Object (from A Class) To The FLA File?

Feb 13, 2009

I have the livedocs wide open and I still can't figure out how to send off multiple variables in an object (from a class) to the FLA file...[URL] The setup: I have a class that extends EventDispatcher. I created an Object called _pass, public var _pass:Object;. In my last function (everything is cool up until now), I have four variables that need to be passed to the main fla. Let's say they're param1, param2, param3, param4.

It was explained to me that I could use the public var _pass:Object; by first creating an instance of the object like so, _pass = { param1, param2, param3, param4 }; (each param is available in the function). Having setup an object instance, I could then dispatch the object to read from within my fla: dispatchEvent(new Event(Event.COMPLETE));.

But I get these errors:

1084: Syntax error: expecting colon before comma.
1083: Syntax error: rightbrace is unexpected.

As the livedocs show, you can use an associative array (with braces and a colon), but I don't need that. I just need to pass my variables that are pre-made to the FLA.

View 2 Replies

ActionScript 2.0 :: Import Some Variables From A Txt File And Treat Them Like Normal Variables In Fla File?

Oct 27, 2009

How can I import some variables from a txt file and treat them like normal variables in fla file? something like in txt file

Code:

&variable1=2&
&variable2=8&

[code]...

View 2 Replies

ActionScript 3.0 :: Accessing A Class's Static Functions From A Variable Of Type Class?

Feb 19, 2010

I realize this is kind of an odd issue, but I am wondering if there's any way to get Flash to allow me to access a class's static functions using a class variable that points to the class. Example:I create a class called FooClass that has a static function named fooI then create a variable of type Class that points to it

Code:
var class:Class = Class(getDefinitionByName("FooClass"));
However, when I try to call foo() using the variable, it errors saying the function

[code].....

View 6 Replies

ActionScript 3.0 :: Accessing An Object Drawn On The Stage In One Class From Another Class

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

Professional :: Accessing A Variable Defined In One Class From Another Class

Mar 14, 2011

I've only been programming in as3 for a couple months, and so far I've written several compositional classes that take MovieClips as inputs to handle behaviors and interactions in a simple game I'm creating. One problem I keep coming upon is that I'd love to access the custom variables I define within one class from another class. In the game I'm creating, Main.as is my document class, from which I invoke a class called 'Level1.as' which invokes all the other classes I've written.Below I've pasted my class 'DieLikeThePhishes'. For example, I would love to know the syntax for accessing the boolean variable 'phish1BeenHit' (line 31) from another class. I've tried the dot syntax you would use to access a MovieClip inside another MovieClip and it doesn't seem to be working for me.[code]

View 1 Replies

Professional :: Accessing A Variable Defined In One Class From Another Class?

Mar 14, 2011

I've only been programming in as3 for a couple months, and so far I've written several compositional classes that take MovieClips as inputs to handle behaviors and interactions in a simple game I'm creating. One problem I keep coming upon is that I'd love to access the custom variables I define within one class from another class. In the game I'm creating, Main.as is my document class, from which I invoke a class called 'Level1.as' which invokes all the other classes I've written.Below I've pasted my class 'DieLikeThePhishes'. For example, I would love to know the syntax for accessing the boolean variable 'phish1BeenHit' (line 31) from another class. I've tried the dot syntax you would use to access a MovieClip inside another MovieClip and it doesn't seem  to be working for me

package  jab.enemy
{
import flash.display.MovieClip;

[code].....

View 1 Replies

ActionScript 3.0 :: Accessing Properties Of A Member Of A Class From Within The Class?

Jun 9, 2011

I have a class, call it MyClass, and there are several variables that I need to be able to access each instance of from within the class.So for instance, I need the object myObject1, a member of MyClass, to store the variable myNumber.From the main timeline, if I trace myObject1.myNumber, I get whatever number I've stored.
 
However, I need to check the numbers against another parameter, so I need to be able to test if myObject.myNumber == myOtherNumber. But from within the class, if I trace this.myNumber or myNumber I get null.What is the proper syntax for accessing a variable within a class?

View 5 Replies

Professional :: Accessing Timeline From Class Loaded Into Doc Class?

Jun 12, 2011

I can't find a way to directly access a MC (or textfield, etc) on the timeline from a Class loaded into my Document Class. No problem from the Doc Class, but can't do it directly from the loaded Class. Is there a trick to essentiall extend the Doc Class AS from another external class?

View 7 Replies

ActionScript 3.0 :: Accessing The Stage From A Class Which Isn't The Document Class?

Jul 3, 2009

I'm being really dumb today and I know this should be simple.....How do i access the stage from a class which isn't the Document Class? For instance, I want to create a tween which takes in the parameters of the stage's width? So I've written.....

ActionScript Code:
var myTweenX:Tween = new Tween(this, "x", Regular.easeOut, this.x, stage.stageWidth, 60, true);

[code].....

View 4 Replies

ActionScript 3.0 :: Accessing Variable In Document Class From Within Another Class?

Mar 11, 2009

I have an array in my doc class that I'd like to access from an external class. Can you do this and if so what's the syntax?

View 6 Replies







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