Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




How To:value Of Sting Becoming An Array In A Variable



I am doing something completely wrong. When I trace the below I get the correct array name but what I want is the value of index 0. how do I get the below variable to spit out the value the array as its own value??

thanx

ActionScript Code:
var mainImage2:String = [currentWorkBtnPrefix + 'main_arr[0]'];



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 06-21-2007, 12:16 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Sting Variable To Mc Path - VARIABLE TYPES
Hey all Im building a variable like this

var m = "_root.subNav.subNav" + i;

When I do a trace to find the var type it comes back as a string so my function wont execute thinking it is a string and not a path. Does anyone know how to fix this or change the variable type on the fly in AS 1.0? Ive tried:

var m =eval( "_root.subNav.subNav" + i);

But that came back undefined....
Thanks.

Eval A Sting Into An Array Reference
I have a data structure called siteContent (which is really a hash) and I want to be able to build a string and then eval the string to reference the array element.

For example let's say I wanted to access the element

siteContent['Link A']['Sub 1']

Then I would like to be able to do something like this:

my_reff = eval("siteContent['Link A']" + "['Sub 1']");

and have my_reff be the actual reference to the array element, not a string.

Does anyone know how I can do this?

Thanks!

-Sean

Sting Values
name=_name;
trace(name);

myString=eval("name");
trace(myString);

suffix=myString.substr( myString.indexOf( "text", 0 ), myString.length );
trace(suffix);

Temp=myString.substr( 0, myString.indexOf( "text", 0 ) );
trace(Temp);
---------------------

the _name of the object is 'londontext'. The whole point of this excercise is to get the value city name out of the object name which is made up of the city name suffixed with the word 'text'.

i get the first two traces ouputted as 'londontext' so it seems that myString is starting with the correct value for the rest of the script. but then the rest of the code doesnt work. i get 'n' as the third output and nothing fo rthe forth.

but if i start the script myString="londontext", everything works as expected and the third and fourth outputs are 'text' and 'london' respectivelly.

what's missing?

[F8] Sting Replace Help
I have a dynamic text box that is populated by previous frames input boxes. The call to populate the dynamic box is vary large and contains more than just quoted text and variable names.

Everything works perfect, but I have an issue I want to remedy. If I leave an input box blank in the previous frames I get "undefined" in the dynamic text box.

I am using this string replace technique and it works well for what it does, but I need it to check the whole dynamic text box after being rendered for the "undefined" not a "string of text here" but instead a "dynamic.text"

I can't figure it out as nothing is working. Ideas?

~MoN

Pass A Sting To A Button
I use a textfield on my webpage and i want to pass the string of that textfield to a button.

example :
I set in the textfield the words : click on this button
so on the button should appear click on this button.

Can anyone help me ?

Loading In Sting Vars With & In Them
is there any way of escaping the & in something like this?

TrackNo=8&artist=Oasis&Title=cigarettes & alcohol&Comp=Definitely Maybe

Converting A Sting To A Number
hey ppl, I have a var that contains a string and i need to convert it into a number but I dont know how example:

a = "5"

how do i make it a=5

I know how to convert a number into a string but how do i go the other way?
pls help

thx

SetMask + Sting = Error
Why doesn’t setMask accept a String variable to be masked.

This code works:

var sPic:String = "mcPic";
this.attachMovie("mask","mask",1,{_x:300, _y:200});
this.attachMovie(sPic,sPic,2,{_x:300, _y:200});
mcPic.setMask(mask);


This code dose NOT work:

var sPic:String = "mcPic";
this.attachMovie("mask","mask",1,{_x:300, _y:200});
this.attachMovie(sPic,sPic,2,{_x:300, _y:200});
sPic.setMask(mask);


I get the following Error:

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 4: There is no method with the name 'setMask'.
sPic.setMask(mask);

Total ActionScript Errors: 1 Reported Errors: 1

Converting A Sting To A Movieclip
I want to convert a sting which comprises of the instance and a suffix so I can edit show my addresses.

var addressName = event.target.name + "Address";

I tried this but is is null when I trace it.





myMap.aberdeenRed.addEventListener (MouseEvent.ROLL_OVER, showAddress);

function showAddress (event:MouseEvent) {
trace(event.target.name + "Address");
var addressName = event.target.name + "Address";
addressName.alpha = 0.2



}

Combining A Sting Var & A Number Var
I tried everything before i posted this questions...

How can I combine my counter number to the end of the string variable?

name1 = value
i=1

while (i<amount){
combovox.addItem(name + i);
i=i+1;
}

desired output value1

What am I doing wrong?

Calling A Function With An Array Variable As Arguments Is Resetting Array?
I'm going to post the full code of the two functions, disregard the "fluff" unrelated to the two functions as it is all working flawless, I've tested this HEAVILY and cannot understand why it keeps setting the entire array to undefined!

