ActionScript 2.0 :: Referencing Objects By Variable Name

Jan 11, 2007

I have a simple function that dynamically creates text fields. My text field name is referenced by var thisTextField. Problem is, when I try to do things with my text field, actionscript shoots back an error as such: There is no property with the name 'text'. How am I supposed to apply properties to my object if my objects name is a variable?

Code:
function showProducts() {
var products:Number = 0;
var thisTextField:String = "product" + products + "_txt";
for (var itemID in _global.rtsData[_global.rtsPos]["products"]) {
[Code] .....

View 2 Replies


Similar Posts:


ActionScript 2.0 :: Referencing Objects Not On Same Layer

Jul 15, 2011

Is it possible to control an object/element on a instance? If so, how is it done through actionscript?

There is an instance "instance140" off of the root, that has an element named img4 that i need to reference... does anyone know how I would go about that?

View 1 Replies

ActionScript 3.0 :: Referencing Objects In Array?

Feb 25, 2010

I've created a for loop to do the following:add instances of button MovieClip from library to stagename the instances via name propertyadd instance names to array for later referenceadd event listenershese 4 steps are working peachy, however, I'm having troubles referencing these instances later on through my code. I'm pretty sure that the problem is in my data types not matching, but I'm not sure how to fix it.

var menuBtn:mc_menuBtn;var menuBtnList:Array = new Array();
for(var b:int = 0; b < numFiles; b++){  //add instances to stage  menuBtn = new mc_menuBtn();  testClip.addChild(menuBtn); //adding button instances to

[code].....

View 5 Replies

ActionScript 3.0 :: Referencing Objects In Captivate?

Jul 6, 2009

I need to be able to dynamically position a component generated in Captivate 4 via ActionScript that in child SWF that is imported into the Captivate project. The problem is that I don't know how to reference the objects in the parent movie. I can set a label on the object and reference the parent itself with:

MovieClip(this.parent)

but this doesn't seem to work:

MovieClip(this.parent).label.y

And I suspect that it is because some how Captivate subclasses the objects but I'm having trouble finding out how the hierarchy is structured.

View 2 Replies

ActionScript 3.0 :: Referencing Stage Objects From Within Class

Sep 3, 2009

How to access stage elements from within a class.
buttonControls.as

Code:
package {
import flash.display.Sprite;
public class buttonControls extends Sprite {
// Navigation Hover Color
var hover = "0xF1E960";
var normal = "0xFFFFFF";
public function changeColor(object, color){
[Code] .....

View 2 Replies

ActionScript 2.0 :: Referencing Objects From Inside A Function?

Jun 18, 2011

I understand this, _parent keywords and its usage but I don't understand the following:

MovieClip.prototype.move = function() {
function toRight() {
this._x=50;

[code].....

View 3 Replies

ActionScript 3.0 :: Referencing Objects That Are Not Present On Frame 1 Of A Movieclip

Apr 20, 2010

I'm working with a movieclip right now that has two frames in it. I want the user to be able to go back and forth between the pages by clicking on tabs on either page. The button that they click on is only present on the frame that it is applicable (so, the button to switch to frame 2 is only present on frame 1, and vice versa).

I want to control when they are able to click back and forth, and be able to turn the buttons on and off whenever I need to, but since the button to switch back to frame 1 is only on frame 2, when I reference it from the main timeline, the button registers as a null object. How do I refrence an object that is not present on the first frame of a clip?

[Code]....

View 3 Replies

ActionScript 3.0 :: Referencing Variables/objects From External FLA Files?

Dec 1, 2010

I am trying to display in 'Reciever.swf' the value a shared object updated in 'TextSO.swf'. The following is my code for the Reciever

Reciever.as-----------------
package {
import flash.events.SyncEvent; import flash.events.NetStatusEvent; import flash.events.MouseEvent; import flash.net.SharedObject; import

[Code]....

I am getting an error that says that 'text_so' is an undefined property and that I can't access it. Yes, I have not declared 'text_so' in 'Reciever.as'. However it is the shared object instance from the 'Text_SO.as' file. How do I reference it from the 'Reciever.as' so that I won't get this error anymore?

View 1 Replies

ActionScript 3.0 :: Referencing Objects In The Level Above The Movie Clip?

Sep 10, 2011

i want to referance objects in the level above the movie clip that i have the AS in.  what i mean is that i have a movie clip on the stage, and that movie clip has some actionscript in it, and that AS needs to refer to an object on the main stage, how would i do that?  i have tried parent and stage 1, but neither seem to work

View 4 Replies

ActionScript 3.0 :: Referencing Variables / Objects From External FLA Files?

Dec 1, 2010

I am trying to display in 'Reciever.swf' the value a shared object updated in 'TextSO.swf' . The following is my code for the Reciever[code].,...

I am getting an error that says that 'text_so' is an undefined property and that I can't access it. Yes, I have not declared 'text_so' in 'Reciever.as'. However it is the shared object instance from the 'Text_SO.as' file. How do I reference it from the 'Reciever.as' so that I won't get this error anymore?

View 4 Replies

ActionScript 3.0 :: Dynamically Referencing Objects Names In Loop

Jul 12, 2009

The problem is referencing object names dynamically in AS3, in a loop. Example. I have an array called c4 which i would like to reference like this:

I have a number
var x:Number = 4

How can I do something like
trace(["c"+x].length);
(I know this is wrong!)

Same with other objects
E.g. Movieclip called mc4
["mc"+x].x = 100;

View 3 Replies

ActionScript 3.0 :: Object Oriented Game - Referencing Dynamic Objects

Jun 26, 2009

I'm doing this object oriented game and I create a bunch of 'boxes' via a for loop

Code:
Select allfor (var z=0; z < numOfBoxes; z++){
var box:Object = new Object();
box.mc = new Box();
box.mc.name = "box"+z
box.mc.x = Math.round((Math.random()*(530-box.mc.width)) + 20);
for (var i=0; i<boxXArray.length; i++){
[Code] .....

I get my random amount of boxes scattered over my stage (I haven't put in any checks to see if they are touching). How do I 'name' these boxes so I can reference them later? Say I want to move the .x of boxA in another function? Is there a simple way to call them box+z instead of just all as box? (Then I can run them through a loop later to talk to them).

View 2 Replies

ActionScript 2.0 :: Referencing A MovieClip With A Variable?

Oct 20, 2010

I'm trying to set something up that will print a bunch of boxes on a grid in a certain pattern, and set things up so that a path can be determined from the start to the end. Each grid square is a MovieClip with an instance name x0y0, x1y0, etc. for each coordinate of the grid. I want to set a variable in my grid square class to 1 or 0, depending on whether or not a box is in that square. So I have this code:

for(var j=0; j < row1.length; j++)
{
for(var i=0; i <= row1[j]; i++)

[code].....

View 3 Replies

ActionScript 2.0 :: Variable Object Referencing

Jun 14, 2007

I am in no way very knowledgable with ActionScript, so this might be very simple and I am looking in all of the wrong places... but basically here is my issue: Instead of accessing an objects attributes like this, _level0.thumbnails.thumbnail0._width = 500; I want to be able to access it with _level0.thumbnails. (this.id) ._width = 500; where as (this.id) is a variable that could be equal to "thumbnail0" or "thumbnail99" depending on which object gets clicked. I have everything working to if I hardcode thumbnail0 it works fine, and this.id does get set to whatever thumbnail I click's "thumbnail" + ID

View 2 Replies

ActionScript 3.0 :: Referencing Variable In AddChild?

Mar 16, 2010

First off I want to say that the resources on this site have been excellent

how to reference a variable when adding a new Movieclip?

Currently I am using this method:

Code:
var myVariable:String = "one"
if(myVariable == "one"){
var myMovieClip = this.addChild(new one())

[Cde]....

View 2 Replies

ActionScript 2.0 :: Array Name Referencing With A Variable?

May 2, 2005

fairly simple question (with a long explaination). I have an array, created from the results of another array and it's position in that array. There are actually multiple arrays It can be created from.

Eg.
Array1: clientName1, clientName2, etc.
Array2: clientType1, clientType2, etc.
Second Array: [clientName1,0], [clientName2,1] OR [clientType1,0] etc.

[Code]...

My issue is, I would like to be able to dynamically adjust the array that it is generating from. This would mean changing the bold bit of the code above. I have tried declaring a variable (type = names+"[i]") and using it in the linkArray declaration, however it will not see this as an array reference, only as a variable. What I want to know is, how do I reference the name of the original array as a variable so I can update it dynamically?

View 5 Replies

ActionScript 1/2 :: Referencing A Movie Clip By Using A Variable?

Jun 2, 2009

I have been using this line of code to fade in a movie clip:

new Tween(background_mc, "_alpha", None.easeNone, 0, 100, .5, true);

Now, I want to accomplish the same thing, only this time by using an element from an array (bg_array[currentSlideNumber]) that stores the instance name "background_mc"
 
I've tried the following, but it doesn't work:

new Tween(bg_array[currentSlideNumber], "_alpha", None.easeNone, 0, 100, .5, true);

View 3 Replies

ActionScript 1/2 :: Revisiting: Referencing A MovieClip Using A Variable?

Jun 15, 2009

This is a problem I thought I understood and was addressed in a previous thread [URL] but I have a new situation where the old solution isn't working.I have 3 instances on a "nested" movie clip. Their instance names are: b1, b2, and b3. When I trace these movieclips from the main timeline, I get:
 
trace(b1); // result = _level0.slide_mc.newMC.b1
trace(b2); // result = _level0.slide_mc.newMC.b2
trace(b2); // result = _level0.slide_mc.newMC.b3
 
From the main timeline, I want to fade up these movieclips using tween, but I need to do this by building the instance name in a variable:

var myInstance:String = "slide_mc.newMC.b"+ instanceNumber //(instanceNumber is equal to 1, 2, or 3)
 
Now, I thought using the variable in this manner would work:

new Tween (this[myInstance], "_alpha", None.easeNone, 0, 100, .5, true);

...but it doesn't.
 
I've checked trying to use the actual movie clip instance:

new Tween (this.slide_mc.newMC.b1, "_alpha", None.easeNone, 0, 100, .5, true);
 
...and it works fine.

View 2 Replies

ActionScript 2.0 :: Variable Referencing Inside Loops?

Apr 27, 2010

ActionScript Code:
function setUpButtons() {
var btnCnt = numeri_array.length;
for (i=0; i<btnCnt; i++) {

[code]...

i'm having a problem with this script... the onRollOver and onRollOut are working properly but the onRelease it's always the same i mean (my_mc.loadClip(foto[27], "container") for all the 27 buttons..

ActionScript Code:
for (i=0; i<btnCnt; i++) {
var temp = this["a"+i];

[code]....

and everytime i have to make a modify i have to write for every case..

View 2 Replies

ActionScript 3.0 :: Referencing Variable In Previous Player

Apr 19, 2011

I've got my variables set out in a layer on the main stage. I've also got a MovieClip which I want to write some code within but reference a variable in the main frame. I tried just referencing the variable name but it didn't find it. I then tried root.variable name but I'm now getting this error message:

ActionScript Code:
Symbol 'character', Layer 'CODE', Frame 1, Line 2
1119: Access of possibly undefined property deathReset through a reference with static type flash.display:DisplayObject.

View 9 Replies

ActionScript 2.0 :: Aligning Variable Sized Objects And Objects Inside Them

Jun 29, 2006

How do I align a movieclip, which width and height is user-defined, inside another object (this one is static, though). Top-left alignment is easy, x=0 and y=0, but what about center, center left, bottom left, etc? Math(.round) i suppose, but how?I want an object (static) inside the movieclip (user-defined) to stay aligned to, for instance, the top right corner, similiar to the minimize, maximize and close buttons at the top right of your browser.. The height and width data is pre-defined by the user in another file.But that does probably not make any difference...

View 3 Replies

ActionScript 3.0 :: Variable Referencing Between Classes And Custom Event?

Nov 5, 2009

I finally got the variable referencing between classes and custom event problems sorted out. Now I got a question regarding the Error #2044 and Error #2035. The error reads like this:

Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.

I've put all the swf in the same directory, so I don't think that is the problem. Could it be that my XML file is in another directory that's causing the problem? I also heard having quotes in the URL in the XML file could also be problematic. Is that true? Here are my AS and my XML file.
[code]......

View 12 Replies

ActionScript 3.0 :: Referencing A Variable On The Main Timeline From A .as File

Sep 2, 2010

I am having problems referencing a variable on the main timeline in a .as file using root.variable.

[Code]....

View 6 Replies

ActionScript 2.0 :: Referencing Instance Name With Variable In Prototype Call

May 25, 2005

I'm trying to reference an instance through the use of a variable in my call to a prototype. The variable is myVar and contains the instance name to which I want to apply the resizeTo prototype. My syntax is incorrect.

Code:
on(release){
//disregard this line
this.swapDepths(this._parent.getNextHighestDepth());
//this is calling a prototype named resizeTo
this.resizeTo(150, -100, -100);
//Setting instance name of another movie
myVar = "green";
//Trying to drop that instance name into my next prototype call
this._parent.myVar.resizeTo(100, _parent.old_X, _parent.old_Y);
}

View 2 Replies

ActionScript 2.0 :: [MX04] Referencing Multiple Movieclips With Single Variable?

Jan 25, 2009

Is there a way to reference multiple movieclips using a single variable name? For example,I'm making a side-scrolling game, and there's going to be many platforms, and I have some code that tells the player not to fall through these platforms, but I don't want to copy and paste the same "platform" code every time I add a new platform.

View 3 Replies

ActionScript 3.0 :: Referencing Variable Result Inside Speech Marks?

Jan 1, 2010

How would I go about refferencing a variable and then turning it into a string (if that is the correct terminology). e.g:

[Code]...

I need the result of variable something to end up inside the speech marks without loosing its obvious refference to the variable.

View 2 Replies

ActionScript 2.0 :: Referencing/loading A Dynamically Created Movieclip Variable?

May 23, 2008

I am trying to load an image in to a dynamically created movieclip, which is:

_root.mySlider."+stripX2(band[i][0])+i

but I can't seem to reference it. I can load the movie into _root.mySlider, but if I add the dynamic element (stripX2(band[i][0])+i) without quotes it it doesn't load. If I load with quotes i.e.

"_root.mySlider."+stripX2(band[i][0])+i

flash doesn't allow strings in movieClip variables.The code I'm using is belowm, it's the second to last line thats causing the problem:

var loadListener:Object = new Object();
loadListener.onLoadComplete = function(target_mc:MovieClip):Void {
trace(">> target_mc._width: "+target_mc._width);[code]......

View 2 Replies

ActionScript 3.0 :: Referencing Class Objects From Class?

Jun 19, 2010

I have an enemy on the stage that reads whether it's being hit by a bullet by a hittest. There's a for loop inside the enemy's class that looks for all the bullets and names the bullet that's hitting it "hitBullet". What I'd like to do have an easy way of seeing what type of bullet is hitting the enemy. I'm basically looking for something like

if (hitBullet == RegBullet) {
//do regular bullet dying
}else if (hitBullet == ClusterBullet) {
//do clusterbullet dying
}

, where RegBullet and ClusterBullet are classes. But I have no idea what hitBullet is equal to when a ClusterBullet or RegBullet hits it. I traced hitBullet to see what it would return and got "[object ClusterBullet]", but I'm not sure what that would be in the actual code.

View 2 Replies

Actionscript 3 :: Referencing Variable In Document Class From Another Class?

Mar 11, 2011

I need to increment an integer variable in a function within the document class upon transpiring event in another class. I can't seem to figure out how to call the function and reference the variable.

View 2 Replies

ActionScript 1/2 :: Variable References To Objects?

Aug 30, 2010

I've got a 15x3 grid of dynamic text fields in an object called "textbox" that I want to reference through a for loop, so I don't have to have 45 lines of code for assigning stuff to those fields.I have each dynamic field named by their placement in the grid, so, c0a, c0b, c0c, c1a, c1b, c1c, etc.I can also name them c00, c01, c02, if necessary.
 
I tried:
 
for (i=0; i<15; i++) {
textbox.c[i]a.text = "Cell " + i + " A";
textbox.c[i]b.text = "Cell " + i + " B";
textbox.c[i]c.text = "Cell " + i + " C";
}
 
but that gives me a syntax error.I also tried naming them c00, c01, c02, c10, c11, c12, etc., so I could do a double nested loop:
 
for (i=0; i<15; i++) {
for (n=0; n<3; n++) {
textbox.c[i][n].text = "Cell " + i + n;
}
}
 
but that gives me a syntax error too.So, is there a way to access all of these with a for loop, or am I going to have to do it the long way?

View 3 Replies







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