ActionScript 2.0 :: Make An Array And List It's Elements In A Text Box?
Apr 25, 2004I'm trying to make an array and list it's elements in a text box.
Code:
tabs = new Array();
tabs[0] = "jerseys";
tabs[1] = "tshirts";
[code]....
I'm trying to make an array and list it's elements in a text box.
Code:
tabs = new Array();
tabs[0] = "jerseys";
tabs[1] = "tshirts";
[code]....
I'm using a list element with variableRowHeight and word-wrap set to true like in the example below:
[URL]
When I scroll through the list with a mouse scrollwheel the text in the listItems also scroll. I know that this is to do with the height of the textField...
this is part of an XML file I retrieve using AS3 E4X:
<links>
<link>
<label>Versions</label>
<href>http://mylink1</href>
[Code].....
I want to retrieve the values of labels, so I write:
document.links.link.label.text();
This returns VersionsConfigurations. I need this as Array ([Versions, Configurations]) but I would like not to use a loop. Is there any other way?
I have an array (named arrayFull), and I want my dynamic text box (named messageText) to display one random element from the array, changing once per second.The code I have makes it display all elements of the array at once in random order, changing once per second.How do I make it display just one element from the array at any given time?This is the code:
var arrayFull:Array = new Array(1,2,3,4,5);
import flash.utils.Timer;
import flash.events.TimerEvent;
[code]....
I think that arrays are probably one of the more powerful tools available in flash,
mc with instance name but0
inside mc is a text box var name label , code is
[AS]label = _name;[/AS]
mc on main timeline code in frame 1 is:
subjects = new Array("page1","page2","page4","page4","page5")
butHeight = but0._height+5;
butNumber = subjects.length[code]....
What this code does is produce 5 buttons appearing one after the other, like a cascade effect, so far so good, I then want to insert the array elements into text box label, but all I get is subject, subject1, subject2 and so on.So, what do I need to do so that my buttons are called page1, page2 and so on.
I'm trying to figure out how to generate an array whose elements are each arrays to make a quick loading database of sorts.the main array could essentially be something like "employees" while each employee would have demographic data like age, salary, gender, etc.In some cases the information on some employees would be greater than others, and options created by "push" would imply the number of elements within each employee array would be variable until generated.[code]But I get the feeling this type of array as it is currently described doesn't lend itself well to adding new elements in the way I've described.My goal is once an employee's information has been entered and saved, I can call up their info by array number like aEmployee[2], and if employee 2's name is Bob, then Bob's name would appear in the text field, along with all the other fields related to Bob's array, such as being male, 42 years old, and living in Witchita Kansas.Would I modify a multidimensional array, or do I want an array within an array, and is there a way to add "arrays" as elements?
View 8 Repliesdoes anyone know how to shift all the array elements by one or more without deleting the array itself?
Something like rotating the array:
1,2,3,4,5,6,7,8,9,10
10,1,2,3,4,5,6,7,8,9
9,10,1,2,3,4,5,6,7,8
8,9,10,1,2,3,4,5,6,7
7,8,9,10,1,2,3,4,5,6
I'm building a kind of dynamic level generator, at the moment I have it draw a grid of alternating coloured squares/plots (for visual debug), currently set at 1 pixel which I then scale up so they are easier to see. I make a list of all these open 'plots' in an array(maybe a dictionary would be better?)... Next I draw a random selection of roads on top of my grid in another sprite. Ranging in width from 2 to 8 plots. First drawing all the horizontal, and then the vertical ones. Now I'm wondering what would be the best way of finding all the plots/pixels that these roads occupy?I thought perhaps I could draw the roads into bitmap data, and then find the x,y values of all the black pixels? something like:
PHP Code:
var bData:BitmapData = new BitmapData(roads.width, roads.height, false);
bData.draw(roads)
[code]........
The problem with the code below is that TextFormt does not support wordWrap which is upported by TextField(which, unfortunately has no effect on a List component).
var lb = new TextFormat(); lb.bold = true;
lb.align = TextFieldAutoSize. lb.color = 0x000066;
var sqsL:List = new List(); sqsL.rowHeight = 44;
[code].....
I have 2 arrays, one of images, the other of links I would like to create an XML list using the values in these arrays. My code is similar to:
public function savecards():void var coverflow:XML = new XML(<coverflow/>); var cover:XML = new XML(<cover/>);
for (var j:Number = 0; j < 2;
[code].....
I want to list all controls (buttons, datagrids, etc) in a container
This works but gives me a warning 1008: variable 'comp' has no type declaration.
for (var i:int = 0;i<this.numElements;i++)
{
var comp = this.getElementAt(i);
[Code]....
when I get a compiler warning it's because I'm not doing something the way it is supposed to be.
Are there any alternatives to reference the id property? A method I'm missing even a whole different way iterate through all the controls?
I have a for loop which is grabbing data from a xml file and showing it to the user.. my problem is that I want to show 5 for let's say.. 30 seconds.. and then making a transition and show another 5 elements.
I can make the condition like:
Code:
if(info.length() >= 5){
for (var i:int = 0; i < 5; i++)
{
and I show the first 5. But what now? How do I hide those and show the next five?
I've been trying to move array elements from one array to another using the push method. The problem is that the element pushed should any longer be on the first array where it was taken from. That's where i'm stuck..
[Code]...
Is it possible to define a property to limit the number of elements which will appear in a mx:List ? I've read about setting the property rowCount, but I don't see any effect.Can a filter be applied to accomplish this? My intention was to avoid removing the items from the list/array collection, but simply "hide" them. Can this be done?
View 2 RepliesI have been scripting this flash profile card which pulls data from multiple XML files. The problem i am having is when it comes down to pulling this 1 set of information which is accessing the attributes of an array of specific XML nodes on display after the first item it inputs a comma before each item.
My code:
---------------------------------------------------------------------- ---
xmlData = new XML ();xmlData.ignoreWhite = true;xmlData.onLoad = loadXML;xmlData.load ("../xml profiles/test.xml");
---------------------------------------------------------------------- ----
function loadXML (loaded){if (loaded){ xmlNode = this.firstChild;
[code].....
This is just a draft version of the layout i used to pull up fake data... to show the commas.Lastly i am wondering if it is possible to control the 3 text fields using 1 scroll bar or would i be better off learning how to create columns in 1 text field to display these lists.
Is there a way to write out an array without the that separates the elements in the array?
View 15 RepliesIf I am a subclass of an Array, how do I access an element?
class ArrayOfFoo extends Array
{
public function getFooAt(anIndex : int) : Foo
{
return this[anIndex] as Foo; // <---- looks for an object attribute (named "0", for example)
}
}
I could wrap an array instead of subclassing it, however lacking a universal IArray interface, that is less than useful for standard and custom functions expecting an Array.
I have a list of countries that are in an xml document. I was wondering if here was a way to randomly load ten of these and place them on the stage in random places. I want to get the effect of this intro: [URL]. (not the one with the black background)
View 8 RepliesI have a List, and I have an ArrayCollection.
The ArrayCollection is something like:
<mx:ArrayCollection id="arrColl">
<mx:source>
<mx:Array>
[Code]....
I need the List to only display the scores of the student.
Something like:
<s:List dataprovider="arrColl[Student A]"/>
or:
<s:List dataprovider="arrColl.Student A."/>
When a user selects a category from the first drop down box then i want the 2nd drop down to be updated based on the selection of the first drop down. I have created multiple ArrayCollections whose names are set to the "data" values of the first drop down, for instance:
[Bindable]
public var countries:ArrayCollection = new ArrayCollection([
{label:"USA",data:"USA"},
[code].....
I'll start by posting my code then explain what I want it to achieve.
[Code]...
What I am attempting and failing to do after much trial and error is to have a random ingredient from the ingredientList array pushed into the previewIngredients array making sure the new value going in is not already in the preview ingredients array. If the same value is there I want it to keep choosing an ingredient from the list array until it finds a value thats not in the preview array then push that one in there. It feels like I'm getting close but obviously I'm either going about it the wrong way or just missing a little somthing somthing out.
How do you empty an array. I want the array complete empty, so the array length =0. I have tried this code, but that doesn�t take away all elements in an array, just a few.
for (i=0; i<myArray.length; i++) {
myArray.pop();
}
What is the easiest way to let a variable refer to all the elements in an array?
View 3 RepliesI am stuck when trying to total the elements in an array, I keep getting NaN and cannot for the life of me see what I am doing wrong.
I am using a prototype function:
Code:
Array.prototype.sum = function(){
var totalSum:Number,a=0;
while(a<this.length){
[Code]....
In a fla file (flash8) I added an "Input-text" naming the var: "varInput", and selected "Numeral [0..9]" from "Character Embedding".I added another input object, this time of "Dynamic -text" text type naming the var:"varOutput". I also added a button naming its' instance name:"btnDisplay".In "actions" panel I wrote the following [code]....
View 2 RepliesI´m trying to order elements of an array. When the dates come from dynamics text it´s no problem, bad when come from input text the dates are treated like strings and it´s impossible to order correctly, because 15 is considered less than 3. In both cases I can operate correctly whit this dates like numbers.How is possible to order this dates from input text, like numbers?
View 3 RepliesI have array with 5 boxes. I show this boxes on the stage + showing it random. Now I want add events for this boxes. For example if I click to box1 I must go to 'p4', if I click to any other boxes I must go to 'p3'.
I try to make the same like for buttons, but its not working:
classNames[0].addEventListener(MouseEvent.CLICK, goCorrect);
function goCorrect(event:MouseEvent):void {
trace("p4");
gotoAndStop('p4');
[Code] .....
is there an easy way, using 1 or more for loops, to hit test every object in an array against every other object in that array. So I've got an array of 6 things
[Code]...
If i have array like var my_Arr:Array = new Array("a", "b", "c");and i have button to use random element of ths array , is there any to remove that element that if i press the button again i won't find the last element ?
View 5 RepliesI need to access the elements of an array that is declared in the main swf(_level0). But I need to change it from another swf.How can I do it??So far I have this:
MAIN SWF:
var vector1:Array = [biblio_vid1, biblio_vid2, biblio_vid3, btn_1_4, biblio_vid4];
OTHER SWF:
var vector2:Array = _level0.vector1.slice();
trace(vector2); // undefined,undefined,undefined,undefined,undefined