Any help would be grateful.

ActionScript Code:
// processReplace Function    function processReplace(transferFiles) {        var processArray:Array = transferFiles.slice();        var fileName:String = new String();        var filesArray:Array = new Array();        var replaceArray:Array = new Array();        var exists:String = new String();        var error:String = new String();        var promptResult:String = new String();        // Check        for (i=0; i<processArray.length; i++) {            // This is where it bugs up            <b>exists = processSearch(transferFiles[i][1]);</b>             if (exists == "replace") {                replaceArray.push(processArray[i]);            } else {                filesArray.push(processArray[i]);            }        }        // Prompt        if (replaceArray.length>0) {            error = "Replace "+replaceArray.length+" item(s):

";            for (i=0; i<replaceArray.length; i++) {                error += " - "+replaceArray[i][1]+"
";            }            promptResult = mSystem.messageBox(error, "Replace Existing Files?", 4);        }        // Action                  if (promptResult == "NO") {            transferFiles = filesArray;        } else if (promptResult == "YES") {            transferFiles = filesArray.concat(replaceArray);        }        processTransfer(transferFiles);    }

The processSearch

ActionScript Code:
// == processSearch Function    function processSearch(sentInfo) {        for (i=0; i<_global.boxFiles.length; i++) {            if (_global.boxFiles[i] == sentInfo[1]) {                return "replace";                break;            }        }    }

Basically it's supposed to check to see if the file exists and return as true if it does and add it to a replace array, then the replace array is processed into a single string and put into a dialog box through the flash wrapper prompting them to "replace the files or not".

It makes the replace array just fine, it actually even has the right "count" in it but it's setting all the "filenames" to undefined because of the exists = processSearch function.

I even tried to make a new array and run the search just from that one and set the values from the old one and it's still failing.

Is it because of the "break" or can anyone figure it out? Iknow it's hard because you can't use the code

ANY Solution ideas are welcome, even if you think it's dumb

Thanks!

Sting Manipulation : Newbie Problem
hey all

I need help on this one..

i got a list of data.. looking like this...

xxxxxxxxBlablabla
xxxxxxxxYadadadaad
xxxxxxxxBluhbluhbluh
xxxxxxxxYapyapyap


if i want to remove the first 8 characters.. ( "xxxxxxxx" , in this case can be anything)..

how do i do it..? substr?

help apreciated

Creating A Query Sting In Flash Mx
this isn't working, any ideas on the correct syntax:
i have var in the flash
qq=3 and rr=6

I'm trying to use a getURL to pass these onto the proceding page, something like so:

getURL("0eure7ghi.asp?qq=+qq&rr=+rr"), "_self")

any ideas?

thanks

Sting To Number Conversion Issue
Why does the following code convert the string to 399?

var str:String = "0617";
var strNum:Number = Number(str);
trace("strNum: "+ strNum);

Thanks,
Jeff

Problems With Splitting A Sting [ String.split ]
Im trying to split a large string into an array.
the problem is that flash "hangs" when i try to split a large string (>100 vars) It works (very slowly...but) properly if i use a small string (about 20 variables)
does anyone have the same problem (there MUST be whole communities that have faced this problem, not?)
i found this splitting code on the internet but its quite bulky does anyone know an other routine for splitting?
Thanx in advance!

code:

String.prototype.split = function(d){
if (d != null){
var r = new Array();
var size = this.length;
var c = 0;
var n = 0;
if (d != ""){
for (var i=0; i<=size; ++i){
if (substring(this, i+1, 1) == d){
r[n] = substring(this, c+1, i-c);
c = i+1;
++n;
}
}
if (c != i){
r[n] = substring(this, c+1, i-c);
}
}else{
for (var i=0; i<size; ++i){
r[i] = substring(this, i+1, 1);
}
}
}else{
r = new Array(this.toString());
}
return (r);
}

Passing Array Variable Name In To Component Variable & Getting It's Value
Hi, All
Anyone can solve my problem????
My Problem is that I want to store a array' s name in to a component variable. like this:-

working in this case

Scene action on timeline
_global.arr = "This is aray Test"

component parameters
VarName : _global.arr



Not working in this case

Scene action on timeline
_global.arr1 = new Array()
_global.arr 1[0]= "This is aray Test"




component parameters
VarName : _global.arr1[0]




in component I'm doing this on timeline action
abc.text = eval(VarName)


plz help me out of this

Regards
Ankur Arora

Variable Name And Array
i have a problem

I try to build an array from a variable, which name is a variable.
And it doesn't work !

KethumbType = "Thumb_" +_global.TypeName;
_global.ThumbArray = KethumbType.split(", ");

