ActionScript 2.0 :: Reference A Button In A Dynamic Array?

Mar 10, 2009

I've got a couple of columns of buttons loaded with attachMovie and looping through an xml array with a for loop, so they're named, for example, "thisBtn"+i+"_mc". But I don't seem to be able to reference them in the script with either a written-out name like thisBtn0_mc, or with "thisBtn"+i+"_mc".

How exactly do you reference each individual button?

View 7 Replies


Similar Posts:


Actionscript 3 :: Button Reference In An Array?

Apr 11, 2012

I have two buttons that are in a movieclip, how can I reference them like I have done with the 2 buttons below so that they can be added into an array?

container.anotherButton and container.anotherButton2 are the buttons I want to add to the array.

var agreeButton:SimpleButton; var disagreeButton:SimpleButton;

var buttonArray:Array = new Array(agreeButton, disagreeButton);
for (var i:int = 0; i < buttonArray.length; i++) {
buttonArray[i].addEventListener(MouseEvent.CLICK, mouseClick);
}

View 1 Replies

ActionScript 2.0 :: Using Array To Reference Button Number?

Aug 18, 2010

I have an array for my navigation bar (btn1, btn2, btn3 etc) where when the user clicks on a button, it goes to the correct page, and all is good. Now, I when the user clicks on a page, I want it to play a funtion where the button (movieclip) goes to frame2, and the button is disabled. How do I say 'if user clicks btn1, and is on page1, now disable btn1'. My code is below:

PHP Code:

