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




Xml, Dynamic Text & Arrays..



Hello,

Part newbie/ AS question..

I want to load different xml files into the same dynamic textfield on my root timeline, the code so far is;

flashContent = new XML();
flashContent.ignoreWhite = true;
flashContent.load("foo.xml");
flashContent.onLoad = function(success)
{
if(success)
{
myText.htmlText = flashContent;
}
}

I guess the third line needs to change URL according to which button the user pressed - I was thinking maybe each button sets a variable [1-10] which correspond to a URL but have no idea how to script that or even if this method is the right way to approach the problem?

Any advice welcome!



FlashKit > Flash Help > Flash ActionScript
Posted on: 11-26-2003, 02:01 PM


View Complete Forum Thread with Replies

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

Dynamic Text And Arrays
Ok here is what im doing! I have a program that has TONS of variables that change when you click on a button but there is soooooo many variables so I wanna use arrays instead but it dont seem to work! Heres what I mean....

I have 13 variables(1 for each hour each home is comming in at what time and 1 for the amount of homes already built)! So I tried to make an array as such....

HomeH = new Array(0,0,0,0,0,0,0,0,0,0,0,0,0)
So I named the variables in all my dynamic text boxes

HomeH[1] //for hour 1
HomeH[2] //for hour 2
etc....

But the text doesnt show is there a way of getting a variable DIRECTLY from an array WITHOUT declaring it as another variable.....

HomeH1=Home[1] <<<Dont wanna do that


HELP!!!!!!

Using Dynamic Text And Arrays: Can I Do That?
I'm new to flash and need some help! Any advice would be greatly appreciated!

OK... I'm trying to use a dynamic text box. The variable with that text box, happens to be an array: namely arrayName[0]. Thing is... that doesn't seem to be working... any advice? Or samples that can somebody can point me to?

Again any advice is appreciated!

thanks,
Brian

Arrays In Dynamic Text
I've mainly used flash for animation, which doesn't require much in the way of actionscripting. But have been messing around with games and have not got to grips with variables, arrays and their relationship with levels, _global, _root etc. Anyway, I will have many questions over time but my first........

I want to declare a simply array, have the first entry display in a dynamic text object and a button either side which when clicked change the text to the next array entry.

I know how to do some of this but mainly can't get the dynamic text to display the array entry. So could anyone help me with this or have any tips on how to do any of it would be very much appreciated.

Thanks.

Help With Arrays & Dynamic Text
i am trying to create a store, essentially. one text box for the title of the product, on for the description, one for the rating, and one for the cost. i figured the best way to do this would be to use arrays. that way, you could change the product being displayed by simply citing a different array.

however, i don't entirely understand this area, and the attempt i made was unsuccessful. i think the problem is that the dynamic text boxes aren't showing the locations in the array, for whatever reason. as a variable link, i put in names such as 'myArray[0]' or 'myArray[4]'. they don't seem to like that.

the second issue is that the buttons that change the product have the code attached:

on(release){
myArray = product1;
}

i'm not sure if you can do that, or not. i've attached what i've done, and any help, explanations, and solutions on the matter would be greatly appreciated. thanks!

XML, Arrays And Dynamic Text
utterly stuck with this one..

I have an xml file that looks like this:

<images>
<image
ID="3"
Path=""
Caption="Clear Perspex Containers - Bunny"
/>
<image
ID="4"
Path=""
Caption="Clear Perspex Containers - Easter Bunny!"
/>
<image
ID="5"
Path=""
Caption="Clear Perspex Containers - Large Heart"
/>
<image
ID="6"
Path=""
Caption="Clear Perspex Containers - Piggy"
/>
<image
ID="7"
Path=""
Caption="Clear Perspex Containers - Small Hearts"
/>
<image
ID="8"
Path=""
Caption="Clear Perspex Containers - 6 Pointed Star"
/>
<image
ID="9"
Path=""
Caption="Clear Perspex Containers - Christmas Trees"
/>
</images>

Which is loaded into an array called 'Objects'. What I need to do now, is set the a dynamic text box so that it contains the 'caption' value of one of the entries. Its been a while since I coded actionscript at this level and I'm stuck. What i've tried so far is having a MC called 'caption' which contains a dynamic textbox with the instance name of 'text_box and the variable name 'text'. I then tried this code:

_root.caption.text_box.text = _root.Objects[2];

thinking it would at least show 'something' but no. I've also tried something quite basic:

_root.caption.text_box.text = "hello world";

but the dynamic text refuses to change, which makes me think i've done something fundamentally wrong.

Anyone offer some help please?

Dynamic Text From Arrays
I was wondering if I would be able to output the information that is being stored by two arrays into a dynamic text box. I have the arrays tracking which button the user selects, then based on that i would like to be able to display how the user did (i.e. "you got 7 out of 10 questions right") in the dynamic text box. If anyone has any idea if or even how to do this, I would greatly appreciate the help.

Dynamic Text And Arrays
does anyone know of a way to show the right text string in a dynamic text field within a movie clip that is dynamically created through a for loop from data held within an array? phew, that was hard work!

if that makes no sense, i'll break it down:
 1: within a for loop, a movie clip is attached to the stage depending upon the array data being scrutinised.
 2: the corresponding text string needs to be written to a dynamic text field that is within this newly attached mc.