Thanks for your help.

Variable Box Plus Array Value
thx mitya!

I have created a loop with 4 values and I would like to fill 4 variables with colours using the loop values.

i.e. _root.box1[i]="red"
or _root.("box1"+[i])="red"

I just need the correct syntax for this.

Thanks.

Getting An Array Name Out Of A Variable
Hello Community!

I've got a bunch of arrays (12 and growing, i.e. "aMajor") that each need to be compared with one user-generated array (kFarray). Each value from all my arrays need to be compared to each value of kFarray. I have a series of loops set up, and a function to return an OBJECT of the name of the current array. Problem is, I can't use the returned OBJECT (I also tried it with String) to access the value in the array.

The variable [b]vari[b] gets a value like "aMajor[0]", from the getScaleArray(o,m) function. which should be compared to the value of kFarray. Problem is, it sees vari as a string, and never actually accesses the aMajor array.

I tried the eval() function, but it returns the string value or undefined.

Here is my code (the problem is bolded):
for(o = 0; o < 12; o++) {

for(n = 0; (n < 7); n++) {
for(m = 0; m < 7; m++) {

vari = retScaleArray(o,m);

if (vari == kFarray[n]) {
KFConf = 1;
break; }
else
KFConf = 0;}}}Again, vari has a value like aMinor[1], returned from retScaleArray(o,m). So my question is, is there a way to convert the value of a variable to code that actionscript can understand? Again, the eval() fuction is not working for this situation.

I have no _global variables, could that possible be a problem?

Thanks for anyone who can lend a hand!

Variable Or Array ?
Hi,

I have four buttons on the stage (about us, products, services and contact us) and the following code to control them:


Code:
for (var i in this) {
if (this[i]._name.substr(0, 4) == "btn_") {
setBut(this[i]._name);
}
}
function setBut(clip) {
var clip = eval(clip);
clip.onRollOver = function() {
new Color(clip).setRGB(0x000000);
};
clip.onRollOut = function() {
if (!this.pushed) {
new Color(clip).setRGB(0x626934);
} else {
new Color(clip).setRGB(0x000000);
}
};
clip.onRelease = function() {
_root.resetKnop();
this.pushed = true;
new Color(clip).setRGB(0x666666);
};
}
function resetKnop() {
for (var i in this) {
if (this[i]._name.substr(0, 4) == "btn_") {
var clip = eval(this[i]._name);
clip.pushed = false;
new Color(clip).setRGB(0x626934);
}
}
}
What I want now that if when one of the buttons is pressed that the name appear in an dynamic textfied called titles.

Anybody an idea?

Variable To Array
Hello,

I've some variable's called image1, image2, image3 and so on. This is dynamic, so it could be twinty but also fourty. How can I convert them into an array?

Example:

banner.swf?image1=disney.jpg&image2=red.jpg&image3 =blue.jpg&image4=purple.jpg&image5=goofy.jpg

will be converted into:
array = ["disney.jpg", "red.jpg", "blue.jpg", "purple.jpg", "goofy.jpg"];

The number of imagex= is not certain, it could be fourty, it could be twenty. So if it's possible to do this please help me. (If i need to make a variable imagenr=x just tell me)

Variable In Array
ActionScript Code:
function startClip(clipno)
{
    if(clipno == "")
    {
        clipchoice = findClip();
        isValid = validateClip(clipchoice);
        if(isValid == "no")
        {
            while(isValid == "no")
            {
                clipchoice = findClip();
                isValid = validateClip(clipchoice);
            }
        }
        if(isValid == "yes")
        {
            _root.attachMovie(clips[clipchoice], clips[clipchoice], getNextHighestDepth());
            nowplaying = clips[clipchoice];
            currentclip = "loading";
        }
    }
    else
    {
        _root.attachMovie(clips[clipno], clips[clipno], getNextHighestDepth());
    }
}
How can I make it so that variable clipno's and clipchoice's values are what end up in the array name to flash instead of the text clipno and clipchoice?
clipno and clipchoice are numbers by the way.

Array Variable
How to make the array variable as global variable? I am trying to do the one like below. However, I get error message as I add "_global" text in it (var _global.loadPicture:Array = new Array();).

var loadPicture:Array = new Array();
loadPicture.push(new Array("1.jpg","800","600","h"));
loadPicture.push(new Array("2.jpg", "800","600","h"));

Please Help With With Array An Variable
I am having trouble setting the variable for selectedBtn.

I want to have it so I can put selectedBtn = 3; So that when you first open the swf. It will have the last button already selected.

I include my code below. Any help is very much appreciated.


