ActionScript 2.0 :: Lists And Arrays - How To Tie Name To Number
Jun 30, 2009
What I have are basically two lists.
(using this one as an example)
Bear = 5
Cat = 3
Dog = 1
Bird = 2
And I have two corresponding arrays
Array1 = [5, 3, 1, 2]
Array2 = [Bear, Cat, Dog, Bird]
How can you reorder this by number? I know that you can use Array.sort, but how would I still be able to tie the name to the number? Like, if you use the sort method, it will give you [1, 2, 3, 5], but the other array would still be [Bear, Cat, Dog, Bird]. How could I make it so it ends up being [1, 2, 3, 5] and [Dog, Bird, Cat, Bear]? I was thinking of making something like [[Bear, 5], [Cat, 3], [Dog, 1], [Bird, 2]], but I'm pretty much stuck after that...
View 5 Replies
Similar Posts:
Dec 20, 2006
This is probably one of several ways to do this..."myData" is an array that contains information displayed in "myDataGrid". "toBeMoved" is a variable containing, um, the item to be moved.
btn_up.onRelease = function() { // this is a button to move items UP in the list
whoseSelected = myDataGrid.selectedIndex; // gets the index # for the selected row/item
if (whoseSelected > 0) { // makes sure you dont have the already top item selected
toBeMoved = myData[myDataGrid.selectedIndex][code]...
View 2 Replies
Apr 18, 2011
I've got an array of coins, which are called within the array coin1, coin2, coin3, coin4 etc. I'm trying to reference them to say if the character hits coin 2, then coin2 will disappear. Here's my array (so far):
ActionScript Code:
var coinArray:Array = [coin1, coin2]; //an array which contains all of the coins
And here's the script I'm working on:
ActionScript Code:
function coinCollect(evt:Event){
if (collisionTest (character, coin/*[n]*/){
var i:int = /*the number from coin[n]*/ - 1
remove coinArray[i]
}}
But I'm missing some major things, mainly how to reference which coin has been hit, and how to take the number from that coin and take 1 from it to reference it's correct position in the array? (the code in /* */ tags represents things I'm not sure on the code of).
View 2 Replies
Jun 12, 2011
I've been making arrays from numbers produced by the Collatz conjecture. But when the number where we start calculating exceeds over 1x10^16 program can't do any more calculations. It loses it's capability to handle odd numbers. Heres a part of my code that makes calculations:
ActionScript Code:
var a:Number;
var result:Array = new Array();
var count:int = 0;
function calculate(e:TimerEvent):void{
[Code] .....
View 6 Replies
Jul 3, 2006
i am trying to create a loop that will put a list of names from external sources into a number of Arrays .so what i did is :
Code:
for (i=0; i<4; i++) {
this["loadVarsText"+i] = new LoadVars();
this["loadVarsText"+i].onLoad = function(success) {
[code].....
and i dont understand why it is not working, and how can i fix it?
View 3 Replies
Mar 17, 2005
Posible? like: product here..product here..produkt with extra info and so on like 1 row moreor 2 lines heheor just 1 productitem info here? Or.. as in columns?
View 1 Replies
Nov 12, 2009
How do you make a List control wrap around to a second column (or multiple columns)? let me know if there is a solution for this with the List control or some other Flex control.
For example, if you have one list with 42 items in it, but I want to cap the height of a list to 20 items; then instead of having one list with 42 items all the way down, I would have that list of items look like the equivalent of 3 adjacent lists: the first with 20 items, the second with 20 items, and the third with 2 items (which represent the original list of 42 items). [url]...
View 6 Replies
Jun 30, 2009
i need something in this script for make mask to all the menu now i stell don't understand why just last menu is mask i have var( i )Start from 0 to last number the menu example: last number menu is 9 so will mask just the menu number 9 i need not just to mask menu number 9 i need to all the menu menu loanding from xml and i make the script for linkage i tray so much for finish the problem for mask all but .... this is script:
[Code]...
View 9 Replies
Jul 6, 2011
I need to create the same like this: [URL]
but in flash... I am fighting all week to create this, but I've lost...
View 0 Replies
Sep 25, 2009
I've successfully (finally) been able to pull imagery from an external XML list and display it on stage and even add it to be pulled randomly. What I'm hoping to be able to do, is after the first image comes in, using a mask bring another on top of it with a vertical blinds effect.And alternate back and forth with this technique. My thought process is two XML lists being pulled alternately? (I'm probably WAY off.) I've seen a couple templates out there, but 1. I'm a financially strapped programmer and 2. I wouldn't learn anything that way anyways.
ps. I might include the code that I have thus far in a little bit.It's nothing more than a modified version of an XML slideshow from another tutorial site.
View 1 Replies
Apr 9, 2008
It was not for the want of trying, but I just don't think I knew where to look or what to search under, which brings me to asking the good people here. I'll try and keep it short and to the point...
I need 5 ComboBoxes/DropDown-lists/whatevers which are Item, Colour, Height, Width and Price.
And once the user has selected an item from each dropdown, and presses a button, this will generate a URL in a new window. Something like this:
[URL]
The second part of my 'question' is: Is there a way to, if the user chooses Item#1, then in the Colour list, 3 particular colours are there, but if the user chooses Item#2, then there a different set of colours to choose from?
View 2 Replies
May 9, 2009
way to create a mailing list form for the website I'm making for a model. I've looked over a number of things and I'm not finding anything that can do just what I need without alot of peripheral knowledge of PHP, Perl, etc. or being way more complex than I even need.All I'm basically looking for is a construct where there will be 3 text fields that the user can type their info into. ( name,address, e-mail ) Then there will be a send or clear button for them to obviously either change or send the data. All I'd like is for the info to be sent to an e-mail address we specify where we can retrieve it later and use it for a mailing list. I know there are a few ways this can be done. I'm just not sure if it would be better to have it be as described above - or if since I want it sent to an e-mail address, make the data into an e-mail. I've used Flash for a few years but mostly for graphics, animations and the navigational aspects of sites. I have basic scripting skills, so for me this is fun new ground, as I'd like to get better at creating the code for some user interactivity.
View 2 Replies
Sep 25, 2009
I am looking to replicate the way the music tracks are presented on this website:[URL].. I'd like to create something somewhat similar, in which I can simply type out the name of each track and then have the small Play/Pause button icon. Are there any templates that are packaged with Flash CS4 for something like this? Otherwise, if you could point me in the right direction as to how it is constructed and/or a tutorial for creating. - But is the text that lists the tracks done in HTML? If so, then this is pretty simple really.
View 1 Replies
Jun 28, 2011
I need to create two lists called OLD LIST and NEW LIST.I need to be able to drag items from old list to new one and vice versa.I almost created these things, but I have a problem with update the items position when I drag item from list to another one
View 0 Replies
May 14, 2008
I'm building fairly simple item renderers, in fact, here's the code for one of them...
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
implements="mx.controls.listClasses.IListItemRenderer"
[Code].....
It's a really simple renderer that has an image and some text sitting next to it, or just the text if no image is in that item's data provider. There is also some basic rollover, rollout and click functionality...
So my question: Why is it that if my list needs to scroll it gets messed up? By "messed up" I mean that the text changes from being to the right of the image (when image is present) to moving over top of the image, as if it isn't realizing that the image is there. There's also sometimes an issue of the item renderer shrinking down so there is no longer anything even visible in the box (just some black with a grey border on the bottom about 5 - 10 pixels big...
I'm wondering if maybe my item renderer is too complex? I'm having the same issue with text working like that in another renderer, but no images, just text placed in certain positions (as well as some strage blue tints showing up at the top or bottom depending on how I am scrolling)
By the way... here is the MXML where I am initializing my list...
Code:
<mx:Canvas width="100%" height="100%" id="list">
<mx:List
width="100%"
[Code].....
View 1 Replies
Jan 29, 2009
Ive been searching everywhere to try and find a way to add a bit more styling to my htmlText fields, apparently the flash developers really half-*****ed the abilities of html and especially css.my biggest complaint would be with the unordered lists, the giant, ugly, black bullets. these things would break all but the worst designs and stand out like a sore thumb in every use I could find.
View 2 Replies
Dec 22, 2010
I've got a Flex 3 website. Unfortunately, Google Webmaster Tools lists zero keywords for my site. My site's been up for about a month. I submitted a sitemap. I've put a description and keywords metatags in the HTML wrapper.Any advise on what else I should do? Does anyone have a Flex 3 site for which Google Webmaster Tools lists keywords?
View 2 Replies
Aug 5, 2011
I'm trying to override the default handling of the 'up' and 'down' keys for an editable list, such that when they are pressed a list entry that is being edited behaves as if the escape key has been pressed, but the 'selected item bar' moves up or down.
Here is my (simplified) component:
<?xml version="1.0" encoding="utf-8"?>
<mx:List xmlns:mx="[URL]"
enabled="true" width="100%" height="100%"
creationComplete="initialise()"
editable="true"
[Code] .....
For some reason this doesn't work: if a row is being edited, the first 'up' (or down) keypress ends the edit and moves the bar. Further up or down keypresses have no effect, but if you click somewhere near the list it does start working. This makes me think it is a focus issue. Weirdly, if you hit escape the edit finishes and you can move up and down correctly. If the 'callLater' line is uncommented to try and make the list retain focus, the bar initially moves in the direction of the keypress but then moves back again and re-edits the original line!
View 2 Replies
Oct 29, 2010
is there any control that lists items (like s:list control) and also allows to edit the item ( like mx:ComboBox )?
View 0 Replies
Apr 10, 2012
I have several horizontal scrolling lists with differing item widths stacked inside a Vertical Group. On an item click all any selected item from the other lists will be cleared. When any of the lists are scrolled all the other lists should scroll exactly the same amount in the same direction, simalar to [URL]
The synced scrolling is throwing an undefined error and has crashed the adl(it is a mobile app) on one occasion. This happens only when I add more than 2 synced scrolling lists via event listeners.
So my question is: Can anyone see why this errors or is there a better way to achieve this type of horizontal scrolling multi-list, possibly a really wide data-grid or group of buttons inside a scroller?
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
[Code]....
View 2 Replies
Aug 17, 2010
I'm trying to create a nested list in Flex which will dynamically resize to display all children when the data provider changes.
Here's a simplified example which illustrates the problem:
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Code].....
The list sizes remain static when items are added.
If I add variableRowHeight="true" to the outer list then the inner lists will correctly resize. But the outer list itself remains at a fixed size.
How can I have both lists resize automatically to display all children?
View 1 Replies
Apr 14, 2009
ok so i built a nice little CMS that is all XML driven, everything working pretty smooth you can open the documents edit them same them, make new ones, and so forth. the only issue that im hitting is that it will take the app some time before it understands the xml has changed.
so i built a refresh button, it removes all of the listeners nulls the two xml lists then rebuilds everything, but this will only work after sitting around for a minuet, if i refresh right after i add content or make a new file, it won't show. this isn't a huge issue since the files do eventually update, but i would like to figure out what is going on,
View 1 Replies
Jan 21, 2011
I am running into some trouble adding an array into another array to create a multi-dimensional array.The code appears as below:
var slideDataArray:Array = new Array();
var slideShowDataArray:Array = new Array();
slideDataArray[0] = xmlData.SlideShowParameters.SlideShowImagesDirectory;[code]........
I am looking for a means of placing the slideDataArray into a 'slot' or value of slideShowDataArray so that I can in the end pass the slideShowDataArray as a parameter to another function.As of now, the last slideDataArray appears 11 times (the loop runs 11 times) in slideShowDataArray and the way the code is written the slideDataArray is unique every iteration of the loop.
View 1 Replies
Sep 3, 2008
client decided on a different font (after we finished everything), so i had to go change the font. in one page, whenever i change the font in one text block, the XML-driven lists stop being rendered. they load, according to the trace statements, but nothing actually renders. when i change it back to the original font, boink! everything is just fine. if i delete the text and create a new field... same thing. i finally had to hide the thing and make a new text block in it's place.
[Code]...
View 1 Replies
Aug 26, 2009
I've got a bit that loads a big chunk of xml data about products.I push product info into an array(e.g. productArray), then add that array to another array (e.g. allProductsArray)How do I sort those arrays? For instance, if I want to sort the allProductsArray based on the info in productArray[0]?Alternatively, would something other tha an array of arrays be a better route?This loader loads the same sort of info for many different clients, so the bit to sort on will change.
View 5 Replies
Sep 26, 2011
I'm trying to write a function where I can specify any amount of array, and the return value will be an array containing the contents of all of the specified arrays.I've done this, but it seems like a really slow and ugly way of doing it:
var ar1:Array = [1,2,3,4,5,6,7,8,9];
var ar2:Array = ['a','b','c','d','e','f','g','h'];
function merge(...multi):Array[code].....
Is there an inbuilt and more efficient / nice way of achieving this? The result does not need to be in the same order as the input - completely unsorted is fine.
View 3 Replies
Feb 17, 2009
A little explanation: Im making a random arranging number Array. So instead of using a loop and assigning 0 to first array element, 1 to second, etc.I need to make it totally random but without repeating any numbers. To do that I made a second Array that will have the same number of children to serve as a reference.Each of them will be an Object with a property "num" , wich will be its actual number, and a property "called" wich defaults to false.Like this:
ActionScript Code:
for(var i:int=0;i<vQuantity;i++){
ranArray.push( new Object() );
[code].......
View 8 Replies
Dec 27, 2009
I've had a problem for awhile that was really odd. After some intense debugging, I realized the problem lied in setting an array equal to another array.[code] When setting one array equal to another, the values aren't copied over, but a reference to that memory is stored. So no matter which variable you change, they are both references to the same memory and thus both will reflect the changes.With other data types, this doesn't happen.I could fix it by looping through t1 and using push() to add each index from t1 into t2, but that seems a little messy.
View 7 Replies
Jun 25, 2004
correct syntax for pushing variables to arrays within arrays? I have searched many threads but found nothing that exactly answers my query.I have a class (Brigade) which amongst other variables contains an array (BrigadeUnits) This is the third element.. My Brigades are stored in an array called AllBrigades. I now need to fill the BrigadeUnits array with objects of my Units class.The hierarchy I want to create is as follows:
AllBrigades (array of Brigades)
Brigade (object)
BrigadeUnits (array within Brigade object)
Unit (Object to be stored in BrigadeUnits array)
I have tried various approaches including the following, assuming that I am addressing the first Brigade in the array:
AllBrigades [0] [2].push (MyUnit);
But when I trace this I just get undefined.
View 14 Replies
Jul 16, 2009
Dear Guys I Want To Generate A Random Number Between 2 Number BUT Without Generating 2 Same Number I Mean If For Example Already Generated Number "2" Next Time Did Not Generate It , Is There Any Solution
View 5 Replies