at the moment, when the prog is run all that occurs is the printout of the final string value in all the slots. when traced out, it becomes evident that this portion of the code is being carried out after the attachment part.

it would be nice to simply place the array element variable into the dynamic var field, but it doesn't seem to allow me to do this. anybody come across this problem before? i'm usually quite an accomplished Flasher, but i've been hijacked by several irritating problems this week... merry christmas from Flash :o(

thanks to anyone who can help,

ralph

Arrays And Dynamic Text Feilds
I'm trying to use a dynamic text feild to display information from an array inside of an array.

i.e:

job1 = new Array("text", "text1", "text2", "text3");
job2 = new Array("text4", "text5", "text6, "text7");
job3 = new Array("text8", "text9", "text10", "text11");
job4 = new Array("text12", "text13", "text14", "text15");
alljobs = new Array(job1, job2, job3, job4);

Now, later on in the movie, I put a dynamic text box up and want to refer to, ahh... let's just say "text4". So, I point the dynamic text box to the variable:

_root.alljobs[1][0]

Doesn't display a thing. Then I use the trace function:

trace (_root.alljobs[1][0]);

That works perfectly. I got the message "text5", so I know that the arrays are set up right. How do I go about pointing the dynamic text box to the same thing?

Any help would be greatly appreciated!

New To Arrays... And Variables... And Dynamic Text LOL
HOwdy it;s me again.

Argh, I have a stupid stupid but very frustrating problem!
I have a dynamic text box called: number.

I have declared number = 0;

I have two buttons. When I press one, I want the number in the text field to go up, when I press another, I want it to go down.

Easy! Got that to work fine!
But-
How do I get it to only cycle thru 0-9... whenever it gets to 9 it of course displays 10, and I have been trying tons of things to get it to STOP

(I tried an array, but then read I can't access an array thru my text box? Is there some step I can do in between??)

I could do the easy way and make the text field a MC instead with 10 frames... a number on each frame... but I want to learn more about variables and such instead. Thanks for any help you can give me!

Arrays Into Dynamic Text Boxes
[I am using Flash MX Pro]

I have created an array, however, when I go to call up this array within a dynamic text box, for instance, putting 'varname[1]', into the variable field. However, this does not return a result. Is there something I'm doing wrong here, or do I have to feed the array into normal variables for the dynamic text box to be able to read it?

Thanks in advance

-- Desinc

Am I Supposed To Be Able To Use Arrays In The VAR Box Of Dynamic Text?
Basically, I want to have a table of names, in an array, so I can sort them.

I set some dynamic text, and in their "Var" box in properties, I try to refer to the array. This does not work, and it only works when I have the "Var" property as regular variable names.

For example:

My array would be called "names". So in the Var box, I'd put "names[0]" in an effort to display the name in that position in the array. This does not work. Nothing gets displayed in the dynamic textboxes.

Using a regular variable "name0", I can get the name to appear. This works. But I do not want to do it this way, mainly because I don't want to have to transcribe each separate name in the list in my array into its own String variable. It would be a real mess, and it would be a lot cleaner just to have one array for everything.

Why are these dynamic textboxes being so stubborn? What can I do about this?

Issues With ARRAYS And Dynamic Text.
Hey there, i'm no stranger to arrays form my old basic coding days and after reading up on flash arrays, they seem to be fairly similar.
Still I find a problem.

I've built my array:-
pname = new Array(9);
pstack = new Array(9);
pname[0] = "Richard";
pname[1] = "Richard";
pname[2] = "Richard";
pname[3] = "Richard";
pname[4] = "Richard";
pname[5] = "Richard";
pname[6] = "Richard";
pname[7] = "Richard";
pname[8] = "Richard";
pname[9] = "Richard";
pstack[0] = 1500;
pstack[1] = 1500;
pstack[2] = 1500;
pstack[3] = 1500;
pstack[4] = 1500;
pstack[5] = 1500;
pstack[6] = 1500;
pstack[7] = 1500;
pstack[8] = 1500;
pstack[9] = 1500;

I did this in a seperate scene at the beginning at first, to try to keep things tidy (the project I have in mind will be bursting with arrays and variables)

I then have a couple of dynamic textboxes. in the 'var' section, I put in pname[0] and so on.
Why does the text box not display anything? I have tried moving the code defining the array into the same scene in which I am using it, yet that doesn't work. It I take the identifier off of the variable in the var box (eg, I just put in pname) then it does display, but it displays the whole list.

What am I doing wrong and how do I go about fixing it?

Dynamic Text Titles With Arrays..?..
Hey, I'm a relative newbie to AS and have hit a snag with a project I'm working on. Basically, I built several fairly large image galleries using Arrays and using back/next buttons to rifle through the pics.

Everything works fine, except that the client needs the "slide description" and (1 of _ pics) displayed now. Do I have to make more arrays for the text? Or Im guessing I can dynamically connect text boxes? I know I can do this with XML, but would prefer not to waste the Arrays I set up.

Below is one of them. Sensory is the theme, thus the name of the array. Ideally, when the [1] slot is selected: the picture 02.Luminare.jpg would be shown, it would say 'Luminare' underneath with (2 of 23). and so on


var sensoryArray:Array = new Array();
sensoryArray[0] = "pics/01.sensory/01.hold_your_dreams_crusht.jpg";
sensoryArray[1] = "pics/01.sensory/02.luminare.jpg";
sensoryArray[2] = "pics/01.sensory/03.adam_sandler.jpg";
sensoryArray[3] = "pics/01.sensory/04.sublimation.jpg";
sensoryArray[4] = "pics/01.sensory/05.swimming_in_sky.jpg";
sensoryArray[5] = "pics/01.sensory/06.projectionist.jpg";
sensoryArray[6] = "pics/01.sensory/07.excrutiating_minutae.jpg";
sensoryArray[7] = "pics/01.sensory/08.chair.jpg";
sensoryArray[8] = "pics/01.sensory/09.hangers_in_closet.jpg";
sensoryArray[9] = "pics/01.sensory/10.acid.jpg";
sensoryArray[10] = "pics/01.sensory/11.awesome_cloud.jpg";
sensoryArray[11] = "pics/01.sensory/12.light002.jpg";
sensoryArray[12] = "pics/01.sensory/13.light04.jpg";
sensoryArray[13] = "pics/01.sensory/14.bird_w_sun.jpg";
sensoryArray[14] = "pics/01.sensory/15.conflagrant_happenstance.jpg";
sensoryArray[15] = "pics/01.sensory/16.metal_oxygen.jpg";
sensoryArray[16] = "pics/01.sensory/17.sky_tastes_candy.jpg";
sensoryArray[17] = "pics/01.sensory/18.stadium_full_of_screaming_fans.jpg";
sensoryArray[18] = "pics/01.sensory/19.the_chaotic_city_streets.jpg";
sensoryArray[19] = "pics/01.sensory/20.tree.jpg";
sensoryArray[20] = "pics/01.sensory/21.typical_sunwashd_self_conf.jpg";
sensoryArray[21] = "pics/01.sensory/22.untitled_03.jpg";
sensoryArray[22] = "pics/01.sensory/23.untitled_04.jpg";


var arrayNum:Number = 0;
gallery_mc.loadMovie(sensoryArray[arrayNum]);
//trace(memoryArray.length - 1);


next_btn.onRelease = function(){
nextImage();
}

back_btn.onRelease = function(){
backImage();
}

function nextImage(){
if(arrayNum != sensoryArray.length - 1){
arrayNum++;
//arrayNum = arrayNum + 1;
//trace("arrayNum = " + arrayNum);
gallery_mc.loadMovie(sensoryArray[arrayNum]);
}else {
arrayNum = 0;
gallery_mc.loadMovie(sensoryArray[arrayNum]);
}
}

function backImage(){
if(arrayNum != 0){
arrayNum--;
//trace("arrayNum = " + arrayNum);
gallery_mc.loadMovie(sensoryArray[arrayNum]);
}else {
arrayNum = sensoryArray.length - 1;
gallery_mc.loadMovie(sensoryArray[arrayNum]);
}


}

Arrays Into Dynamic Text Boxes
[I am using Flash MX Pro]

I have created an array, however, when I go to call up this array within a dynamic text box, for instance, putting 'varname[1]', into the variable field. However, this does not return a result. Is there something I'm doing wrong here, or do I have to feed the array into normal variables for the dynamic text box to be able to read it?

Thanks in advance

-- Desinc

Q&A Game - Dynamic Text And Arrays?
Question | Answer
------------------------------

dtext1 dtext2


dtext3 dtext4


I would like one of the dynamic text boxes (picked at random) to display the Answer and the other 3 to be filled in with (Answer+2, Answer-2, Answer*5).

My problem seems to be in picking the random box and then assigning Answer to it. Any help would be grateful. Thank you.



This is my test actionscript so far..

questionArray = ["What is 5 multiplied by 5?"];
answerArray = ["25"];

Question = (questionArray [0]);
Answer = (answerArray [0]);


//This array containing to the four dynamic text boxes
correctAnswerBox = [dtext1,dtext2,dtext3,dtext4];

//This is what I would like to do -----This returns: _level0.dtext2

(correctAnswerBox[random(3)]) = Answer

Arrays Into Dynamic Text Boxes
[I am using Flash MX Pro]

I have created an array, however, when I go to call up this array within a dynamic text box, for instance, putting 'varname[1]', into the variable field. However, this does not return a result. Is there something I'm doing wrong here, or do I have to feed the array into normal variables for the dynamic text box to be able to read it?

Thanks in advance

-- Desinc

HELP Dynamic Text, Loops And Arrays Problem.
Hey all,

I've been coding in Flash for a while now and this really bugs me. I can do this to a loop to get data out of a psuedo array into a real array:


c1 = "one";
c2 = "two";
c3 = "three";

for(i=0;i<4;i++){
y[i]= eval("c" + i);
}


My problem now is how to update four hundred dynamic text variables. I'd rather not have to type out four hundred variables, especially since I've taken the trouble to name these variables with a numeric suffix, like this...


text_1, text_2 up to text_400


Then I find out that I could not reference those variables using the eval method... I want to use a for loop to load up my data into those variables, like this:


for(i=0;i < 401;i++){
"text_" + i = myarray[i];
}


Documentation provides no clue. Anybody run into this same problem?

A huge thank you to the person who can help me NOT type text_x four hundred times... (collapses into a sobbing wreck).

Populating Dynamic Text Fields With Arrays
I'm trying to populate a dynamic text field with an array. Each element would be on a seperate line. As in:

text field:
item1
item2
item3

If anyone has any commented movies or tutorials on creating drop-down menus using arrays that would be great too.

Please Help Vertical Overlaps Using Dynamic Text From Arrays
Hi flashers!

Problem A:
I am having a little problem I hope you flashers can help me solve.
I am loading information from an array into a containermovieclip that contains a textfield.

My problem is that the container movieclip doesnt resize according to the text that is set to autosize=true, which consequently means that everything overlap.

Problem B:
The reason why I even bothered to mess around with arrays is because I want an effect like this... Imagine menu links:

[A] [b] [C] [D] [E]

You click [D]

Then I want everything to reorder so [D] is replacing [A]
It would look like this

[D] [E] [A] [b] [C]

Like circlistic, and I figured arrays would be the best idea if I wanted to change orders around.

Anyways guys... Please help.

Look in the attachment for the code.

Please.
Kim.

Arrays, Sound, And Dynamic Text - PLEAE HELP
Hi Everybody,

I'm really just a beginner, so I hope my questions are not too remedial for you experts out there. I've built an array that holds a playlist of mp3's. The first one loads automatically, and my function is at least working to get through the playlist once. The problem comes when I tell it to go back to [0] (I want the playlist to be on a continuous loop)... the ouput box pops up with a URL undefined message, but it still plays the first song again - it just doesn't continue to the next song in the array. Any ideas?

Also, I'm using onID3 to load track data into dynamic text fields, and it works fine when I test the movie, and it works fine when I preview the published movie, BUT it doesn't load the dynamic text when I actually publish the swf and html. This is probably something really simple that I can't figure out on so little sleep.

Anyway, thank you all for your help!

[F8] Walrus Advice, Dynamic Text, Else:if, And Arrays?
I am working on a Flash widget involving an advice dispensing walrus, "Ask the Walrus." (Working with Flash CS3, but coding in AS2) I'm currently trying to figure out how to trigger the same response to any item from a group of

The idea is that the user can type in any word, and the walrus will give a reply — a few copywriters here are willing to spend a hours typing in any/every possibility of word.

Anyway, I have this set up using else / if statements (and another version set up using switch statements):

(Sample code

var askWalrus:String = input_txt.text;
//trace("I think "+askWalrus+ " are great")
dynamic_txt.text = (askWalrus+ "? This walrus has no opinion regarding " + askWalrus)

else if ( askWalrus == "ping pong" ) {
dynamic_txt.text = ("Is a fine and noble game.");
}

else if ( askWalrus == "brooklyn" ) {
dynamic_txt.text = ("Brooklyn now has a baby walrus! He is very handsome.");
}

else if (input_txt.text.indexOf("ugly") != -1) {
dynamic_txt.text = "I don't think you should call anything ugly! I might find it beautiful.";
}

Next, I'm trying to figure out how to set up a group to trigger the same response to any item from a group — for instance, if a user types in any MLB team, the walrus knows to give a baseball response.

var myBaseball:Array = new Array
("Orioles", "Red Sox", "White Sox", "Indians","Tigers", "Royals", "Angels", "Twins", "Yankees", "Oakland A", "Mariners", "Devil Rays", "Rangers", "Blue Jays")

dynamic_txt.text = "Hmm., I don't really follow baseball. I prefer ping pong.";

I'm sure the solution involves arrays and indexOf — but I'm not sure how to pull it together.

Any advice would be appreciated. Thanks!

[fmx] Populating Dynamic Text Fields With Arrays
I'm trying to populate a dynamic text field with an array. Each element would be on a seperate line. As in:

text field:
item1
item2
item3

If anyone has any commented movies or tutorials on creating drop-down menus using arrays that would be great too.

[fmx] Populating Dynamic Text Fields With Arrays
I'm trying to populate a dynamic text field with an array. Each element would be on a seperate line. As in:

text field:
item1
item2
item3

If anyone has any commented movies or tutorials on creating drop-down menus using arrays that would be great too.

For Dynamic Text, Are Arrays Supposed To Be Usable In The Var Box Of Properties?
I can't get it to work, unless I'm simply constructing my arrays wrong.
What is the case here?

Basically, none of the text is appearing in my Dynamic Textbox. I've embedded the necessary glyphs.

I also have the text nested in stuff, which I've taken care of already in the Var box. Also, the object that the text is nested in is rotating. I read in a few topics that rotating dynamic text makes it disappear on people. Is this true?

Arrays In A Text File To Arrays In Flash
What i am wanting to do is get an array list from an external file and put it into flash arrays, the code i tryed to use was this:


PHP Code:



            for (i=1; i<33; i++) {
                
                if(id=="undefined" || id=="NaN"){
                    
                } else {
            
                id[i] = id(i)

                               }

                         } 




But that dosent work obviously.

I know ive got the
PHP Code:



id[i] 




bit right, but i dont know how to do the bit from the text file.

in the file it goes like this:


PHP Code:



id1=432&id2=324 ect 




So basically what i am trying to ask is how to in a look do variables using the i (id plus the i at the end). Anyone got any ideas?

Dynamic Arrays
I need an interactive array, for navigation history, like browsers. Any ideas?

Dynamic Arrays
Hey guys,

I´ve got the following Problem:

There are some dynamically generated arrays at level0:

_level0.array_print_window0
_level0.array_print_window1
...

The values of an array should be filled from an mc at level1 :

_root["array_"+_level0.active+"["+_level0.activeRow+"]"]=variable;

But what happens is that not the array is filled but a new variable is generated at level0:

_level0.array_print_window0[0] = "something"


Hope that someone understands my bad english...

Dynamic Arrays
Is it possible to create an array based on the contents of an external file? For example, I want to create an array in Flash from four .jpegs in a folder called pics.

Arrays And Dynamic Tfs
Hi all,

I have a button, an input textfield (variable = paraNum) & dynamic tf on the stage, and an array of 5 text files.

I am attempting to get the value of the input text box to 'populate' the dynamic tf.

myPara = new Array();
myPara[0] = "para1.txt";
myPara[1] = "para2.txt";
myPara[2] = "para3.txt";
myPara[3] = "para4.txt";
myPara[4] = "para5.txt";

this.myPara1_mc.onRelease = function() {
loadVariablesNum(myPara[paraNum-1], 0);
};

The output in the dtf is myPara[0], regardless of whatever number is placed in the input textfield.

If I test it with an actual item from the array, eg loadVariablesNum(myPara[4], 0);, the appropriate text will appear in the dtf.

Can someone please help / explain where I am going wrong.

Cheers,

Megs

Dynamic Arrays
I create a given number of arrays named by the contents of another array a=["a1","a2","a3",...] in a loop.


Code:
for(var i:Number = 0; i < a.length; i++){
set("a"+a[0], "some_content"); //Creating arrays named aa1,aa2,aa3,...
}
Now I want to access the first value in the array named aa2 using the array a=["a1","a2","a3",...] and i imagine I have to to something like this


Code:
value = "a"+a[1][0]
I see why this doesn't work but is it all possible in any other way?

Thanks

Dynamic Arrays
I am looking through a for loop and I need to add a string to an array each time... I tried just _global.buttonArray = "test" + i; but each object ends up undefined at the end... here is an overview of my code


Code:
for (var i = 0; i < 5; i++)
{
_global.buttonArray[i] = "test" + i;
trace(_global.buttonArray[i]);
}

Dynamic Arrays From Xml
if I create an array in from a xml file and then try to trace the array

trace(gallery_array);

the out put is,
[object Object],[object Object],[object Object]

why does it not show the values that have been added to the array?

Also I've created some movie clips dynamically but can seem to control their x position because i can’t seem to access their names. I've even given a name (below)

var thisMC:MovieClip = new MovieClip();
thisMC.name = "picture"+i;

if I trace(this);

all I get is,
[object MainTimeline]

I assume I’m missing something fundamental!

The code I have modified is from Galleries.fla that can be found in "flash ActionScript 3.0_samples.zip"
http://www.adobe.com/support/documen...flash/samples/

Thanks for your help
Katy

XML And Dynamic Arrays
Hi,
I created a XML-File and now I want to get the content out of it. The "Name", like Ex_Number, is supposed to be the array name and the rest between the tags is what I want in the array:

Here the XML:

<?xml version="1.0" encoding="ISO-8859-1"?>
<vars>
<Ex_Number Name="Ex_Number">1,2,3,4,5,6,7,8</Ex_Number>
<Ex_Name Name="Ex_Name">First,Second</Ex_Name>
</vars>

I got that far:

Vars = new XML();
Vars.onLoad = newVars;
Vars.ignoreWhite = true;
Vars.load("vars.xml");

function newVars() {
Var_Name=Vars.childNodes[0].childNodes[0].attributes.Name;
trace(Var_Name);

Content=Vars.childNodes[0].childNodes[0].firstChild;
trace(Content);

Ex_Number=Content.split(",");
trace(Ex_Number);

}

But as you can see, the array is not dynamic and it does not even work.

Please help.

Dynamic Arrays In FMS
Ok, I have a problem, a not so big problem, but a problem. :/

I have this array that is dynamic for FMS.
ActionScript Code:
[Client.name + "Idea"] = new Array(idea1,idea2,idea3);




Except, for some reason, it won't work unless i put a this infront of it so it becomes this:

ActionScript Code:
this[Client.name + "Idea"] = new Array(idea1,idea2,idea3);




It works fine for everything, except I have a separate function that needs to update the first string, eg:

ActionScript Code:
[username + "Idea"][0] = newIdea;




but as you can imagine, it gives me errors if I don't put the this infront of it:

ActionScript Code:
this[username + "Idea"][0] = newIdea;




But, then it doesn't update. Why? I'm not so sure, but probably because the array level is different (one is in the root, and one is in function), and I have tried using _parent, _global, and _root to access it, but anything with _ in it gives me not defined errors.

Does anyone have an idea what I could do.

Dynamic Photo Arrays...
OK, we all have seen the javaScript image array that shows web viewers a different image each time they visit an HTML page. I.E. - when I visit "example url" I see image 01. If I were to hit the refresh button I would see image 03. If I were to hit the refresh button again I would see image 02. So on and so on and so on.

My question is: Is there a way for me to accomplish the same technique in flash?

EXAMPLE: I have a portfolio site where the user will see a featured piece on each portfolio section. I would like Flash to choose from an array of images(or swf files) to populate the featured piece section. I envision some sort of frame actionscript that would randomly choose from the designated list. I also would like the image to be linkable to a larger version of the piece. Is this doable?

If the above example is doable, how do I execute it? I do not really need a line by line explanation of how to accomplish this, just a general idea. I.E. - Do I use functions? What about if then statements? Do I utilize loadMovie commands. Etc, etc, etc. If the technique is simple then a line by line example would be appreciated.

Thanks in advance. Also, if this explanation is confusing, please inform me so I can try and simplify my reasoning.

Take care!

Dynamic Control Of Arrays
I'm trying to set a number of arrays at once, and have come across a problem. The code below is supposed to set the arrays, and then set all their values to the string "bottom". It doesn't though. Any ideas?

for (this.i; this.i <= this.noofverbs; this.i++) {
this["nounposition"+this.i] = new Array();
for (this.j= 1; this.j <= this["noofnouns"+this.i]; this.j++) {
this["nounposition"+this.i][this.j] = "bottom";
}
}

Dynamic Bricks / 2d Arrays...
I'll show you guys the code I used. It's not from that site, and it's quite different then the code above. But it is exactly what I set out to do.

Code:
[HTML]function drawWall( aWall, oTarget, nOffsetX, nOffsetY ){
var nOffsetX = ( typeof nOffsetX != "number" ) ? 0 : nOffsetX;
var nOffsetY = ( typeof nOffsetY != "number" ) ? 0 : nOffsetY;
var oTarget = ( typeof oTarget != "movieclip" ) ? this : oTarget;
for ( var i = 0; i < aWall.length; ++i ){
aWall[ i ] = aWall[ i ].split( "" );
for ( var j = 0; j < aWall[ i ].length; ++j ){
var nWidth = nBrickWidth;
if ( aWall[ i ][ j ] != " " ){
var nX = nOffsetX + ( nBrickWidth / 2 ) * j;
var nY = nOffsetY + nBrickHeight * i;

if ( aWall[ i ][ j ] == "[" || aWall[ i ][ j ] == "]" )
var nFillColor = 0xCC3333;
else if ( aWall[ i ][ j ] == "(" || aWall[ i ][ j ] == ")" )
var nFillColor = 0xffaa77;
else if ( aWall[ i ][ j ] == "{" || aWall[ i ][ j ] == "}" )
var nFillColor = 0xeeeeee;

if ( aWall[ i ][ j + 1 ] == "]" || aWall[ i ][ j + 1 ] == ")" || aWall[ i ][ j + 1 ] == "}" )
++j;
else
nWidth = nBrickWidth / 2;

with( oTarget ){
lineStyle(1, 0xdddddd, 100);
beginFill( nFillColor, 100 );
moveTo( nX, nY );
lineTo( nWidth + nX, nY );
lineTo( nWidth + nX, nBrickHeight + nY );
lineTo( nX, nBrickHeight + nY );
lineTo( nX, nY );
endFill();
}
}
}
}
}

var nBrickHeight = 8;
var nBrickWidth = nBrickHeight * 1.4;
var aBuilding1 = [
"[][][][][][][][][][][][][][][]",
"][][][][][][][][][][][][][][][",
"[][] () () [][]",
"][][ () () ][][",
"[][] () () [][]",
"][][ () () ][][",
"[][][][][][][][][][][][][][][]",
"][][][][][][][][][][][][][][][",
"[][][ ][][] [][]",
"][][] [][][ ][][",
"[][][ ][][] [][]",
"][][] [][][ ][][",
"[][][ ][][][][][][][]",
"}{}{} {}{}{}{}{}{}{}{"
];
var aBuilding2 = [
"[][][][][][][][][][][][][][][]",
"][][][][][][][][][][][][][][][",
"[][] {}{} [][]",
"][][ }{}{ ][][",
"[][] {}{} [][]",
"][][][][][][][][][][][][][][][",
"[][][][][][][][][][][][][][][]",
"][][][][][][][][][][][][][][][",
"[][] ][][ [][][] ]",
"][][ [][] ][][][ [",
"[][] ][][ [][][] ]",
"][][ [][] ][][][ [",
"[][] ][][ [][][] ]"
];

drawWall( aBuilding1 );
drawWall( aBuilding2, _root, 240, ( 4* nBrickHeight ) );[/HTML]

Dynamic Content In Arrays
I'm just starting my first big flash project for years and am basically having to relearn AS, it's been so long I'm pretty useless.

Anyway I'm trying to dynamically load .jpg's into an Array, in turn loading the Array into a target movie. It works fine with [0] 1 object in the Array but as soon as I try to load a second object [1] it gives me an error.

AS and Error attached

Any help is greatly appreciated
---------------------------------------

var thumb1:Array = new Array ("gold1thumb.jpg", "gold2thumb.jpg");
loadMovie(thumb1, "thumb1_mc");

var thumb2:Array = new Array ("gold2thumb.jpg");
loadMovie(thumb2, "thumb2_mc");


Error opening URL "file:///harddisk/work/websiteFlash/catalogue/thumbnails/gold/gold1thumb.jpg,gold2thumb.jpg"

****my file names are good it just doesn't like adding more than 1 item????

Dynamic Arrays And Evaluations
Alrighty I rarely post on this board but this problem has been driving me nuts and im at a loss after trying several different methods. Im basicly assigning dynamic paths and populating arrays based on user settings from an admin panel (yet to be built). Problem is though....

this works:

xmlDat[0].childNodes[k].childNodes[p].childNodes[L].attributes.CQ = ("real data")

However if I set up my .CQ extension on my _root timeline which I call MTL (to avoid root collisions loading several movies) I get undefined.


tmpData=["xmlDat[0].childNodes[k].childNodes[p].childNodes[L].attributes."+MTL.Column[Z]];

MTL.Column[Z] trace shows the right extension. ("CQ")

The rest is a string..... tracing it I get the right path. however if I eval it or do a bracket trace i get undefined data. Manually typing it.... it shows up. GR!

Thanks guys

Re: Arrays And Such In Dynamic Paths...
hi guys,

Just posted in the wrong thread, here is the post:

http://www.actionscript.org/forums/s....php3?t=129250

-------------------------------------------------------------------------------------------

hi,

After resolving the issues previously, i've just hit another similar issue it seems I can't get my head around...

If you take a look at the horrific code below, the trace keeps coming back with "loadPath = content/work/cs_tgt7.swf" on every button, where i'm trying to get it so onRelease loads 'cs_tgt0.swf', 'cs_tgt1.swf'.



Code:
public var cs_tgt:String;
private var scope:MovieClip;


for(var i=0; i<8; i++)
{
this.scope = _root.mc1.mc2.whatever;
var cs_tgt = "cs_tgt" + i;
var loadPath:String;
loadPath = "content/work/" + cs_tgt + ".swf";


scope[cs_tgt].bgBtn.onRollOver = function(){ this._parent.gotoAndStop(2); };
scope[cs_tgt].bgBtn.onRollOut = scope[cs_tgt].bgBtn.onDragOut = function(){this._parent.gotoAndStop(1); };
scope[cs_tgt].bgBtn.onRelease = scope[cs_tgt].bgBtn.onReleaseOutside = function(){

var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(listener);
mcLoader.loadClip(loadPath, container);
}
};

----------------------------------------------------------------------------

Thanks in advanced,

Mike

Dynamic Associative Arrays
Hello!

I want to create an more-dimensional associative array so that i can get the values by

var array:object;
arrray.level_1.level_2.level_3 etc

so, when i have the array, i want to read the values with some dynamic options in an loop, for example.
so, in theorie i want to do it like

var y:Array = new Array;
y.push("level_2")
trace(array.level_1.y[0].level3);

so, if i use it, it doesn`t work. also if i try to use some (...) or [...].

please, can anyone tell me how i can use i so that it's value is used when i ask my array?

thanks!

Fieldnames, Dynamic Arrays, Oh My
All right.

I've got data coming from a FlashCom server, coming in as a hash array.

I'm breaking the data like so:

ActionScript Code:
myResult.onResult = function(data) {    dataArray = new Array();    for (var key in data) {        for (var key1 in data[key]) {            var keyVar = data[key][key1];            var monthVar = key1;            dataArray.push([key, monthVar, keyVar]);        }    }};


I'd like to amend that second for statement to have fieldnames like so:


ActionScript Code:
myResult.onResult = function(data) {    dataArray = new Array();    for (var key in data) {        for (var key1 in data[key]) {            var keyVar = data[key][key1];            var monthVar = key1;            dataArray.push({engine:key, date:monthVar, value:keyVar});        }    }};


Of course it doesn't work. But how could I get it so that it does? I can do something like this:


ActionScript Code:
var my_array:Array = new Array();my_array.push({password: "Bob", age:29});my_array.push({password: "abcd", age:3});my_array.push({password: "barb", age:35});my_array.push({password: "catchy", age:4});


I just need to know how to do this dynamically. Any help would be more than wonderful. (Two for two IPaq...?)

Dynamic MC's, Arrays, And ForLoops
i was having issues with this file but i got it working.

it just pulls in pages MC's from the library using an array. nothing real spectacular for you guru's out there but very useful for the novices... like myself.

*please feel free to make this better... i'd like to see it done differently*

PREVIEW
http://monkeyheadgraphics.com/theLab/flash/forLoop/

SOURCE
http://monkeyheadgraphics.com/theLab...op/forLoop.zip


enjoy,
Andre

Fieldnames, Dynamic Arrays, Oh My
All right.

I've got data coming from a FlashCom server, coming in as a hash array.

I'm breaking the data like so:

ActionScript Code:
myResult.onResult = function(data) {    dataArray = new Array();    for (var key in data) {        for (var key1 in data[key]) {            var keyVar = data[key][key1];            var monthVar = key1;            dataArray.push([key, monthVar, keyVar]);        }    }};


I'd like to amend that second for statement to have fieldnames like so:


ActionScript Code:
myResult.onResult = function(data) {    dataArray = new Array();    for (var key in data) {        for (var key1 in data[key]) {            var keyVar = data[key][key1];            var monthVar = key1;            dataArray.push({engine:key, date:monthVar, value:keyVar});        }    }};


Of course it doesn't work. But how could I get it so that it does? I can do something like this:


ActionScript Code:
var my_array:Array = new Array();my_array.push({password: "Bob", age:29});my_array.push({password: "abcd", age:3});my_array.push({password: "barb", age:35});my_array.push({password: "catchy", age:4});


I just need to know how to do this dynamically. Any help would be more than wonderful. (Two for two IPaq...?)

Dynamic Element Name In Arrays
Is this even possible? Here's what I'm trying to do:


Code:
var myArray:Array = new Array();

for (var i=0; i < myRecordSet.length; i++) {
myArray[i] = {("a"+i):myRecordSet.getItemAt(i).someVar1, ("b"+i):myRecordSet.getItemAt(i).someVar2};
}
so instead of static array element names, i have dynamic ones like so:

myArray[0] = {a0, b0}
myArray[1] = {a1, b1}
....
myArray[n] = {an, bn}

of course, when i try the compiling the above code, flash spits out an error. can anyone please help?

Dynamic Associate Arrays?
ok, so I know you can build objects with dynamic names etc. by using the array operators [] but how do you build an associative array that has both a dynamic NAME AND VALUE??

It would make sense that it would look SOMETHING like

var myVar="Name";
var myDataVar = "123456";
myArray = new Array({[myVar]:myDataVar});

but, i get an error...

Any ideas?

Trouble With Arrays And Dynamic Textfields
In my first frame I have this code:


myarray = new Array();
myarray[0] = "_";
myarray[1] = "_";
myarray[2] = "_";
myarray[3] = "_";
myarray[4] = "_";
myarray[5] = "_";


nummer = myarray[0]
+ myarray[1]
+ myarray[2]
+ myarray[3]
+ myarray[4]
+ myarray[5];

stop();


nummer is a dynamic textfield. Then I have a button. The button's code is like this:



on (release) {

myarray[5] = 1;
gotoAndStop(2);

}



But when the player reaches the second frame, the dynamic textfield still looks like ______ and not like the desired _____1. What is wrong?

Accessing Data From Dynamic Gen Arrays...
Okay guys, here's what I'm doing. In part one I'm parsing the XML data and the pushing all of the text data into arrays, dynamically.

Using a "for" loop I'm using the attachMovie to generate and place buttons on the stage using the array.length property. So, basically what I want to do is to be able to click on one of the buttons(movieclip) and have it display in a text field. For some reason it's not displaying the text properly. If I write the following...



genreName_txt.text = genre_array[i];

it will not display the text in the text field and it will return "undefinded" when running a trace. But if I write

genreName_txt.text = genre_array[3];

for example, it displays the proper text in the text field.

Why can't I use the "genre_array[i]" to access text within the genre_array?



genreXML = new XML();
genre_array = new Array();
ginfo_array = new Array();
genreXML.ignoreWhite = true;
genreXML.load("Genrelist.xml");
genreXML.onLoad = function(success) {
if (success) {
var rootNode = this.firstChild;
var children = rootNode.childNodes;
for (i=0; children[i]; i++) {
var Genre = children[i].attributes.genre;
var List = children[i].firstChild.nodeValue;
//trace ("Genre : "+Genre);
genre_array.push(Genre);
ginfo_array.push(List);
}
buildIt();
}
};


//-------Build Genre Buttons----------
function Buildit() {
for (i=1; i<=genre_array.length; i++) {
attachMovie("daButton_mc", "genre_mc"+i, i);
this["genre_mc"+i]._x = 95+(i-1)*10;
this["genre_mc"+i]._y = 498;
this["genre_mc"+i]._xscale = 60;
this["genre_mc"+i]._yscale = 90;
this["genre_mc"+i].id = i;
this["genre_mc"+i].onRollover = function() {
rollOver(this);
genreName_txt.text = genre_array[i];
};
this["genre_mc"+i].onRollOut = function() {
rollOut(this);
genreName_txt.text = "";
};
}
}

Xch And Dynamic Variables Holding Arrays
Okay, I have given up on putting and array within an array. The new thing is I dynamicaly create variables (instead of array eliments) and then keep arrays within them. The problem I'm having is I can't seem to assign an array dynamicaly to the xch object.

Now I tried without dynamic variable names and the only way I could get it to work was to use 'push'. This is what it looks like:


PHP Code:




// Get
trace(xch.myArray[1]); // Returns "Value 2"
// Set
xch.myArray = new Array();
xch.myArray.push( "Value 1" );
xch.myArray.push( "Value 2" );






However when I try this on my dynamic variables it doesn't work:


PHP Code:




// Get
getTargetVar = eval( "myArray"+1 );
trace(xch.getTargetVar[1]); // Returns "undefined"
// Set
setTargetVar = eval( "myArray"+1 );
xch.setTargetVar = new Array();
xch.setTargetVar.push( "Value 1" );
xch.setTargetVar.push( "Value 2" );






I also messed about with using the set() function rather than push, but that didn't seem to work either.


PHP Code:




// Get
getTargetVar = eval( "myArray"+1 );
trace( get( xch.getTargetVar[1] ) ); // Returns "undefined"
// Set
setTargetVar = eval( "myArray"+1 );
set( xch.setTargetVar, new Array() );
set( xch.setTargetVar[0], "Value 1" );
set( xch.setTargetVar[1], "Value 2" );






And I tried this variation:


PHP Code:




// Get
getTargetVar = eval( "myArray"+1 );
trace( get( xch.getTargetVar[1] ) ); // Returns "undefined"
// Set
setTargetVar = eval( "myArray"+1 );
set( xch.setTargetVar, new Array( "value1", "value2" ) );






But nothing seems to be working.

Help!

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