//code
var nameArr:Array = new Array("page 1", "page 2", "page 3", "page 4");
var buttArr:Array = new Array (b1, b2, b3, b4);
for (i=0;i<buttArr.length;i++) {
var tmpBtn = buttArr[i];
tmpBtn.id = i;


tmpBtn.onRollOver = over;
tmpBtn.onRollOut = out;
tmpBtn.onPress = press;
tmpBtn.onRelease = release;
tmpBtn.buttText.buttonText.text = nameArr[i];
}

function over() {
if (_global.selectedBtn != this) {
this.gotoAndPlay(2);
}
}

function out() {
if (_global.selectedBtn != this) {
this.gotoAndPlay(7);
}
}

function press() {
if (_global.selectedBtn != this) {
this.gotoAndStop(17);
this._parent._global.selectedBtn.gotoAndPlay(7);
}
}

function release() {
if (_global.selectedBtn != this)
_global.selectedBtn = this;
this.gotoAndStop(18);


switch (this.id) {
case 0:
getURL(yahoo.com, "_blank");
break ;
case 1:
getURL(yahoo.com, "_blank");
break ;
case 2:
getURL(yahoo.com, "_blank");
break ;
case 3:
getURL(yahoo.com, "_blank");
break ;


}
}

Array/variable Help
I'm currently using this code to create a grid with thumbnails loaded via XML:


ActionScript Code:
var gridSpace:Number = 5;//border space between and around images
for (a=0;a<4;a++) {
     for (b=0;b<4;b++) {
          //Other code comes here
          t._x = gridSpace + ((t._width + gridSpace) * b);
          t._y = gridSpace + ((t._height + gridSpace) * a)
     }
}


The thing is that I want to load 16 instances at a time and display a page count together with the next & previous buttons.

How do I go about storing the data in arrays/variables so that it will load 16 instances at a time?

Array Variable
Hi, in AS2, it was possible to write something like this:

Code:

for(i=0;i<10;i++){

this["tempclip" + i]._alpha = 0;

}


Is there an equivalent in AS3 for this?

Variable In An Array?
I need to find a way of doing the following in a much smaller way...Can I somehow load these variable into an array...Basically I have labeled the variable exactly the same as the frame label...Anyway if anyone knows how to do this it would be greatly appreciated....The following code works perfectly but I will be adding many more variable to it...

if (page =="WhoWeAre") {
_root.gotoAndStop("WhoWeAre")
}
else if (page =="Vision") {
_root.gotoAndStop("Vision")
}
else if (page =="Values") {
_root.gotoAndStop("Values")
}
else if (page =="Mission") {
_root.gotoAndStop("Mission")
}
else if (page =="Services") {
_root.gotoAndStop("Services")
}
else if (page =="News") {
_root.gotoAndStop("News")
}
else if (page =="Employment") {
_root.gotoAndStop("Employment")
}
else if (page =="Portfolio") {
_root.gotoAndStop("Portfolio")
}
else if (page =="CommunitySenior") {
_root.gotoAndStop("CommunitySenior")
}
else if (page =="Financial") {
_root.gotoAndStop("Financial")
}
else if (page =="FoodService") {
_root.gotoAndStop("FoodService")
}
else if (page =="HighTechLabs") {
_root.gotoAndStop("HighTechLabs")
}
else if (page =="Historic") {
_root.gotoAndStop("Historic")
}
else if (page =="JusticeDetention") {
_root.gotoAndStop("JusticeDetention")
}
else if (page =="K12Education") {
_root.gotoAndStop("K12Education")
}
else if (page =="MasterPlanning") {
_root.gotoAndStop("MasterPlanning")
}
else if (page =="Medical") {
_root.gotoAndStop("Medical")
}
else if (page =="PrivateOffices") {
_root.gotoAndStop("PrivateOffices")
}
else if (page =="Religious") {
_root.gotoAndStop("Religious")
}
else if (page =="Transportation") {
_root.gotoAndStop("Transportation")
}

Array & Variable.split
Hey guys,

I tried to split a variable.

myname = "maurice!walter!gaston"
mynewname = myname.split("!");

In the text field "mynewname[0]" I'm hoping to get "Maurice" as output. But it doesn't work.

Mauriz, Maastricht

Variable, Array And SetProperty
Hi guys...

I'm probably missing something stupid. I'm trying to move a movie clip through actionscript. Okay, "moveme" is the instance of the movie clip. "movieposition" is a variable that tells me the current position of the movie clip. "forwardone" is the name of my array. And "numero" is the name of the variable that tells me which element of the array I want.

This is the code I want to make work in a button, but it doesn't work:
setProperty("moveme", _x, movieposition - forwardone[numero]);

These work... so the variables are all being read okay...
setProperty("moveme", _x, movieposition - 100);
(I add "-100" because moving the movie clip to its current position would not allow me to test the variable... it would not move)
setProperty("moveme", _x, forwardone[numero]);

