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


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

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 :: Accessing Timeline Variables From Within A Movieclip?

Jun 25, 2009

i use MovieClip(this.parent) to access a variable that's outside of the movieclip i'm currently writing code in. However, this doesn't work within two functions.For example:

function editMainText (e:Event) {
MovieClip(this.parent).headline.text = "Hello"[code]....

doesn't work.There are probably a few small errors in my code, but i essentially need to know how to modify MovieClip(this.parent) to work within the second function.

View 4 Replies

ActionScript 3.0 :: Accessing Main Timeline Variables From Within A MovieClip

Jun 13, 2009

Let us say we have a movieclip "mc1" on the stage. We also have another movieclip "mc2" inside mc1. We have declared a variable, say, var number1:Number=5 on the first frame of the main timeline. Now we go inside mc1 and then inside mc2 and write some code on its first frame. Is there any way to use the variable number1 over here? Can properties of mc1 be altered using the code written here? In AS2, it could be done using the "_parent" command, but it doesn't seem to work in AS3. (when we use parent and try accessing a property, it says that it is possibly undefined)

View 3 Replies

ActionScript 3.0 :: Accessing MovieClip Methods From A Class?

Oct 17, 2009

Here is the situation:I have created a movieClip named "tp_crack" on the timeline and created its class using linkage called "tp_crack".The tp_crack mc is like a small rectangle which breaks in 3 seconds when it is played.I have a seperate class in which I have used tp_crack to create many instances of tp_crack going by the names: cracked1","cracked2" etc.These instances are present in another movieClip (this time created within the class) called "crackContainer".Now I have added the following code to check for hitTest of those cracked1,2,3...... with a spaceship.The hitTest works but flash does not recognize the pieces as movieClips and does not play them as required, instead it gives me an error saying:1061: Call to a possibly undefined method play through a reference with static type flash.displayisplayObject.

for (var i:uint=0; i<crackedPieces; i++) {
if (crackContainer.getChildAt(i).hitTestPoint(Spacesh ip.x,Spaceship.y+(Spaceship.height/2),true)) {

[code].....

View 4 Replies

ActionScript 3.0 :: Accessing MovieClip On Stage From Class

Apr 11, 2009

1.I have a MovieClip in the Library. There is a named and dynamic text box in the MovieClip. In Frame 1 of the .fla, I construct the MovieClip from the class StatusBoard and add it to the stage. There is one setStatus method in the class to set the text. This works fine.[code]

2.I have a bunch of buttons that I created from a class called LinkButton.as (they are MovieClips, not _btn buttons). FWIW, they are attached to other MovieClips, but they work fine. The trace output is fine. What I am trying to do is have the rollover change the text in the billboard.[code]

3. In lay terms, I used addChild to add a MovieClip with a dynamic TextField to the stagw and I want MovieClip buttons created from an .as class to be able to change the text on a rollover.What I can't seem to do is actually reference the billboard that I added using addChild from the .fla.The buttons work and trace the desired text, I can't seem to send that text to the billboard.

View 2 Replies

ActionScript 3.0 :: Accessing A Movieclip From A Static Class?

Sep 21, 2009

I'm working on a small networked game (server is written in C# ready to go). I've completed all of the networking classes utilizing xmlsockets (socket handling, packets etc). My issue is once you get to the login screen and attempt to authorize a packet is sent depending if your login has been accepted so if it has you delete the login movieclip and show the game movieclip but I can't access it from my static class (it was created on the main stage).

View 4 Replies

ActionScript 3.0 :: Flash Accessing MovieClip In A Class?

May 21, 2010

Document Class 'whatwedo'

[code]....I'm trying to access the loadMC movieclip in the document class. It dosnt work,

View 6 Replies

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

May 9, 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]...

View 4 Replies

ActionScript 3.0 :: Accessing Class Instance At Root From Movieclip

Nov 15, 2010

I have declared a object in my 1 st frame of application.

ActionScript Code:
var objTest:Test = new Test();

I am tring to access the object from a movie clip. Movie clip is located in frame 2. I am getting error

ActionScript Code:
this.parent.objTest.IncrementCount();
trace(this.parent.objTest.QuestionCount);

1119: Access of possibly undefined property objTest through a reference with static type flash.displayisplayObjectContainer.

How to access a object instantiated at root from a movie clip.

View 1 Replies

Professional :: Accessing Class Instance At Root From Movieclip?

Feb 25, 2010

I have declared a object in my 1 st frame of application.

ActionScript Code:
var objTest:Test = new Test();

I am tring to access the object from a movie clip. Movie clip is located in frame 2. I am getting error

ActionScript Code:
this.parent.objTest.IncrementCount();
trace(this.parent.objTest.QuestionCount);

[code].....

View 4 Replies

ActionScript 3.0 :: Accessing MovieClip From Flash Stage In Class

Jan 10, 2011

What is the best way to accessing movieClip from a flash stage in AS3 Class? And what if the as3 class it's in a package, outside the Document Class?

View 4 Replies

ActionScript 3.0 :: Accessing Class Instance At Root From Movieclip?

Nov 16, 2010

I have declared a object in my 1 st frame of application.

ActionScript Code:
var objTest:Test = new Test();

I am tring to access the object from a movie clip. Movie clip is located in frame 2. I am getting error

ActionScript Code:
this.parent.objTest.IncrementCount();
trace(this.parent.objTest.QuestionCount);

[code].....

View 3 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

Flash - Accessing Nested Movieclips From Main Movieclip Class?

Feb 16, 2011

I have a MovieClip, that I'm going to add to the display list with my document class at runtime beacuase there will be many instances of it. The MoviClip "box" has 3 more MovieClip instances inside it,and each of those three have two more.It looks like this:

box
circle 0
oval0
oval1

[code]....

View 2 Replies

ActionScript 3.0 :: Referencing Class Variables For A Movieclip?

Dec 5, 2011

Hey guys. It's been a while since I've used Flash and I am still trying to wrap my head around Actionscript 3.0 and the way it works; I am so used to the way AS2 works.I have provided the code below, it's very simple, so you might be able to skip this explanation and just take a look at the error and the code:

- I have made a movieclip called HeroMC in my FLA.

- The HeroMC movieclip has the AS Class linkage of exactly the same name, "HeroMC".

- I have made an actionscript class file, HeroMC.as, to house specific variables for my hero; such as Name, Age, xPos and yPos.

- I have also made an actionscript class file, Main.as, the document class for this FLA.

- In Main.as I instantiate HeroMC using the variable hero, and then run the function addHero() from my constructor.

- addHero() is a simple stage.addChild(hero);

This all works perfectly fine and it adds my hero to the stage. However, the problem arises whenever I try to reference one of the variables from HeroMC.as. I am met with this error - I will use the variable xPos as an example.

Here is the error:

1119: Access of possibly undefined property xPos through a reference with static type HeroMC.

Here is the code for Main.as:

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

[code]....

It is obvious this is a very simple problem, but I have searched Google, Kirupa and Flashkit for an answer, but none of the threads I find discuss my specific circumstances and I am unable to find the specific information I need to.

View 3 Replies

ActionScript 3.0 :: Calling Document Class Variables In A Movieclip

Feb 25, 2010

I have a variable, we'll call it helloNurse, defined in the document class, we'll call it Joy, as a public variable. Meanwhile, I have a movieclip within the FLA that uses that class as its document class that, simply put, needs to access that variable. I had read up that the following SHOULD work:

[Code]...

View 12 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







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