Turn Array Values Into Strings
I was wondering how you make sure an Array has quotes around each value.
simply, I'd like:
array_1 = new Array(cat,dog,the green frog)
to turn into
array_1 = new Array("cat","dog","the green frog")
ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 10-22-2008, 03:13 PM
View Complete Forum Thread with Replies
Sponsored Links:
Turn Array Values Into Variable & Value
Hi there - fairly simple question - i want to turn the value of two arrays into a variable and value:
ie:
Code:
name[2] = value[2]
say for example - name[2] is "Address" and value[2] is "23 new street"
how can i write it so that flash creates a new variable called Address, with the value "23 new street" ?
Cheers
View Replies !
View Related
[MX] Weirdness With Values Used By Array Populated Clip Values.
Hi,
I have used invisible buttons on top of some text, as part of a volume control interface.
The text buttons are set out as 0 – 25 – 50- 75 -100 referring to the % that a music tracks volume will change to once a button is pressed – so far so good.
Now to give values to the text buttons in order for them to make the text clip that they are on top of go to & stop & the right frame I have used arrays to give a reference the location of the text clip:
numbs_array = [_root.volHold_mc.vol0, _root.volHold_mc.vol25, _root.volHold_mc.vol50, _root.volHold_mc.vol75, _root.volHold_mc.vol100];
I then reference that in a home made “release” function as “this.monica.gotoAndStop(2);” “monica” being the reference to the address of the clip.
It all works fine except the code seems to make the movie play clips in an order that they have not been designated in the array – Like a button on top of the “25”% value will play the animation for the “75”% clip?
The whole problem is probably much better seen through the movie – the problem section of which i have attached below.
View Replies !
View Related
Database Values To Array Values
Hi all,
I've created a movie which uses a number of arrays to construct the elements of a flash-based gallery.
What I need is a practical method of getting values from a database into an array via an ASP page.
The plan was to load the variables into these arrays using the an asp page and a loadvars object to create a string (basically the array values in quotes separated by commas) which was then to be inserted into the parameters for the creation of the array. Needless to say this hasn't worked- the create array object seems to interpret the whole string as the first value in the array, i can't find a way of populating the array from just a single asp page.
I've given up with this method and really need a few pointers.
Thanks
View Replies !
View Related
Array Strings To MC Ids?
So I've got a 2D array that contains the identifiers of movie clips on my stage:
trace(theArray[0]["id"])//Outputs firstMC
trace(theArray[1]["id"])//Outputs secondMC etc...
How (using a for loop) can I access these values as MCs instead of strings?
Example
for (i=0; i<theArray.length; i++){
theArray[i]["id"]._alpha = 50;
}
??
Thanks,
Jared
View Replies !
View Related
Array Of Utf Strings?
Hi,
I have an array of strings, that is used to fill meny item's names. Here's example:
var sm4_array:Array = ["Brza Vožnja", "Submenu 2", "Submenu 3", "Submenu 4", "Submenu 5", "Submenu 2", "Submenu 3", "Submenu 4", "Submenu 2", "Submenu 3", "Submenu 4"];
As you can see array[0] is on croatian language (has "ž"). But when I put thins in preview this submeny text is like - ''Brza vonja''. Has no "ž" character!
Can anybody help me with this?
View Replies !
View Related
Strings In An Array
hello people,
I am mking a game. there i have 2 make a little data base of string's that i want 2 load auta an array into a text field. sounds easy.
I also want the strings 2 load in a random order.
So if i have 1 question at 1 time, i load a random numer "string" out of the array data base.
any1 knows how to do that in as?
heeeeeeelp!
thanks
View Replies !
View Related
Splitting Strings Into An Array
Hi All,
I'm familiar that in flash, an array can be populated using such as a following:
var myArr = Array("cat","dog","bird");
Is there a way to populate an array if I get passed a string like this... (note the quotes placement):
"cat, dog, bird"
Some of you maybe familiar with VB's 'split' command which automatically turns that comma-delimited string into an array.
I need your help guys if there is a built-in function in flash that can do or mimic this or did I just missed an item in the help file?
Thanks in advance. Butch
View Replies !
View Related
[F8] Deleting Undefined Strings From An Array
i have it set to where it can lists the undefineds as null... but how do i remove them from the array completely so they dont show up at all?
PHP Code:
temp = [];
arr = [];
lv = new LoadVars();
lv.load("text.txt");
lv.onLoad = function(){
str = unescape(this);
str = str.split("
").join("");
temp = str.split(";");
temp.pop();
len = temp.length;
k = [];
for(var i=0;i<len;i++){
var u = temp[i].split("KaiOrbitalServer=");
if (u[1] !== undefined or null) {
k[1] = u[1];
} else {
k[1] = null;
}
arr[i] = k[1];
}
trace(arr);
}
Data in text.txt
Code:
KaiOrbitalServer=220.110.159.220;
KaiOrbitalServer=87.118.96.216;
KaiOrbitalServer=221.240.208.210;
KaiOrbitalServer=221.251.3.70;
KaiOrbitalServer=221.115.88.55;
KaiOrbitalServer=62.75.202.112;
KaiOrbitalServer=88.198.48.232;
KaiOrbitalServer=84.200.226.110;
KaiOrbitalServer=91.121.77.194;
KaiOrbitalServer=64.46.44.12;
KaiOrbitalServer=166.70.145.104;
KaiOrbitalServer=66.135.32.175;
KaiOrbitalServer=65.208.243.13;
KaiOrbitalServer=67.18.15.194;
KaiDeepResolutionServer=41.23.53.83;
KaiDeepResolutionServer=41.35.168.42;
KaiDeepResolutionServer=41.20.232.129;
KaiDeepResolutionServer=23.13.67.106;
KaiVersion=Launch;7.1.7.6;
KaiVersion=Engine;7.1.7.6;
I want to filter out the data from the array... hopefully my question is clearer this time and I'm thankful for anybody that helps.. thanks..
View Replies !
View Related
Array + Number In Strings In Function
Hi again!
This time I want to use ONE function with different inputs, but. Take a look at the two code examples below. testA does NOT work though testZ and testX does work.
Here is what I got from tracing the values from inside testA. All pretty obvious exept the bottom one.
Code:
trace(aCirclePic);//Circle00,Circle01
trace(nCirclePic);//0
trace(aCirclePic[nCirclePic]);//Circle00
trace(sArrayPic);//aCirclePic
trace(sNumberPic);//nCirclePic
trace(sArrayPic[sNumberPic]);//undefined
What variables am I suppose to use to get it to work with just one function. Obviously this is a very simplified example…
Code:
var aCirclePic:Array = new Array("Circle00", "Circle01");
var nCirclePic:Number = 0;
var aBoxPic:Array = new Array("Box00", "Box01");
var nBoxPic:Number = 0;
testA("aCirclePic", "nCirclePic");
//testA("aBoxPic", "nBoxPic");
function testA(sArrayPic:String, sNumberPic:String):Void {
this.attachMovie(sArrayPic[sNumberPic], sArrayPic[sNumberPic], this.getNextHighestDepth(), {_x:10, _y:10});
}
//testZ();
//testX();
function testX():Void {
this.attachMovie(aCirclePic[nCirclePic], aCirclePic[nCirclePic], this.getNextHighestDepth(), {_x:10, _y:10});
}
function testZ():Void {
this.attachMovie(aBoxPic[nBoxPic], aBoxPic[nBoxPic], this.getNextHighestDepth(), {_x:10, _y:10});
}
View Replies !
View Related
Array Access Notation With Strings?
I may be confused, but I thought you could use array access notation with strings. Can someone tell me why this code doesn't work (or suggest new code):
the code is meant to rewrite the block of text in tText at a rate of one character per frame... (when the function is called once per frame) but it doesn't work.
Attach Code
function swapText():Void {
var sWorkingText:String = tText.text;
var sNewText:String = oPhotoText[sPageFocus];
var nIndex:Number = oPhotoText.nIndex;
if(oPhotoText.nIndex < sNewText.length) {
trace("sNewText[nIndex] = " + sNewText[nIndex]);
sWorkingText[nIndex] = sNewText[nIndex];
} else if(sWorkingText.length > sNewText.length) {
sWorkingText = sWorkingText.slice(0, -1); //takes 1 character off the end.
} else {
oPhotoText.bSwapText = false;
}
oPhotoText.nIndex++;
tText.text = sWorkingText;
}
View Replies !
View Related
Setting Array Values To Variables In Another Array
I have some variables created on the main timeline and a mc called options which will be where those variables can be manipulated.
A way I've tried to this is by creating a first array(array1) and populating it will all the variable names found on the main timeline, and another array(array2) containing the values of the variables the user has changed(which are displayed on some dynamic text fields). To make these changes, an "apply" button is pressed which will set the values found in array2 to the variables in array1.
So...
Code:
PHP Code:
//variables on the main or root timelinevar1 = 1; var2 = 2; //... //within options mc timelinearray1 = [var1, var2]; array2 = [var1Display, var2Display]; apply.onRelease = function() { //set values in array2 to variables in array1 and update the main timeline's variables//... }
How would you do this so that var1, var2... are updated properly according to the values found in array2?
And because array2 contains strings(read from dynamic textfields), how do you deal with that since var1 and var2 are numbers?
hope this all makes sense to everyone
View Replies !
View Related
Turn String Into Array
Hi all,
If i have the following:
Code:
sloj = "new Array(new Array(26,311,9062912,100,100,100,0,'spray',33), new Array(28,311,9062912,100,100,100,0,'spray',34));";
how can i change this so the sloj variable isn't a string but an actual multi demensional array? At the moment it is just a string.
Cheers,
macca
View Replies !
View Related
Turn A Func To An Array?
******compeletly forgot : AS2.0 Flash8
Hi ... I’m just starting out on really learning java scripting and flash interaction... got this little test function to work great... but I’m not sure how to turn it in to an array... I've tried and tried and have gotten no were... so i was think may-be some one could show me what a few of the ways to do it so i can see a good working model for me to go off of....
here is the actionscript (don't poke fun i'm still learning...)
Code:
import flash.external.ExternalInterface;
function getTextFromJavaScript(str:String):Void {
PG_1.APP_Email.text = "" + str;
}
ExternalInterface.addCallback("sendTextToFlash", this, getTextFromJavaScript);
function clickSend(eventObj:Object):Void {
var jsArgument:String = PG_1.APP_Email.text;
var result:Object = ExternalInterface.call("getTextFromFlash", jsArgument);
PG_1.APP_Email.text = "" + result;
}
PG_1.send_button.addEventListener("click", clickSend);
mind you I’ve work hard to get this far... just have not been able to move ahead
so the array example that I think I could get a good idea off of would be 4 items... unless some one think more makes a difference... I will be having a app to make in the near time that will have about 200 TextInput, CheckBox, ComboBox, and DataGrides so ideas would be great... they all will be much like this...
PG_1.APP_Email.text <TextInput
PG_1.APP_Yes.Boolean <CheckBox?
PG_1.APP_States.selectedItem <ComboBox?
PG_1.APP_Email.selectedItem <DataGrides?( a row of data ie: Item id, Item Name, Item Date ect)
I'm not sure about the muilt selects... and i'm not even sure about what i got lol... any examples or tips, heads up would be great...
Incase it matters.. here is the javascript... (which also need to be an array i'd asume)
Code:
<script language="JavaScript">
function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
function formSend() {
var text = document.htmlForm.m7feu_input_email_address.value;
getFlashMovie("v2.d").sendTextToFlash(text);
}
function getTextFromFlash(str) {
document.htmlForm.m7feu_input_email_address.value = "" + str;
return str + "";
}
</script>
I'm a designer not a coder ... I just wish my bosses would stop trying to save money by haveing a crapy coder code crap... lol... Please any help would be great thanks....
View Replies !
View Related
[F8] Problem Matching Variables In Array With Strings
I'm getting back into flash after 3yrs hibernation, so I'm sorry if this is a newbie question!
I'm writing a game to help kids learn vocab about occupations with the barebones script I've setup below.
I'm trying to put clothes on the nurse (not what you think!), but for some reason the 'random clothes item' (question) and the 'selected item' even if they are the same 'string' don't match in my 'if statement'. What's wrong please!
This script is on the timeline.
I'm supposed to be demo'ing this to a client on the weekend, so I really appreciate your input! The gfx part is all easy
code:
stop();
var rndClothes = new Array();
rndClothes[0] = "hat";
rndClothes[1] = "shirt";
rndClothes[2] = "shoes";
var partI:Number = 0;
/// FUNCTIONS ////
//////////////////
// add a method to randomly shuffle an array
NewRound = function() {
var thisArrayLength = rndClothes.length;
trace("size of array is " + thisArrayLength);
// copy over our array
var inputArray = new Array();
for (var i=0;i<thisArrayLength;i++) {
inputArray.push(rndClothes[i]);
}
// randomly splice everything back into our array
for (var i=0;i<thisArrayLength;i++) {
rndClothes[i] = inputArray.splice(random(inputArray.length),1);
}
trace("random clothes is " + rndClothes);
trace("where is my " + rndClothes[partI]);
}
EvalItem = function(selectedItem) {
trace("selected item is " + selectedItem);
trace("random item is " + rndClothes[partI]);
if (selectedItem == rndClothes[partI]) {
trace("this is my " + rndClothes[partI]);
} else {
trace("Oh no, these aren't " + rndClothes[partI]);
}
}
NewRound();
EvalItem("hat");
EvalItem("shirt");
EvalItem("shoes");
View Replies !
View Related
Problem Matching Variables In Array With Strings
I'm getting back into flash after 3yrs hibernation, so I'm sorry if this is a newbie question!
I'm writing a game to help kids learn vocab about occupations with the barebones script I've setup below.
I'm trying to put clothes on the nurse (not what you think!), but for some reason the 'random clothes item' (question) and the 'selected item' even if they are the same 'string' don't match in my 'if statement'. What's wrong please!
This script is on the timeline.
I'm supposed to be demo'ing this to a client on the weekend, so I really appreciate your input! The gfx part is all easy
Code:
stop();
var rndClothes = new Array();
rndClothes[0] = "hat";
rndClothes[1] = "shirt";
rndClothes[2] = "shoes";
var partI:Number = 0;
/// FUNCTIONS ////
//////////////////
// add a method to randomly shuffle an array
NewRound = function() {
var thisArrayLength = rndClothes.length;
trace("size of array is " + thisArrayLength);
// copy over our array
var inputArray = new Array();
for (var i=0;i<thisArrayLength;i++) {
inputArray.push(rndClothes[i]);
}
// randomly splice everything back into our array
for (var i=0;i<thisArrayLength;i++) {
rndClothes[i] = inputArray.splice(random(inputArray.length),1);
}
trace("random clothes is " + rndClothes);
trace("where is my " + rndClothes[partI]);
}
EvalItem = function(selectedItem) {
trace("selected item is " + selectedItem);
trace("random item is " + rndClothes[partI]);
if (selectedItem == rndClothes[partI]) {
trace("this is my " + rndClothes[partI]);
} else {
trace("Oh no, these aren't " + rndClothes[partI]);
}
}
NewRound();
EvalItem("hat");
EvalItem("shirt");
EvalItem("shoes");
I thought the problem was with the buttons I created in the scene and tried to turn all the variables to globals, but still no joy.
Hope you can help!
View Replies !
View Related
(Flash 8) Deleting Undefined Strings From An Array
i have it set to where it can lists the undefineds as null... but how do i remove them from the array completely so they dont show up at all?
I want to filter out the data from the array... hopefully my question is clearer this time and I'm thankful for anybody that helps.. thanks..
Data in text.txt
quote:KaiOrbitalServer=220.110.159.220;
KaiOrbitalServer=87.118.96.216;
KaiOrbitalServer=221.240.208.210;
KaiOrbitalServer=221.251.3.70;
KaiOrbitalServer=221.115.88.55;
KaiOrbitalServer=62.75.202.112;
KaiOrbitalServer=88.198.48.232;
KaiOrbitalServer=84.200.226.110;
KaiOrbitalServer=91.121.77.194;
KaiOrbitalServer=64.46.44.12;
KaiOrbitalServer=166.70.145.104;
KaiOrbitalServer=66.135.32.175;
KaiOrbitalServer=65.208.243.13;
KaiOrbitalServer=67.18.15.194;
KaiDeepResolutionServer=41.23.53.83;
KaiDeepResolutionServer=41.35.168.42;
KaiDeepResolutionServer=41.20.232.129;
KaiDeepResolutionServer=23.13.67.106;
KaiVersion=Launch;7.1.7.6;
KaiVersion=Engine;7.1.7.6;
Attach Code
temp = [];
arr = [];
lv = new LoadVars();
lv.load("text.txt");
lv.onLoad = function(){
str = unescape(this);
str = str.split("
").join("");
temp = str.split(";");
temp.pop();
len = temp.length;
k = [];
for(var i=0;i<len;i++){
var u = temp[i].split("KaiOrbitalServer=");
if (u[1] !== undefined or null) {
k[1] = u[1];
} else {
k[1] = null;
}
arr[i] = k[1];
}
trace(arr);
}
Edited: 10/18/2007 at 08:28:55 PM by MrKnives
View Replies !
View Related
Desperately Needp Help To Turn XML Into Array.
I have made the xmlObj but I don't know how to make an array out of it with attributes I can access.
here is the basic xml struct
PHP Code:
<channelData>
<channel chNum="01" chType="LATIN & WORLD" chCat="music" chNew="NEW" >SPA 73</channel>
</channelData>
its pretty basic one value per item and array of attributes I just need to parse it into an array so I can use the sortOn() via the items attribues.
Thanks.
View Replies !
View Related
Turn Part Of Array Into Button...
i was wondering if there's a way to change the last bit of the array (name@place.com) into a button with actionscript? or any other suggestions?
here's a still of what it looks like:
ActionScript Code:
contactInfo = [["Location", "NW" + newline + "Portland, OR"
+ newline + "97209"], ["Telephone",
"555.555.5555"], ["Email", "name@place.com"]];
xPos = 20;
yPos = 20;
for(i = 0; i<contactInfo.length; i++){
attachMovie("conBox","new"+i, i, {_x: xPos, _y: yPos});
xPos += this["new"+i]._width + 50;
this["new"+i].head.text = contactInfo[i] [0];
this["new"+i].content.text = contactInfo[i] [1];
}
View Replies !
View Related
Are Strings Arrays? 4 Digit Date To 4 Element Array?
Getting my feet wet in actionscript and see that it sure resembles javascript, which, if I remember correctly lets you access each individual characters in a string as an element in an array. Can this be done in actionscript?
what I'm trying to do is turn the .getFullYear (2001) into some sort of form where I can access each individual number, be the 2 the zeros or the 1.
View Replies !
View Related
[MX04] Merging Strings Into A Variable To Pull Out An Array Value
Ok, so here's the deal.....
I have two dropdown lists who's values when merged them represent an array name.
For example... I make a selection from a dropdown list 1 who's value is "SomeArray", and from the dropdown list 2 i select an item with value "No1"
So now i want to merge those two and add a number from which place in array to take a number to display it in a text field...
Something like a variable called SomeArrayNo1[0] so afterthat I can put it into a text filed....
I know my English sucks, but please help me....
The code below puts a word "SomeArrayNo1[0]" into teh text field instead of pulling the number from array.
Code:
SomeArrayNo1 = new Array("10", "20", "30", "40");
var Droplist1 = new String ("SomeArray")
var Droplist2 = new String ("No1")
var ArrayPosition = new String ("[0]")
TraceNumberFromArray = Droplist1+Droplist2+ArrayPosition
trace(TraceNumberFromArray);
_root.textfield.text = [TraceNumberFromArray]
View Replies !
View Related
Turn A Array Of Variable Names Into Actual Variables
Hi all,
I have an array filled with the names of variables I created dynamically. I am trying to get these array items to act as the name of the variables while running through a loop but I get the error. "ReferenceError: Error #1069: Property text not found on String and there is no default value".
Flash sees the array items as strings rather than a list of variable names. I tried this a couple of ways but no matter how I hold these variable names they are in string form. So I guess what I really need is a way to convert a string to a variable name.
Here is the code I am using right now.
ActionScript Code:
for (var i=0; i<myMCArray.length; i++){
outXML += "<display_obj>";
outXML += "<value>"+myMCArray[i].text+"</value>";
outXML += "<pointX>"+myMCArray[i].x+"</pointX>";
outXML += "<pointY>"+myMCArray[i]y+"</pointY>";
outXML += "</display_obj>";
}
Thanks for the help my transition to AS3 has been a bumpy one.
View Replies !
View Related
Populate An Array Values From An Array
ok i have this xml file
Code:
<artworkinfo>
<movieinfo>
<artLocation>cover1.jpg</artLocation>
<movie>Live Free or Die Hard</movie>
<plot>John McClane takes on </plot>
</movieinfo>
<movieinfo>
<artLocation>cover2.jpg</artLocation>
<movie>Meet the Robinsons</movie>
<plot>Lewis is a brilliant inventor </plot>
</movieinfo>
</artworkinfo>
the xml will tell where the cover art is the movie title and plot.
i want to populate my movie with this info what is the best approach to create empty movieclips using actionscript or create individuals MC , i try the second one and create 4 movieclips (cause the xml have 4 elements just post 2) and make an array of mc but i can find how to match the xml array to the mc array , this is the code for better explaining,
Code:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
movie = [];
plot = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
movie[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
plot[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
}
placeholder=new Array(loader1,loader2,loader3,loader4);
placeholder_total = placeholder.length;
for (e=0; e<placeholder_total; e++){
placeholder[e].contentPath=this.image[i];
}
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("movieinfo.xml");
the stage have 4 movieclips name loader1,loader2,ect... each mc have 2 dynamic text field one for title and one for the plot.
View Replies !
View Related
Add Up All Values In An Array
Hi there
I need a bit of help I am have loads of trouble adding all the variables
In an array together. I just not sure how to go about doing it.
I have try using a for loop but the out put does match up with the
To the total of all the values.
Code:
for (k=0; k<totalprice.length; k++) {
allprice = parseInt(totalprice[k-1])+parseInt(totalprice[k]);
}
I know there is some thing wrong with this code but I am not sure what
Think I’ve been looking at it for to long.
Hope you can help
Thanks
Mac-10
View Replies !
View Related
Array Values..HELP
I want to create a memory game, but i got stuck here:
on (release) {
bricka=new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 ,19,20,21,22,23,24);
for (i=1; i<13; i++) {
arrayPos=random(bricka.length);
frameNum=myArray[arrayPos];
_root[bricka(i)]=frameNum;
myArray.splice(bricka,1);
}
}
the _root[bricka(i)]=frameNum; is wrong somehow.
it set bricka[1]=2,bricka[2]=3,bricka[3]=4 and so on, instead of
the random numbers that comes out from arrayPos.
what am i doing wrong ?
View Replies !
View Related
Array Values Into A For()
I'm trying to use the following values in a for so I don't have to type them out all the time.
But it ain't working [obvioulsy]!
Also I'd like to put it into a function so that I only have to type out the array values then call the function rather than repeating the for code all the time.
Any clues?
squares = Array("s2","s11","s19","s27","s30");
opacity = Array("15","22","40","17","12");
for (x = 0; x < squares.length; x++) {
_root.Grid[squares[x]].gotoAndStop(1);
setProperty(_root.Grid[squares[x]], _alpha, opacity[x]);
}
View Replies !
View Related
Array Values?
Hi,
I have two arrays which attach random movie clips to the stage. One array contains pictures and the other contains words. So for example the word array contains the words "apple" "dog" "cat" and the picture array contains pictures of an apple, dog and a cat. Ive got the movie clips to display randomly when you click a button, so a picture and a word displays at the same time.
Is it possible to assign a number to each item in the array, so for example the dogword = 1 and the dogpicture = 1
appleword = 2 and the applepicture = 2
catword = 3 and the catpicture = 3
so if the dogword and dogpicture are on the stage at the same time it is possible press a button to say that they match and then to add a point to the score?
Could anyone tell me if this is possible?
this is the code i am using to display my movie clips randomly
on (press) {
_root.blankpicture.attachMovie(_root.pic[random(3)], pic1, 0);
_root.blankword.attachMovie(_root.word[random(3)], word1, 0);
}
and then my arrays are:
pic = new Array ("applepic", "dogpic", "catpic");
word = new Array ("appleword", "dogword", catword");
I am using flash mx
thanks
View Replies !
View Related
Array Values
I am Using Flash MX 2004........
Ok i have an array with 4 elements wich are coordinates that i will be using for another function in my application.... they are as such
test[0]=12;
test[1]= 205;
test[2]=167;
test[3]=355;
now i have a function that will take the the array element values and do what they do with them.... for right now that function looks like this
function makeButton(x1,y1,x2,y2) {
trace(x1 + ", " + y1 + ", " + x2 + ", " + y2);
}
Now i know i can access the aray element values independently but i dont want to do that, what i want to do is concatenate the array and use its resulting string as the parameter values for the function when i call it....the Problem is it is not working and im not sure if can be done when ...I tried using test.join() and i also tried using test.toString() both of these output
12,205,167,355 which is exactly what i need to pass to my Function but even after setting a variable equal to these the output of the function is....
12,205,167,355, undefined, undefined, undefined.............. which means that the entire array.join() value is only being passed as the x1 value......Is there away around this? Help if you can...Thanks
Suzy
View Replies !
View Related
[F8] _x And _y Values From MC's In Array
Hi
I have created an Array with 5 duplicated movieclips. I am now trying to use the _x and _y values of these movie clips, but this value comes out as UNDEFINED. What am I doing wrong?!
Code:
for (var i:Number = 0; i < 5 ; i++) {
duplicateMovieClip(dot_mc, "dot_mc_" + i, this.getNextHighestDepth());
_root.dot_mc._x = Math.floor(Math.random() * Stage.width);
_root.dot_mc._y = Math.floor(Math.random() * Stage.height);
aDotArray.push("dot_mc_" + i);
trace(aDotArray[i]._x);
}
View Replies !
View Related
Array Values
Hi,
I have two arrays which attach random movie clips to the stage. One array contains pictures and the other contains words. So for example the word array contains the words "apple" "dog" "cat" and the picture array contains pictures of an apple, dog and a cat. Ive got the movie clips to display randomly when you click a button, so a picture and a word displays at the same time.
Is it possible to assign a number to each item in the array, so for example the dogword = 1 and the dogpicture = 1
appleword = 2 and the applepicture = 2
catword = 3 and the catpicture = 3
so if the dogword and dogpicture are on the stage at the same time it is possible press a button to say that they match and then to add a point to the score?
Could anyone tell me if this is possible?
this is the code i am using to display my movie clips randomly
on (press) {
_root.blankpicture.attachMovie(_root.pic[random(3)], pic1, 0);
_root.blankword.attachMovie(_root.word[random(3)], word1, 0);
}
and then my arrays are:
pic = new Array ("applepic", "dogpic", "catpic");
word = new Array ("appleword", "dogword", catword");
thank you.
View Replies !
View Related
Using Values From Array
ActionScript Code:
function setButtonDefaults(){
buttonPropertiesArr=["buttonOne``150", "buttonTwo``110", "buttonThree``128];
for(i=0; i<buttonPropertiesArr.length; i++){
var tempArr:Array = buttonPropertiesArr[i].split("``");
_root.tempArr[0].button_tpl_ins.outer._x=0;
_root.tempArr[0].button_tpl_ins.outer_orange._x=0;
_root.tempArr[0].button_tpl_ins.inner._x=0;
trace("arr length: "+buttonPropertiesArr.length+", arr: "+_root.tempArr[0]+", "+_root.tempArr[1]+", orange x: "+_root.tempArr[0].button_tpl_ins.outer_orange._x+", button: "+_root.tempArr[0]+", orange x buttonOne: "+_root.buttonOne.button_tpl_ins.outer_orange._x);
}
}
Ok, inside the function, for example:
tempArr[0] - traces as something valid
_root.buttonOne.button_tpl_ins.outer_orange._x - traces as something valid
_root.buttonOne.button_tpl_ins - traces as something valid
yet as soon as I replace a static value with an array value it becomes undefined:
_root.tempArr[0].button_tpl_ins.outer_orange._x - traces as undefined
_root.tempArr[0].button_tpl_ins - traces as undefined
I don't understand, and I don't know what to search for to find the answer...
View Replies !
View Related
Array Values
Hi everyone! I'm trying to assign values to my array. Here is what I have so far.
Code:
_root.createEmptyMovieClip("Placement", 2);
var shapes:Array = new Array("square", "circle", "triangle");
function selectshape():String {
//get the index for the letter
var index:Number = random(shapes.length);
//assign the letter to a var
var s:String = shapes[index];
//display letter
return s;
}
trace(selectshape());
//calls the function that will place the shapes on the stage
pulltogether(shapes);
function pulltogether(test:Array) {
for (var i = 0; i < test.length; i++) {
Placement.attachMovie(shapes[i], shapes[i], i+10, {_x:random(200), _y:random(200)});
}
}
What I want to do is say if "circle" is selected than I want to assign a value of "yellow circle".
Code:
if ("circle" ){
storedvalue="yellow circle"
]
else if ("square"){
storedvalue="blue square"
}
else if ("triangle") {
storedvalue="green triangle"
}
Hope this makes sense???
View Replies !
View Related
Array Values
I'm trying to load a random .swf into a holder .swf, basically a random ad on the screen. I'm attempting to do this by calling a random item from an array. I'm wondering if my new array is referencing the external .swfs (which are in the same directory) or if that is just some empty data that I created myself in flash. I'm pretty confussed on how all of this works and how to actually reference external assets like movies and images, in an array.
ActionScript Code:
productClip = new Array("catClip.swf", "QCClip.swf", "OPOSClip.swf");
productClip[0] = "catClip.swf";
productClip[1] = "QCClip.swf";
productClip[2] = "OPOSClip.swf";
function loadOne() {
loadMovie(productClip[random(2)+1], "_root.loadMC");
}
I'm not even sure if this is how I should go about doing this or if there's an easier way.
shagPun
View Replies !
View Related
Add Up All Values In An Array
Hi there
I need a bit of help I am have loads of trouble adding all the variables
In an array together. I just not sure how to go about doing it.
I have try using a for loop but the out put does match up with the
To the total of all the values.
Code:
for (k=0; k<totalprice.length; k++) {
allprice = parseInt(totalprice[k-1])+parseInt(totalprice[k]);
}
I know there is some thing wrong with this code but I am not sure what
Think I’ve been looking at it for to long.
Hope you can help
Thanks
Mac-10
View Replies !
View Related
Dispaly All Values Of An Array?
i am storing all the characters entered by users into a textbox,into an array.Now i manuplate some of these(e.g changing case etc.) and again store these into new array ,how can i display all the values of this array(in a new dynamic text box) on click of a button?
View Replies !
View Related
Values Disappearing From Array
Hi,
i'm filling an array from a xml-file somehow like this:
Code:
[i]
_root.bild[i][j][2] = menuItem[i].attributes.name+"/"+subItem[j].attributes.url;
trace("Fotograf "+i+", Bild "+j+" = "+_root.bild[j][2]);
The trace-command at this stage shows the value alright, but some values seem to disappear from the array if I try to use it later.
The code is rather long, I posted the files here:
http://files.ueberland.net/array.zip
The relevant lines are from 134 to 224 - I'm traceing the actual problem there.
You can see in the output-window after the "where are they gone" that some values seem to have vanished.
Any help would be greatly appreciated.
PS: Isn't it a bit... odd to use []-brackets to format the forum-posts since it's the way you handle arrays in actionscript?
View Replies !
View Related
Assign Array Values
FLASH MX
hi, i have a problem about arrays...
i want to assign values to array elements through a .txt file, then load the .txt from the movie..
so it's like, i have created an array in the movie, then i would load the .txt using loadVariables
how should i assign values in text file??
can i assign it by using:
arrayA[0] = 0123;
arrayA[1] = 4567;
please help...
View Replies !
View Related
Array Values Into Variables
OK, so i have an array defined by a query to the database.
myEntry[][]
What i'm looking to do is define variables from the array using part of the array as the variable name.
ie:
myEntry[0][0] = myEntry[0][1]
The value stored in [0][0] should be the variable name and the [1] value needs to be set as the value of that variable.
Obviosly the above example would simply just redefine the array myEntry[0][0] - but how would I do what I'm trying to do?
Any clues?
many thanks!
View Replies !
View Related
Adding Values Box For Array
I'm looking for a way to add a "values" list box where users can enter values into an array.
What I'm looking for is the "values" list box that you get when you click on the magnifying glass in the components properties panel.
Any ideas as to how I can add this would be most appreciated.
Thanks.
View Replies !
View Related
Remove Values In A 3D Array?
Hey,
I'm not sure if 3D array is the right word... but whatever
Ok, I've got this array for my ISO-RPG-Game wich stores the tile-data:
Code:
map = [
[[6], [2], [2], [2], [2] ],
[[2,1,5],[2], [2], [3], [2] ],
[[2], [2], [2], [2], [2,1,4]],
[[2], [2], [5], [2], [2] ],
[[2], [3], [2], [2], [2], ]];
If a cell only consists of: [number], there's nothing special. It will just add a tile...
But if a cell says [number,number,number] there's something special going on. I shall explain the most left one: [2,1,5]
The first number (2) is just the tile, 2 stands for grass so it'll add a grass tile.
The 1 means an item should be placed on that tile.
The 5 means it's item number 5 that should be placed there.
Now when the hero picks up the item I want: [2,1,5], to be replaced with [2]...
I'm now using:
Code:
map[1][0][1] = null;
map[1][0][2] = null;
But when I then trace that part of the array it says: 2,null,null so the data is not realy removed...
So the question... how can I remove it?
View Replies !
View Related
How To You Reset Array Values
Hi everyone, im creating a game and i need to know how to reset Array values. I have a timer set so that my enemys are called every 5 seconds (just for testing purposes) but the problem is that their speeds keep on increasing each time the enemy code is called....
////////////////////
myInterval = setInterval(initCounter, 5000);
function initCounter(){
initEnemy2();
}
/////////////////////////////
function initEnemy2() {
Enemy2Array = new Array();
// start enemy1 at number 0
Enemy2Num = 0;
// create three large enemy2, 100%, at random locations
for (i=0; i<10; i++) {
enemy2 = newEnemy2(100);
enemy2MC._x = 400*Math.random();
enemy2MC._y = - 10;
}
}
function newEnemy2(size) {
// create a new enemy2
enemy2MC = attachMovie("enemy2", "enemy2"+Enemy2Num, 300+Enemy2Num++);
// random speed and direction
//enemy2MC.dx = 5*(Math.random()-.5);
enemy2MC.dy = 5*Math.random() + 1;
enemy2MC.dy = Math.round(enemy2MC.dy);
// move every 25 ms
setInterval(moveEnemy2,25,enemy2MC);
// store in array
Enemy2Array.push(enemy2MC);
return (enemy2MC);
}
function moveEnemy2(enemy2MC) {
// move enemy1
//enemy2MC._x += enemy2MC.dx;
enemy2MC._y+=enemy2MC.dy;
//trace(enemy2MC.dy)
for (var i = Enemy2Array.length-1; i>=0; i--) {
if (Enemy2Array[i]._y>=600) {
Enemy2Array[i].removeMovieClip();
Enemy2Array.splice(i, 1);
}
}
}
View Replies !
View Related
Selecting All Values Of An Array?
Is there a way that I can select all of the values of an array instead of just using one?Like, what I am using it for is that I have answers to a test, and I want all of the answers in the array:"ans" to be shown. Any help would be greatly appreciated!
View Replies !
View Related
Update Array Values?
maybe someone can solve this one too:
i have an array like this:
code:
for(i=0; i<ap.length; i++)
{
storePositions.push(this._parent._parent["mcItem"+i]._x)
}
now i want to update all the values with a value of +160
how can i do that?
View Replies !
View Related
Spliting Array Values
Hi
my problem is that i create an array consisting of external valuse. One of the array dimensions is made of xml element attributes which works dandy for all the later processing. But i am also trying to display each of the attributes on a list box for the user to see what is available.
this does work but atm says for example
wheels,steeringWheel,Brakes,Engine
instead of
Wheels
SteeringWheel
BRakes
Engine
this is the code
for (i = 0; i < myXML.childNodes.length; i++)
{
this[myXML.childNodes[i].nodeName] = new Object();
this[myXML.childNodes[i].nodeName].name = myXML.childNodes[i].nodeName;
this[myXML.childNodes[i].nodeName].isa = myXML.childNodes[i].attributes.isa;
this[myXML.childNodes[i].nodeName].has = myXML.childNodes[i].attributes.has.split(",");
parseArray.push(this[myXML.childNodes[i].nodeName]);
hasDisplay.addItem(myXML.childNodes[i].attributes.has.split(","));
} // end of for
where hasDisplay is the list box I dont really want to change the structure of the array because that is used later on and works fine just wondered if anyone knows how i could split the attribute values when it reaches a comma?
thanks.
View Replies !
View Related
[F8] Unique Array Values From XML
Hi everyone,
I'm trying to make a combo box display attributes from some XML, but unique values from my XPath array.
Here's my XML
PHP Code:
<?xml version="1.0" encoding="UTF-8"?>
<animations>
<animation link="1lat" key="none" label="Healthy">Whole Body (Healthy)</animation>
<animation link="2lat" key="mAct" label="Healthy">Leg Muscle Activation (Healthy)</animation>
<animation link="3lat" key="none" label="Healthy">Ground Reaction Forces (Healthy)</animation>
<animation link="4lat" key="jMoKey" label="Healthy">Joint Moments (Healthy)</animation>
<animation link="1post" key="none" label="Healthy">Whole Body (Healthy)</animation>
<animation link="2post" key="mAct" label="Healthy">Leg Muscle Activation (Healthy)</animation>
<animation link="3post" key="none" label="Healthy">Ground Reaction Forces (Healthy)</animation>
<animation link="pressurepoints" key="none" label="Healthy">Pressure Points (Healthy)</animation>
<animation link="1lat" key="none" label="Rheum">Whole Body (Rheumatoid Arthritis)</animation>
<animation link="2lat" key="mAct" label="Rheum">Leg Muscle Activation (Rheumatoid Arthritis)</animation>
<animation link="3lat" key="none" label="Rheum">Ground Reaction Forces (Rheumatoid Arthritis)</animation>
<animation link="4lat" key="jMoKey" label="Rheum">Joint Moments (Rheumatoid Arthritis)</animation>
<animation link="1post" key="none" label="Rheum">Whole Body (Rheumatoid Arthritis)</animation>
<animation link="2post" key="mAct" label="Rheum">Leg Muscle Activation (Rheumatoid Arthritis)</animation>
<animation link="3post" key="none" label="Rheum">Ground Reaction Forces (Rheumatoid Arthritis)</animation>
<animation link="pressurepoints" key="none" label="Rheum">Pressure Points (Rheumatoid Arthritis)</animation>
<animation link="vidLat" key="none" label="Healthy">Whole Body (Healthy)</animation>
<animation link="vidPost" key="none" label="Healthy">Whole Body (Healthy)</animation>
<animation link="vidLat" key="none" label="Rheum">Whole Body (Rheumatoid Arthritis)</animation>
<animation link="vidPost" key="none" label="Rheum">Whole Body (Rheumatoid Arthritis)</animation>
</animations>
and here's the AS Code that I thought would strip out the repeats:
PHP Code:
while (a < titleArray.length)
{
duplicateArray [a] = titleArray [a].attributes.label;
a ++;
}
for (i = 0; i < duplicateArray.length; i ++)
{
element = duplicateArray [i];
for (n = 0; n < duplicateArray.length; n ++)
{
if (element == duplicateArray [n] && n != i)
{
duplicateArray.splice (n, 1);
}
}
}
for (d = 0; d < duplicateArray.length; d ++)
{
content_mc.page3_mc.main_mc.condition_cb.addItem (duplicateArray [d]);
}
Is there a spelling mistake somewhere or something? I can't see one, and the code works partly, but in my comboBox I get Healthy, Healthy, Rheum. So something somewhere has gone wrong!
View Replies !
View Related
For Loop With Array Values
Ok, the issue is with the enabling of the buttons on my stage. I run a loop to deactivate them all when one is clicked, then I want to turn them back on, EXCEPT the one which was clicked. I thought I could start off with an array of MC names and simply delete them from the array. But I can't get my head around exactly how to read in the array contents as MC names...
Any help would be greatly appreciated.
Mike
PHP Code:
//declare the team variables
var TeamA:Number = 0;
var TeamB:Number = 0;
var btns:Array = Array("btn1", "btn2", "btn3");
disableBtns = function () {
for (var i = 1; i<=3; i++) {
this["btn"+i].enabled = false;
}
};
//////////////////////////////////////
enableBtns = function () {
for (var i = _root.btns; i<=_root.btns.length; i++) {
this[i].enabled = true;
}
};
View Replies !
View Related
Displaying Values Of An Array
Hi all,
Hope you can help me, I think this is a simple one but I cant figure it out.
What I need to do is display the last element, the second last element and the third last element of an array in dynamic text boxes that have variables numbercalled1, numbercalled2 and numbercalled3. The Array is always changing so this is what I have come up with am I doing something simple wrong??? usednumbers is the array that I want to pull the values from.
mary = usednumbers.length
mary2 = usednumbers.length-1
mary3 = usednumbers.length-2
numbercalled1 = usednumbers.toString([mary]);
numbercalled2 = usednumbers.toString([mary2]);
numbercalled3 = usednumbers.toString([mary3]);
Will this display the elements as I have discribed or am I going about this all wrong. I cant use the pop method as I dont want to change that array but just display the elemants in the text boxes.
Also is there any way that I can do this with usednumbers.slice()
Thanks for your help.
View Replies !
View Related
|