So the variables work, the array works, but it does not move when I put the variable and the array in the expression. This is probably due to incorrect syntax... can anyone help me?

thank you very much
Nicky

Using An Array Value As A Text Variable
Is there any reason why you can't assign the value of an array element to a dynamic text box value?

Eg. A dynamic TB var: myarray[0] as opposed to a conventional variable name?

Push A Variable To An Array...?
I need to know how to load a set of variables from an array (eg: Var1, Var2, Var3) and then push the string values of those variables to an array.

I've tried using a for loop to do somethin like

Code:
_root.MyArray.push(_root.Var[i]);
But that doesn't seem to work.

Could somebody tell me how to do this. BTW, since some people like to spam and just say "search the forum" i'll tell you that i've already done that and didn't find anything helpful.

A Variable On A Different Level (array)
I have a main timeline in _level0 where an array lives in the main timeline. The array is loaded when the playback head hits a certain frame, at this time a new movie is also loaded in _level2.
-------
The timeline _root.level2 will eventually hit a frame that says

loadMovieNum(_level0.myArray[i],2);

But it I am having a hard time loading this sucker.
-------

Shouldnt this acess the variable stored in the current array element? in the initial case i=1, and the array element[1] = "section_1.swf" ( does live in the same directory as the main swf )

Thanks much to all those that reply, Im puzzled!

Josh -

Reading Array Variable
Code:
stop();
for(i=0;i<6;i++){
myHitArea = "ha" + i;
trace(eval(myHitArea));
eval(myHitArea).onRollOver = function() {
locateInArray = i;
var mcLabel = leadership_ary[locateInArray];
var mcName = mcLabel + "_mc";
eval(mcName).gotoAndPlay("rollOver");
}
eval(myHitArea).onRollOut = function() {
var mcLabel = leadership_ary[i];
var mcName = mcLabel + "_mc";
eval(mcName).gotoAndPlay("rollOut");
}
}


why won't the locateInArray variable locate the position in my array? It just says it is undefined. But when I put a 0 in there, it reads it fine!?!?

-Kac

Load Variable/Array
I need a little help loading an array of variable from an external text file into Flash. I'm using the VAR function to bring in a bunch of variables (var elementnames = (element1, element2, element3...etc.)
I know how to bring in a bunch of different variables in as follows:

Text File:
A=text1&B=Text2&C=text3
LoadVariable Action in Flash

But I don't know the correct syntex for a variable array using the VAR action. I even tried to break up the variables by hand:

Text File:
Elementnames[0]=elementA&Elementnames[1]=elementB&Elementnames[2]=elementC&Elementnames[3]=elementD

..but this didn't work either...again this might be because my syntex is wrong. Any help with this would be greatly appreciated. I have my FLA file attached.

Thanks,
Walt

http://funnyclown.com/mysite/deleteme.html

Variable Array From Textfile
Is it possible to return a variable array from a text file?

E.g. could I have a textfile with the following variables: -

&Name=dan&name=john&name=bob

and bring an array back of: -

name(0)=dan
name(1)=john
name(2)=bob

This is using VB principles, is there something similar for flash?

Ta!

Array, Images, Variable? Help
I have the following array of images (they are in the root folder):
_root.picArray = new Array();
_root.picArray[0] = "1twoworlds.jpg";
_root.picArray[1] = "2oneworld.jpg";
_root.picArray[2] = "3stilldo.jpg";
_root.picArray[3] = "4general.jpg";
_root.picArray[4] = "5weapon.jpg";
_root.picArray[5] = "6videovillage.jpg";
_root.picArray[6] = "7epicdesigns.jpg";
_root.picArray[7] = "8officialtrailer.jpg";
_root.picArray[8] = "9leaked.jpg";
_root.picArray[9] = "10fantrailer.jpg";

what I want to do is navigate between them with two buttons (back, and forward), displaying an MC while they load.

I tried setting up a variable :
var imageno;
_root.imageno = 0;

and then attempted to get it to increment or decrement(?) using this code(on the button):

onClipEvent (mouseDown){
this.onPress = function() {
if (_root.imageno=0) {
_root.imageno = 9;
};
_root.imageno = (_root.imageno)-1;
};
_root.jpegToLoad = picArray[(_root.imageno ())];
_root.greenscreen.loadMovie(jpegToLoad);


}

When I test the movie it comes up with this.
Error opening url:
"file:///C|/etc etc/undefined"



What am i doing wrong (quite possibly all of it!)

Help (please)

[F8] Passing Variable To An Array
is there a way i can put one of the array values into "[aText[0]]" via a function call so that it is dynamic rather then hardcoded?

much thanks.


