ActionScript 3.0 :: Accessing A Class Private Variable In The Main Timeline?

Jun 2, 2011

Here's my main class:
 
[code]...
 
in the timeline I have a dynamic text box named my_textbox: var my_test:main = new main(); my_test.check_DVBViewer(); my_textbox.text = ??Basically the class waits for the callback variable (my_msg). The problem is: I need to set the dynamic textbox text to my_msg variable. How can I access it? I know I can access a public var in the timeline with functioname.variable but I can't define a public var inside a function, right?

View 3 Replies


Similar Posts:


ActionScript 2.0 :: Accessing Main Timeline Variable From Within A Class?

Dec 20, 2010

I have a class, the relevant parts of which are defined as follows:

class myClass extends MovieClip {
public function myfunc() {
trace( "mainVar: " + _root.mainVar );
}
}

As you can see, I want to access the variable "mainVar", which exists in the main movie, from within the class. This works fine, if I have only one instance of the class. But, if I have more than one instance, within separate movie clips, the value of mainVar is always taken from the first instance. How do I refer to the actual instance from within the class?

View 0 Replies

ActionScript 3.0 :: Accessing A Class Variable In The Main Timeline?

Jun 2, 2011

Here's my main class:

Code:
package
{
import flash.external.ExternalInterface;

[Code]....

Basically the class waits for the callback variable (my_msg). The problem is: I need to set the dynamic textbox text to my_msg variable.

How can I access it? I know I can access a public var in the timeline with functioname.variable but I can't define a public var inside a function, right?

View 4 Replies

ActionScript 3.0 :: Accessing A Main Timeline Variable From A Class?

May 18, 2010

I'm was getting good with as2 but recently made the mind switch from, I'll learn as3 tomorrow to as3 is awesome. The problem for me is that I don't understand the scope for classes. I know I can trace a variable on the main time line when the var is declared in the class. But how do you access a main time line var from a class? Here's an example - main time line Monkey.fla

Code:
var cagedMonkies:int = 10;
var monkeyTransport:MovieClip = new CarTrunk();

[Code]....

View 13 Replies

ActionScript 3.0 :: Private Variable In Class - Accessing Array?

Apr 9, 2011

I have a class that creates an array from a config xml file. I set a private variable in that class and use a getter in other classes to access the array. The routine that uses the array does the following:
- Call the getter and assign the returned value to a local (private) variable tmpArray.  the getter is a simple return() using a value that is established in the constructor.
- Uses a for loop to itterate over the contents
- Uses array.shift() to pop the item in tmpArray

The next time I run the routine, the contents of the array is empty. I'm using the same getter. I implemented the getter when I tried to manage both arrays in the same class figuring that as long as the original array was private (i also tried static), that the value would not change. I have since worked around the problem by moving the routine that fills up the original value from the constructor to the getter. So, consider the following code:

import flash.events.Event;
btn.addEventListener("click", btnHandler);
var myArray = new Array();
var myTmpArray = new Array()
myArray = ["one", "two", "three"];
myTmpArray = myArray;
function btnHandler(evt:Event) {
[Code] .....

If I create a variable myVar and set it to 1 then set myOtherVar = myVar, the both equal the same value. If I change the value of myOtherVar, myVar is not affected. But using the shift() method changes both the original and the copied array.

View 5 Replies

ActionScript 3.0 :: Get Variable On Main Timeline Into Document Class?

Mar 24, 2009

I have a new FLA with a variable in frame 1:

Code:
var testVar:String = "hello";
//--- my document class:
package

[Code]....

I just get null. How can I see a variable like that?

View 1 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 3.0 :: Accessing Main Timeline?

Jul 15, 2011

I'm using flash CS 5.5 and AS 3.0 . I've a movieclip that contains 3 more moviclips that are acting as toggle buttons. I want to change frame number / label of main time line upon click of these buttons. With _root no longer available I dont know know how to do it.

View 2 Replies

ActionScript 3.0 :: Accessing The Main Timeline

May 8, 2009

I have multiple instances of a movieclip (a1) within the main timeline.  These instances move around via tweening within the main timeline.  The instances also appear (are added) and disappear (are removed) while the main timeline is playing.
 
Within the movieclip is this actionscript:

[Code].....
 
How can I access the main timeline from each instance (even when it is not currently on stage)?  how I can keep all of my code within the movieclip?

View 2 Replies

ActionScript 3.0 :: Accessing The Main Timeline?

Jan 26, 2008

I have multiple instances of a movieclip (a1) within the main timeline.  These instances move around via tweening within the main timeline.  The instances also appear (are added) and disappear (are removed) while the main timeline is playing. Within the movieclip is this actionscript:
 
(code)
addEventListener(Event.ENTER_FRAME, ef);
function ef(evt:Event):void

[code].....

View 2 Replies

ActionScript 3.0 :: Loading Main Timeline Variable From Movie Clip Timeline?

Feb 2, 2010

I cannot seem to find anything of what I need from google.(Well, I can find the reverse method to what i need ) Basically I wish to access a variable declared in the Root Timeline from my Movie clips timeline.

[Code]...

View 2 Replies

ActionScript 2.0 :: [Flash8] Assign A Variable To The Current Frame Of The Main Timeline (not Movieclip Timeline)?

Mar 16, 2007

I simply want to assign a variable to the current frame of the main timeline (not movieclip timeline) I already know about _currentframe and it doesn't help in this case.

View 4 Replies

ActionScript 3.0 :: Accessing Main Timeline From An External .swf

Apr 29, 2010

I'm definitely more designer than flash developer (as most of you might know. At least those that hang in the lounge or Arena). I need to know how to allow a loaded .swf file to control the main timeline in AS3.

I have a container .swf that includes global controls (jump menu/volume control) and branding. Loading a swf for the dialogue boxes (timeline animated ... although I realize there may be better ways to handle it). Another swf for a simcity-ish illustration that has animated elements with various states. I need all to be able to communicate with each other. I was able to load the movies no problem. Even communicate with the loaded ones from the main timeline. Just need to be able to go the other way.

View 2 Replies

ActionScript 3.0 :: Accessing Main Timeline From Loaded SWF

Mar 11, 2009

I have a question about accessing functions or variables on the main timeline from a loaded swf. I know that there are a few ways to do this

1. Casting the timeline as a movie clip
Loader SWF Script
var testText:String = "Test";
var myLoader:Loader = new Loader();
loadData("loaded.swf");
function LoadData(aURL){
myLoader.load(new URLRequest(aURL));
addChild(myLoader);
}

2. Cast the timeline as a generic object
var parentObj:Object = this.parent as Object;
parentObj.unloadSWF("loaded.swf")
Why can you not just reference the main timeline of the container swf directly.

View 5 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 Nested MovieClips From The Main Timeline

Jun 3, 2009

I was trying to access some nested movieClips from the main time line but it was giving an error. What I have is a movieClip on the stage called "dog" and inside this movieClip I have two nested movieClips called "dogLH" and "dogRH". The movieClip "dog" was brought to the stage using actionscript 3.0 and when I tried to move the moveClips inside "dog" it gave me an error.

This is the code I have:

var dogog = new Dog();
dog.x =200;
dog.y =150;

[Code]....

What is strange is that if I add the movieClip "dog" to the stage manually and try the same thing it works. Any idea why it doesn't work when it is brought to stage with actionscript, but it works if I bring this manually?

View 2 Replies

ActionScript 3.0 :: Execute Functions In Main Document Class When Main Timeline Reaches Frame X

Oct 16, 2009

I have 3 functions in my main document class that I want to execute when the main timeline reaches a particular frame number. how do I do that?

see the code and comments

public function mainClass()
{
//stage declaraction
stage.align = StageAlign.TOP_LEFT;

[Code]....

View 5 Replies

Flex :: External SWF Variable Updates Global Variable In Main Timeline?

Feb 8, 2010

I have 2 movie clips, one being loaded into a container MC via "loadMovie();"In the main movie there is a variable with no value, in the external movie there are 5 frames, each with a value to update the variable in the main movie.

IE: if on frame 1, global value = 1 / if on frame 2, global value = 2 / etc etc I'm familiar with passing variables INTO an external swf, but am stumped on how to do it the reverse way.

View 1 Replies

ActionScript 3.0 :: External Swf Button Accessing A Mc Frame In The Main Timeline?

Feb 8, 2010

I've beein digging forums everywhere but cant find the solution to my problem...

I have an external swf "advert_3.swf" loading into the main index.swf.

advert_3.swf has two buttons: one needs to go to "services" frame the other to "events" within a content_mc which is in the index.swf.

that is in the index.swf:

ActionScript Code:
var request:URLRequest = new URLRequest("advert_3.swf");
var loader:Loader = new Loader();
loader.x = 35;

[Code].....

View 1 Replies

ActionScript 3.0 :: Reference Main Timeline - Accessing StartClips Function?

Nov 24, 2009

I have a function on the main timeline named startClips. Now, I want to call this from within two movie clips, the other nested inside the other. In other words, I have a movie clip called holder, and inside of a holder, I have a movieclip called homebase. Now, here is all the code I've been trying to use to access the startClips function which is own the main timeline from the movieclip homebase:

MovieClip(root).startClips();
MovieClip(root.root).startClips();
MovieClip(parent.parent).startClips();
this.parent.parent.startClips();

View 8 Replies

ActionScript 3.0 :: Accessing Nested Dynamically Created MovieClips From Main Timeline

Feb 1, 2010

I have a movie clip menu on a main timeline and inside that movie clip I have created four buttons dynamically. How to access those nested buttons/movieClips (add event listeners etc) from main timeline? Here I am adding menu to the display list on main timeline:

[Code]...

View 2 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 Main Stage Variable From Within MC

Apr 7, 2011

From within a movie clip, I'm trying to update variables on my main timeline. I tried both _parent.variablename and _root.variablename, but neither worked.

View 4 Replies

ActionScript 2.0 :: Private Class Not So Private?

Nov 26, 2006

Okay so you've got your private vars in your AS2 Class, you think they're all safe right? Wrong.

Doing a trace(MyClass.myvar); will spit out an error that the var is private and you can't touch it.

But a trace(MyClass["myvar"]); will work perfectly fine. You can use it normal, without any setters getters outside the class.

Is there a way to protect against this? I think this is a huge security flaw. I know it's simple OOP, but a private var in an object should have rules.

View 7 Replies

Professional :: Accessing Variable In AS On Other Timeline?

Feb 1, 2011

I have a variable declared in AS code on the main timeline, which I want to access from the timeline of an underlying movieclip. How do I do this?

View 4 Replies

ActionScript 3.0 :: Accessing A MC From A Class Other Than Main

Dec 2, 2010

How can I call a MC from a class other than my main. I am making a side scroller and I when the player hits certain parts of the level I want the floor to fall out from under him (think Mario). I created a new class to attach to the different MC of the floor but I cant figure out how to access the player MC from the class. The MC name is playerMC that was exported for actionscript, and the instance name is player_mc. This is the class.

[Code]....

View 1 Replies

IDE :: Accessing Timeline From Within Class?

Oct 23, 2009

I'm trying to write a class that somehow emulates the old AS2 gotoAndPlay(); function, but i'm failing to find a way to reference the timeline that is calling the Class Constructor.

this is what i am using to call the class, i'm placing this code in the frame of the timeline i want to control. but it always gives me a null error.

I Know senocular adressed the timeline issues in one of this forum's post, but i can't figure out what to do in order to register this class in the specific timeline in order to control it.

the frame goes like this:

[Code]....

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

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







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