myArray = ["btn1", "btn2", "btn3", "btn4", "btn5"];
for (i=0; i<myArray.length; i++) {
_root[myArray[i]].onRelease = function() {

[code]....

View 2 Replies

Actionscript 3 :: Remove The Word Button From The Reference To Reference The Actual Item

Apr 11, 2012

I need to remove the word Button from the reference to reference the actual item that will be tinted.

[Code]...

View 1 Replies

ActionScript 1/2 :: Interesting Array + Dynamic Image / Button / Tab Quandary

Jul 14, 2009

Last week I had posted about getting a bit of clarification on dynamic tabs, as seen in this thread: [URL] The next step has my head spinning a bit. Here's the setup: This is a slideshow viewer, ala PowerPoint. Images are pulled in from an external directory via an array. Dynamic tabs are also generated in an array. Right now the demo has 10 images in the first array and 6 tabs in the second array:

[Code]...

now, some of the images will be part of a range - as in maybe the first three would fall under the "Safety" tab, next two under "Efficacy", etc....so when a viewer clicks on a tab the player loads up the first photo in that sequence. So: User clicks tab "X", this compares "X" with the range of images associated to "X" and loads the first in the sequence. Now, to add in more fun, there's a next and back button. So now if someone hits the next button then they should view sequentially the next image in the "X" image array (or sub-array). and the reverse for the back button. so my first thought is that I'd need to have the AS compare Safety with the imageList Array - something like

[Code]...

View 3 Replies

Loop Through An Array And Use The Array Value To Reference A Variable?

Sep 25, 2009

I want to loop through an array and use the array value to reference a variable.

The Setup:
(For illustration only. Not actual script)
My MCs:
triangle_mc
square_mc

[Code]....

View 1 Replies

Actionscript 3.0 :: Dynamic Mc's To Reference Other Dynamic Mc's

May 1, 2009

I have a dynamic group of movieclips... these fade in/out on rollOver/rollOut. During the rollOver they reference an index in the legendArray. In the legendArray each index has 5 digits (0 = off, 1=on). Over each "bg" mc are a series of 5 dynamics mc's ("dt" mc (see eg.jpg)), which are to change tint via tween, depending on the legendArray index. I have been able to associate the btn("bg" mc) with the proper legendArray index, but for some reason I'm having difficulty associating the legendArray index to the "dt" mc. As it stands, I keep getting error 1069.

[Code]...

View 1 Replies

ActionScript 2.0 :: Reference Everything Else In An Array?

Feb 27, 2007

I'm working on a set of buttons so that when one is rolled over, it gets larger and the remaining buttons get smaller. This however will all be housed in the rollOver function of the individual button rolled over. So I used an array and a "for loop" to encompass all of the buttons. I am able to reference the one I roll over by simply using "myButtons[i]" but I cannot figure out how to reference all the others using the array.

#include "mc_tween2.as"
var myButtons = [this.myButton_1, this.myButton_2, this.myButton_3, this.myButton_4];
for (var i=0; i<myButtons.length; i++) {

[code].....

View 7 Replies

ActionScript 3.0 :: Using Array Value To Reference Variable

Sep 25, 2009

I want to loop through an array and use the array value to reference a variable. The Setup:(For illustration only. Not actual script)

[Code]...

View 3 Replies

ActionScript 1/2 :: Use Switch In Reference To An Array?

Mar 18, 2010

I have an array which changes with a pop and a push on button clicks:
 
var nextLoad = ["img0"]; It will always contain img0, or img1, or img2, etc
 
Then I'm trying to control another element on the stage by checking which img# is in the array:
 
trace (nextLoad); // this correct shows the new value in the array

[Code]...

View 5 Replies

Flash :: Can't Reference Nested Array

Oct 6, 2010

[code]...

This is nested inside another for loop which creates an array of the movieClip rows. Problem I see them drawn and positioned correctly on the stage but I cant reference any other than the top row in order to change the alpha for example.

View 1 Replies

Actionscript 3 :: Cant Reference Array Class?

Feb 3, 2011

I have a class consisting of a nested array called twoDArray.

public class TestArray
{
public function TestArray() {
var twoDArray:Array = new Array(new Array("one","two"), new Array("three", "four"));
}

[Code]...

I thought I would be able to reference OrbArray for example using trace(OrbArray[0][0]); giving me the output I am looking for of "one". When I attempt this I get ReferenceError: Error #1069: Property 0 not found on com.orbclasses.TestArray and there is no default value.

View 2 Replies

As3 :: Flash - Reference To Array By String (name Of Var)?

Feb 15, 2011

is it possible to create a new reference to an array by using it's varname ?

e.g.

private var _myArray:Array = new Array("a","m","d");
...
function getReference(_varName:String):void
{

[Code]....

View 2 Replies

Flash :: Reference An Movieclip With Same Name In An Array?

Mar 6, 2011

I realize this is very basic but i need a quick way of referencing all my objects in an array,I have a series of movieclips with instance names "block1" "block2"... etc.

I there a quick way to reference these in an array something like "block"+1 ?

View 1 Replies

ActionScript 2.0 :: Array Overwriting - Reference/value?

Nov 14, 2008

I've created two custom classes to contain data for a web forum controller flash tool:

class postClass
{
public var post_id:Number;
//plus some other variables like timestamp etc

[code]....

When I try to assign a new post to a user (by adding the post data to the postArray variable) I overwrite posts that I had already placed under other users. More specifically, if I'm posting the first post for User Y, I overwrite the first post for User X with the exact same data.I thought this was a reference vs. value passing error, but I tried to eliminate this by not copying the "postClass" objects, but assigning the data directly into the user's postArray array:

var userArray:Array = new Array();
function addNewUser(masterPostIndex,UserNumber)
{

[code]....

This all seems to work fine until I try to write a new post for a second or third user. If I trace the contents of User X's posts, they immediately become identical to the content of User Y's posts, as soon as User Y's posts are added. Later, when User Z comes along, both User X and User Y's posts are overwritten. This code is kinda long, so I didn't want to post the whole thing - but I can post any parts you're interested in, of course.

This really 'feels' like a reference-passing error (arrays are all looking at the same location in memory), but I can't figure out what I'm doing wrong - I'm not making a postClass object and then pushing it onto the user's postArray (I tried that too, same result).

var newPost:postClass = new postClass();
//read and assign values to newPost
userArray[userIndex].push(newPost); //

this is clearly passing the referenceI can see how the latter example would pass the reference to newPost to the user object, then when I change newPost in the next iteration (when user Y posts something), User X's data will change too. I tried to avoid this with the first set of code.

View 3 Replies

ActionScript 3.0 :: Create Dynamic Array Element Names Based On Another Array?

Jun 28, 2009

Is it possible to, if you have an array of class names like ActionScript Code: var city01names:Array = ["pic_01", "pic_02", "pic_03" ...] make a new array which would read these names, instantiate them, and push them into a new array containing the instances of all these pictures, which I could then use for a slideshow?

[Code]...

View 7 Replies

ActionScript 2.0 :: Giving An Array Like Reference To A Movieclip?

Jun 14, 2009

If n=1,b1.gotoAndStop(2); is to happen.n=2,b2.gotoAndStop(2); is to happen.But i don't want to put conditions like this.I want to putting something like this:b[n].gotoAndStop(2); or something.Is it possible.Is there any other alternate logic.

View 2 Replies

ActionScript 3.0 :: Reference An Array From A Stage In Class?

Nov 4, 2009

Ive got two classes and my stage. I'm trying to use an array to keep control of my enemy class's number for collision purposes and I managed to get the enemies to populate the array.

View 3 Replies

ActionScript 3.0 :: Reference Instance Of MovieClip From Array

Mar 23, 2012

I created an Array of lrgIcons that contains several MovieClips, they are then positioned within a second MC and pushed to a second array of lrgIconsOnStage, they are enabled as buttons and assigned an event listener (all of this works fine). Problem is, I want to know which lrgIcon is selected and react to it with an if statement. When I trace the array of lrgIconsOnStage I get [object amazonLrgIcon],[object emailLrgIcon],[object gmailLrgIcon],[object messagesLrgIcon],[object missedCallsLrgIcon] and when I trace e.target I get [object amazonLrgIcon] (depending on which item I selected, which in my mind, should trigger the code correctly, but it does nothing, Why?

Code:
var currButton:String;
var lrgIcons:Array = new Array(amazonLrgIcon,emailLrgIcon,gmailLrgIcon,messagesLrgIcon,missedCallsLrgIcon);
var lrgIconsOnStage:Array = new Array();
var lrgIconPosY:int = 69;
var lrgIcon:MovieClip;
[Code] .....

View 7 Replies

ActionScript 2.0 :: Reference Each Array Name To Pass Into Function?

Nov 12, 2004

In AS2 I have several arrays constructed like this :
var myArray0:Array=new Array(value,value,value...)
var myArray1:Array=new Array(value,value,value...)
var myArray2:Array=new Array(value,value,value...)
var myArray4:Array=new Array(value,value,value...)
...

What I'm trying to do is use iteration to reference each array name to pass it into a function.
Like :
function doSomethingWithArray(arrayToPass){
...
}
//Later somewhere in For loop... :
_root["myButton"+i].onRelease=function(){
doSomethingWithArray(WHAT-THE-HELL-I-TYPE-HERE[i])
}

View 2 Replies

ActionScript 2.0 :: Reference Array In A Class File

Oct 4, 2005

I have a class file that creates an array of image paths from an xml file. i need to know how to from the main stage refrance to get that array.

View 2 Replies

ActionScript 2.0 :: Making A New Array Equal To A Different But Not A Reference?

Oct 12, 2006

Is there a way to make a new array like an old one but have it not be a reference?

View 2 Replies

ActionScript 2.0 :: Passing Array Variables By Value Not Reference

Dec 11, 2006

It took me hours to figure our why this was returning the wrong value - when assigning one array to another it passes by reference not Value. I need a way to force it to pass by values. e.g. copy the existing array and have the second array reference it, so i am free to modify the first array without changing the values of the second.[code]From the example above You see that in Actionscript when assigning one variable to another it does it my reference not value. So when you chage the value of one array it changes the value of the other automatically.I need to have the "test2" variable reference the "test1" array only by value so if modify "test1" the values of "test2" won't be modified.

View 7 Replies

ActionScript 2.0 :: Get Copy Of Object In Array NOT Reference?

Feb 6, 2007

In the code below, i create an object and stick it in an array, then I make a duplicate of that array. I loop though the duplicate and change the value of one of the props of the object in the duplicated array. Doing this however unintentionally changes the prop value of an object in the original array. I'm assuming that the objects in the duplicated array are mere references to the objects in the original array. Is this correct? And if so, how do i make unique copies of those objects in the original array, so that changes made to the objects in the new, duplicated array are exclusive to those objects?

I know that i could probably make a new object when duplicating the array, and then recreate each prop, assigning values from the original objects.. but this is a simplified example. The project im working on has many props for each object, so, id rather just make copies if at all possible.

Code:
var testObj:Object = new Object();
testObj.prop1 = "hello";
//
var testArr:Array = new Array();

[code].....

View 1 Replies

ActionScript 2.0 :: Remove Movieclip Reference From Array?

Aug 29, 2007

this array prototype manage to remove Strings and Integers but not movieclip references.

PHP Code:

Array.prototype.removeArrayItem[code].....

View 1 Replies

ActionScript 3.0 :: Making A Reference Array Of Objects?

Jan 20, 2010

I want to loop through an array of map tile coordinates, place a tile on the stage for each coordinate, and put a reference to each tile instance in a separate multidimensional array called mapRef, where the tile instances can later be referenced by their coordinates in mapRef. Is this line (excerpt from the code below)... Main.mapRef[i][j] = mapTile;.[code]

View 3 Replies

ActionScript 2.0 :: Dynamic Reference To MC Using Variable?

Jun 9, 2009

Using AS2. I have a variable defined:

activenav = "services";

I then want to reference the variable in a MC string. I've tried many variations of this:

_root.my[activenav]Clip.gotoAndPlay("Out");
Essentially, I want Flash to see this as:
_root.myservicesClip.gotoAndPlay("Out");
Getting syntax error.

View 2 Replies

ActionScript 3.0 :: [CS4] : Dynamic Reference To Classes?

Dec 9, 2009

Been trying to make the transition from AS 2 to 3 but not without it's speed bumps. My first major hurdle has been trying to dynamically reference a class by only knowing it's name. I came across the code of import flash.utils.getDefinitionByName; but that's not working for some reason. It keeps giving me the error:

Quote:

ReferenceError: Error #1065: Variable characterType5 is not defined.

My code in getting this is:

PHP Code:

import flash.utils.getDefinitionByName;
var className:String = "characterType" + 5;
var tempClass:Class = getDefinitionByName(className) as Class;
var char = new tempClass();

View 2 Replies

ActionScript 3.0 :: Dynamic Reference To MC's On Stage?

Sep 30, 2010

I have 9 MovieClips on stage (p1, p2, p3...), different colors and sizes. I have one AS3 class -Snake- that as an instance is supposed to duplicate one of these MC's as a Shape. The reference to the specific MC is supposed to be on the constructor method. These instances are supposed to be triggered from one global Enter.FRAME event.

My question: How can I refer a distinct MC from within a class? I ask this because this MC will be dynamic and its properties ever-changing (position and color). I know this can be solved by adding distinct Enter.FRAME listeners per instance, but I'd rather avoid bad practices.

[Code].....

View 1 Replies

ActionScript 3.0 :: Dynamic MovieClip Reference?

May 9, 2009

how does one reference a MovieClip instance dynamically in AS 3.0? Example, I create a new instance of a "marker" MovieClip class that inherently has within it a series of embedded MovieClips labeled: "m1", "m2", "m3" etc ... and I want to be able to dynamically reference those embedded MCs.I used to do this all the time in AS 2.0, and can't recall how to do it in AS 3.0.I know it is something like this:

number = 1;
marker = new StaticMarker();
var thisMarker = this.marker.m[number];[code].........

View 3 Replies







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