var aText:Array = new Array("mcText1", "mcText2", "mcText3");

var dragDistance:Number = scrolledMCrecipient[aText[0]]._height - scrolledMCrecipient.mcContentMask._height;

[F8] Using Flashvars To Set Array Variable
The code below is a game that sets a variable number of coins up in a stack and let's the player grab them and dump them in buckets. I'd like to control the number of coins using Flashvars using the variable "stacknumber".

When i set "stacknumber" in the code, it works fine. However when I set stacknumber using Flashvars it's buggy.

Please check out the makestack function, it uses the stacknumber variable.


Code:
//
stop();

var nb:Number;
if (!nb){
nb=4;
}

var stacknumber;
if (!stacknumber){
stacknumber=10;
}

var yOffset = 22;
var hit = new Sound();
hit.attachSound("kerching");
var rem = new Sound();
rem.attachSound("click");

if (!labelstring) {
labelstring=porsche,ford,ferrari,chevy;
}

var numOfBuckets = nb;
var labelArray:Array = labelstring.split(",");

var stack:Array = new Array(stacknumber);

for (var i = 0; i < numOfBuckets; i++) {
var myBucket = this.attachMovie("bucketMC", "bucket" + i, i, {_x:350, _y:20 + (130 * i)});
myBucket.btnRemove1._visible = false;
myBucket.btnRemove1.onPress = doRemove1;
myBucket.btnRemoveAll._visible = false;
myBucket.btnRemoveAll.onPress = doRemoveAll;
myBucket.txtCT.text = "";
myBucket.CT = 0;
myBucket.myLabel.text = labelArray[i];
}
function makeMini(mc) {
var CT = mc.CT;
var xPos = 28;
var yPos = 80;
var mHolder = mc.createEmptyMovieClip("mHolder", 1);
for (var i = 0; i < CT; i++) {
var myMini = mHolder.attachMovie("coinMC", "coin" + +i, i);
myMini._xscale = myMini._yscale = 30;
myMini._x = xPos;
myMini._y = yPos - ((yOffset * 36) / 100) * i;
}
}

function makeStack() {
var xPos = 20;
var yPos = (stacknumber - stack.length * yOffset) + 460;
for (var i = stack.length - 1; i >= 0; i--) {
var myCoin = attachMovie("coinMC", "coin" + i, i + 1000, {_x:xPos, _y:yPos});
myCoin.num = i;
myCoin.sX = xPos;
myCoin.sY = yPos;
yPos += yOffset;
myCoin.onPress = function() {
this.startDrag();
this.onMouseMove = function() {
var nyPos = this._y;
for (var j = stack.length - 1; j > this.num; j--) {
var aCoin = this._parent["coin" + j];
aCoin._x = this._x;
nyPos -= yOffset;
aCoin._y = nyPos;
}
};
};
myCoin.onRelease = function() {
stopDrag();
delete this.onMouseMove;
if (eval(this._droptarget).bucket._name == "bucket") {
var num = this.num;
hit.start();
for (var t = 0; t < numOfBuckets; t++) {
var myBucket = this._parent["bucket" + t];
if (this.hitTest(myBucket.bucket)) {
myBucket.CT += (stack.length - num);
myBucket.txtCT.text = myBucket.CT;
myBucket.btnRemove1._visible = true;
myBucket.btnRemoveAll._visible = true;
makeMini(myBucket);
break;
}
}
for (var j = stack.length - 1; j > num; j--) {
var aCoin = this._parent["coin" + j];
aCoin.removeMovieClip();
}
this.removeMovieClip();
stack.splice(num);
} else {
for (var j = stack.length - 1; j >= this.num; j--) {
var aCoin = this._parent["coin" + j];
aCoin._x = aCoin.sX;
aCoin._y = aCoin.sY;
}
}
};
}
}
function doRemove1() {
this._parent.txtCT.text = --this._parent.CT;
stack.push(stack.length + 1);
rem.start();
makeStack();
makeMini(this._parent);
if (this._parent.CT == 0) {
this._parent.txtCT.text = "";
this._visible = false;
this._parent.btnRemoveAll._visible = false;
}
}
function doRemoveAll() {
while (this._parent.CT > 0) {
this._parent.txtCT.text = --this._parent.CT;
stack.push(stack.length + 1);
}
rem.start();
makeStack();
makeMini(this._parent);
this._parent.txtCT.text = "";
this._visible = false;
this._parent.btnRemove1._visible = false;
}
// start, call function to make initial stack
makeStack();
//


Thanks for any assistance!

Array Variable Question
I have an MC called letterH. I have an array with "letterH" as the value for [0]. Is it possible for me to do something like this:

myArray[0]._x += 5;

I'm thinking it should be equivalent to letterH._x += 5; but I get an error.

I have also tried eval(myArray[0] + "._x") += 5; but it doesn't like that either.

any tricks to do this?

Array Or Incremented Variable?
hello,

I've been having trouble figuring out what to do about some code. Here is the line in question


Code:
myColoredRow= new Color(_root.empty_mc["myInstancename"+myVariable]);
myFirstRow.setTint(100, 255, 0, 50);
(function works fine and is not included here)

I would like to apply the function to multiple instances, in which case it would be something like:

"myInstancename"+1 (and) "myInstancename"+2 (and) "myInstancename"+3 and so on.


I originally was using an incremented variable (myVariable++) but because all of this is inside of a nested for loop, the variable will only count as high as the for loop counts. I need it to go much higher. I don't know if it is possible to call all parts of an array at the same time, but that is what I think I need to do.

I appreciate any help, and can post more complete code if this doesn't make sense. Thanks.

Help Identifying Array Variable
I have several buttons on the stage and they are included into one array because most of their button events are identical. I am trying to figure out how to change the alpha of only the button that the mouse rolls over. I think I need to create a variable that will be the button on the stage the mouse is on and then use that in the ROLL_OVER, ROLL_OUT, MOUSE_DOWN, etc.. functions but I am not sure how to go about creating this.

ActionScript Code:
var cardArray:Array = [businessCard, postCard1, postCard2, postCard3];

//adding listeners for variable array
for(var a:uint=0; a<cardArray.length; a++)

{
    cardArray[a].addEventListener(MouseEvent.ROLL_OVER, RollOver);
    cardArray[a].addEventListener(MouseEvent.ROLL_OUT, RollOut);
    cardArray[a].addEventListener(MouseEvent.MOUSE_DOWN, MouseDown);
    cardArray[a].addEventListener(MouseEvent.MOUSE_UP, MouseUp);
    cardArray[a].buttonMode=true;
    cardArray[a].useHandCursor=true;
}

// cardArray functions
function RollOver(myEvent:MouseEvent) {
    cardArray[0].alpha=0.95;
    trace("mouse roll over");
}
Currently the first button in the array changes alpha whenever you roll over any button in the array.

Array Name = Dynamic Variable
i have got the code:


Code:
var id = 342;
id = new Array();
id[0] = user;
id[1] = x;
id[2] = y;
what i need to happen is when I trace the value 342[0];, it needs to return user


Code:
trace(342[0]);
in a normal situtation one would do:


Code:
trace(id[0]);
to get this value, as I am setting the array so later on I can use a loop command to compare for instance this valuex with that value x;

Change Value Of Variable In Array
I'm working with a prebuilt form component that uses several other components on the stage to pass values to a php page. The problem I'm having is I need to pass a couple of values to a prebuilt array that is comprised of variables. How do I set the value of a variable that is already in an array?

2 Problems: Variable As Array Name & ...
Ok, I'm trying to make an array generate from someone typing their name in an input box. The input makes the variable "arrayName" = -input-
then in my code below i create an array with

arrayName = new Array(4) (I want four array positions)

But in the input box, it just gives me this ",,,"


ok, moving on to second problem, lol


the slots in the array are changed with four buttons

on(release) {
_root.GR.arraySlot = 0;
}

etc etc for 4 buttons. ok, so now on _root.GR ( a movie clip) I've put this code.

set (arrayName, 0 );
set (gameNumber,0 );
set (userResult,0 );
set (compResult,0 );
arrayName = new Array(4)
computerArray = new Array(4)

And in a submit button I've put this:


_root.GR.submitContinue.on(release) {
_root.GR.arrayName [_root.GR.arraySlot] = _root.GR.userResult
}

ok, so to check my progress, I've added Dynamic Text to display every variable and then the array. I hit the big button, and whammo, nata.

Help : Lol, theres gotta be something wrong with the way I'm changing the variables and paths from inside other timelines. I even tried making every variable and array global, but I'm guessing I did that wrong too, cuz it didnt't work either. I have to have this project done by tomorrow and I'm stressed out alot about it, lol. I'm brand new to AS and really would love your help! Thanks in advance!

Watching Variable In Array
Hi Everyone,

quick question about the this.watch("variable", function, args)
tag, does anyone know how to get this to watch a variable within an array or object, for example : i have an array

Code:
myArray = new Array('jello', 'pizza', 'pie', 'coke')
then I have a MC with the code:

Code:
_root.watch("myArray[1]", traceMe)
//
function traceMe(a,b,c)
{
trace(c)
trace(_root.myArray[1])
}
So, whenever I change the data in Array[1] I want the MC to trace the result......can this be done?

Also, does anyone know any reason why I shouldn't use the Watch tag?
I haven't seen it used much before, but I really like it, so I was kinda wondering if there was any reason why it is rarely used.....

thanks in Advance

Array Name Referencing With A Variable
Hey all,

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.

The code for creating the second array is below:

Code:
for (i=0; i<names.length; i++) {
linkArray[i] = [names[i], i];
}
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?

Array Name Referencing With A Variable
Hi,
I have several arrays that I am using to populate a listbox, the array to be used is dependent on user selection from a comboBox.
I am trying to figure out how to flexibly change the array used to populate the listbox using a variable, when a different comboBox selection is made.
All possible arrays have the same names as possible values from the combobox, so that if 'list1' was selected from combobox, this would call the array named 'list1.' I need to figure out a way to use the selectedArray variable in the for loop to populate the listbox correctly. (see bolded in code)


ActionScript Code:
var selectedArray = evt.target.getValue(); //selected array from comboBox selection.    trace("current list contents: " + _global.listcontent);    _root.listbox.removeAll();//clears listbox of previous contentfor(var i = 0; i < <b>selectedArray.length</b>; i++){    var item = new Object();    item.label = i + " - " + <b>selectedArray</b>[i];    item.data = i;    _root.listbox.addItem(item.label, item.label);}


What I have there is not working, no array is called, but I'm not sure how to make the variable selectedArray reference a specific array simply by name...
I hope I am explaining what I am trying to do well enough. Any help would be greatly appreciated!

Thanks=]

Variable Array Question
I'm having trouble understanding why my i variable in the script below doesn't carry through to the "mySubMenus[i].alphaTo (100,1);" line.

When I trace, it returns a value of 3, but it's working for myButtons[i]. There must be a way to pass that [i] value someplace else, but I can't figure it out. Any one have any ideas?

BTW, this is a variation of one of the mc_tween samples. Thanks!



var myButtons = [this.servicesBtn, this.portfolioBtn, this.peopleBtn];
var mySubMenus = [this.servicesLevel2, this.portLevel2, this.peopleLevel2];

// Loops on all buttons from the first to the last one
for (var i=0; i<myButtons.length; i++) {


myButtons[i].onRollOver = function() {
this.colorTo(0xFFFFFF,.25,"easeOutSine");
};


myButtons[i].onRollOut = myButtons[i].onReleaseOutside = function() {
this.colorTo(0xCCCCCC,.25,"easeOutSine");
};


myButtons[i].onRelease = function() {
this._parent.activateItem (this);

// *** Function here

this.blueArrow.alphaTo (100, 1);
mySubMenus[i].alphaTo (100,1);
};
}

this.activateItem = function(item) {
// Function that activates a button.

// Checks if there's an activated item already; if so, deactivates it.
if (this.currentItem != false) this.deActivateItem();

// Activates it, finally
this.currentItem = item;
this.currentItem.colorTo(0x4F89AB,.25,"easeOutSine "); // makes it 'disabled'
this.currentItem.enabled = false; // makes it a disabled button, so it won't receive mouse events
};



this.deActivateItem = function() {
// Deactivates the current activated menu item.
this.currentItem.enabled = true; // back to a normal button/movieclip
this.currentItem.colorTo(0xCCCCCC,.25,"easeOutSine "); // back to its original color
this.currentItem.blueArrow.alphaTo (0, 1);
mySubMenus[i].alphaTo (0,1);
this.currentItem = undefined;
};

this.stop();

2 Problems: Variable As Array Name & ...
Ok, I'm trying to make an array generate from someone typing their name in an input box. The input makes the variable "arrayName" = -input-
then in my code below i create an array with

arrayName = new Array(4) (I want four array positions)

But in the input box, it just gives me this ",,,"


ok, moving on to second problem, lol


the slots in the array are changed with four buttons

on(release) {
_root.GR.arraySlot = 0;
}

etc etc for 4 buttons. ok, so now on _root.GR ( a movie clip) I've put this code.

set (arrayName, 0 );
set (gameNumber,0 );
set (userResult,0 );
set (compResult,0 );
arrayName = new Array(4)
computerArray = new Array(4)

And in a submit button I've put this:


_root.GR.submitContinue.on(release) {
_root.GR.arrayName [_root.GR.arraySlot] = _root.GR.userResult
}

ok, so to check my progress, I've added Dynamic Text to display every variable and then the array. I hit the big button, and whammo, nata.

Help : Lol, theres gotta be something wrong with the way I'm changing the variables and paths from inside other timelines. I even tried making every variable and array global, but I'm guessing I did that wrong too, cuz it didnt't work either. I have to have this project done by tomorrow and I'm stressed out alot about it, lol. I'm brand new to AS and really would love your help! Thanks in advance!

Copyright © 2005-08 www.BigResource.com, All rights reserved