ActionScript 1/2 :: Measure A Sum Of Widths Of Items In An Array?
Jan 6, 2011Measure a sum of widths of items in an array? I can't figure out and not sure if it's possible..
View 3 RepliesMeasure a sum of widths of items in an array? I can't figure out and not sure if it's possible..
View 3 RepliesI've been working on a project the last few days in AS2 and decided I'd try and re-write it in AS3 as I'm yet to venture in to the AS3 world. I've done most of the conversion, but I'm stuck on what should be an easy problem. I'm loading images from an xml. The images get put into movieclips.
mcholder.image_mc.nmc0
mcholder.image_mc.nmc1
mcholder.image_mc.nmc2
mcholder.image_mc.nmc3 .......
I have a function that resizes the images when the stage is resized. This then runs another function to update an array of the image widths. The problem I have is trying to update the new widths into an Array. I just can't seen to reference my MC's to get the widths!
[Code]...
I am working on trying to collect data within an array (which works) and this data is collected when a button is pressed or selected. I also want the ability to remove an item from the array if the button is pressed again. Currently, I have these buttons dynamically generated and everything works well. The buttons have ids applied to them. SO what I am trying to get working is, if I select button 0, 2, 3 (0 indexing), the data array created holds [A., C., D.]. I want to remove A. after I click button 0. Instead, it seems to cause problems. What I am doing wrong with splicing??? trace statement:
A. items so far selected
selected items are: 0
A.,C. items so far selected
[code].....
I'm so proud of myself. I figured this out all by myself and thought I would share. (If you can't tell, I'm new to AS) I needed a way to grab an item in a specific location and have it return an array of items. Here is how I did it:
[CODE]....
I am trying to make my game increase in balls after each level passed by the player.
The script below are all on an enterFrame function
var level:int = 5;
var ball:ball_mc;
[Code].....
I need to sort String items in an Array. Actually I need to organize children of a MOvieClip inside an Array.
I have a "menu" mc object which has 8 children with names "m1", "m2", and so on..... the last one is "m8" . They are NOT created dynamically.
the children are even organized in layers alphabetically.
i've already tried:
Code:
//for each (var item:MovieClip in menu)
//{
[Code].....
I have an array a=[0,1,2,3] and I want to get a b array with elements of a randomly distributed. I tired the below code but it is not working[code]...
View 3 RepliesI have an array that contains movieclips. All of the movieclips have te type and they are all positioned on the stage next to eachother.
Above the displayed movieclips i have 3 buttons, each simbolizing a type, what i want to do is: i click on one of the buttons and all of the movieclips that dont match the right type should be removed from the stage, the remaining movieclips should then tween so that they are next to eachother again. If i click the button again then the movieclips should be displayed again to where they were and should all be positioned again next to eachother.
I'm a bit green when it comes to code and I have a specific thing I need to do which has had me going round in circles (no laughing at the back!). It must be pretty simple but I'm stumped! Basically I have 6 movieclips on the timeline with instance names 'btn1', 'btn2' etc to 'btn6'. These movieclips have an "on" and an "off" state (frame labels)
[Code]...
suppose I have created an Array object with 4 items on it. Now how we can remove that all items without looping process.
View 2 RepliesI am getting number 0,1,2,or 3 as rundom now when I am running following script. How can I get items a1,a2, a3 or a4 as rundom instead of number?
ActionScript Code:
exam_arr = [a1, a2, a3, a4];
ranNum = Math.floor(Math.random()*exam_arr .length);
var exam1= exam_arr[ranNum];
[Code]....
I am undergoing some experiments on creating object arrays before I attempt to implement it on my main flash document.
Ive created an object array with 3 variables, and im attempting to change the values, then trace the values back to see if its working. Ive tried many things but I keep getting [object: Object] back in the output window.[code]...
Is it possible to give an array of 6 items different x and y.. like as in 2 columns
startx = 0;
starty = 0;
for (var i = 0; i<itemArray.length; i++) {
First 3 items:
nav._y = starty+25*i;
[code]....
What I've got is a menu that loads images as buttons. It will only display menu items that are within a certain group (i.e. if themenuitem.node Value == groupid[q] then it will display that menu item. Each of the menu items has a unique number (Itemnumber[n]). I have a loop that goes through and displays the menu items that are within a certain group. I am currently able to also find out the unique number of each of the menu items where themenuitem.nodeValue == groupid[q], but what I want to do with these numbers, is place them all into an array as it loops through.So, say for example, it finds an item in the loop. It tells me this item is number 4 (if I tell it to trace(Itemnumber[n]) within the loop). Then, it finds another item in the loop, and it tells me this item number is 6. I want to be able to add items to an array as it loops through, so I'll have an array at the end like this: (4, 6).Currently my ActionScript looks like the following. Never mind if there are variables that are not defined in there -- they have been defined in other parts of my movie.[code]As you can see, I've made an attept at achieving this by trying numarray[numarraylength] = n; -- but all this does is send me an array, then overwrite it next time it loops (so I get an array like (4, 4), then one like (6, 6). I've added comments in the code to further explain what I'm trying to do.
View 2 RepliesI've got a combo box adding items from an array. The labels are working just fine, but adding the data with a variable won't work for me. If I put in an actual number, I get that result, but trying to add it with a variable I always get 1 as a result. classData only ever = 1. I can access the array. I know it must be in the syntax.[code]
View 2 RepliesI'm a bit green when it comes to code and I have a specific thing I need to do which has had me going round in circles (no laughing at the back!). It must be pretty simple but I'm stumped!Basically I have 6 movieclips on the timeline with instance names 'btn1', 'btn2' etc to 'btn6'. These movieclips have an "on" and an "off" state (frame labels)
I make an array:
ActionScript Code:
var buttons = [btn1, btn2, btn3, btn4, btn5, btn6];
[code]....
i want to make some kind of gallery, to put in a banner..
This is my code:
Code:
import flash.net.*;
var path:String="fotos.xml";
var xmlImages:XML;
[Code].....
I think the only thing i need to do is to add the items of my array to the stage
i don't understand arrays in functions, but how do you find the matching items given in an array? for example: var fruit:Array = ["apples", "oranges", "grapes", "oranges", "apples", "grapes"]; how can i get it to show only the number of apples in the array?
View 3 Repliesim trying to put a few items from a page into a 2d array, the page output looks like this
[Code].....
I have a DataGrid and I am manually setting the widths of the columns and they are working when i test through the flash application but in the browsers my column widths are not being set at all?
View 2 RepliesI want that clip on line 5 to equal the items of an array excluding the item that is the currently active/clicked on. Becuase one array contains buttons and the other array contains movie clips that I want to fade when the corresponding button is clicked
PHP Code:
function groupOn(event:MouseEvent):void {var clickedIndex:int = leftMenuArray.indexOf(event.currentTarget); currentClip =
[code].....
I'm making a very short text adventure, not one that will be all that fun, but just so I can learn a little as3. So I was designing a system that splits the persons input into an array of words, and then goes through and takes out unimportant words like "on." To test this out, I quickly (and messily) coded it up, and the only thing you can do is sit on a box. but it doesn't seem to be working. if you type "sit box" it works, but "sit on box" does not.
[Code]...
The buttons search and find the movie clip in the array flawlessly, but I'm having trouble adding a transition to every movie clip as it is appears. Most tutorials on transitions require a specific instance name, but I want ALL instances to have a transition. Heard the .getChildAt() method is the way to go but cannot find solid guidance on this. Here is the basic code:
Quote:
var myDishArray = [chicken, steak, tuna, pasta, iceCream];
for each (var btn in myDishArray) {
btn.addEventListener(MouseEvent.CLICK, onDishBtnClick);
[code]....
how do I properly use the transition manager or add a transition code?
Found some great code that adds Button Event Listeners in a loop. The buttons search and find the movie clip in the array flawlessly, but I'm having trouble adding a transition to every movie clip as it is appears. Most tutorials on transitions require a specific instance name, but I want ALL instances to have a transition. Heard the .getChildAt() method is the way to go but cannot find solid guidance on this. Here is the basic code:
Quote:
var myDishArray = [chicken, steak, tuna, pasta, iceCream];
for each (var btn in myDishArray) {
btn.addEventListener(MouseEvent.CLICK, onDishBtnClick);
[Code].....
how do I properly use the transition manager or add a transition code?
I used to put a load of instance names linking to library objs into an array in AS2, then use a loop to add them to the stage..I htought this would work in AS3, alas no.
Code:
var list:Array new Array("one", "two","three");
for(var i:int=0;i<list.length;i++)
[code].....
i don't understand arrays in functions, but how do you find the matching items given in an array? for example:
var fruit:Array = ["apples", "oranges", "grapes", "oranges", "apples", "grapes"];
how can i get it to show only the number of apples in the array?
I have an app where a user puts in the required info into text inputs inside a titlewindow pop up and it sends the data entered into a datagrid. This first time when I call for the popup and enter info it works fine. Here's the problem: the next time I call the component pop up and click anywhere on the popup, including textInputs, the first the item in the array is automatically entered into the textInput where the user is supposed to enter the data themselves (BTW this textInput is also a autocomplete component).What I want is nothing to entered into textinput until the user inputs the data themselves. I've been tweaking with it for hours and im stumped. Here's the code: (this is main page)
[Code]...
I'm trying to remove items from an array but its not working like its supposed to.Here is my code:
for(var i:uint = 0;i<OrderModel.getInstance().orders.length; i++){
if (OrderModel.getInstance().orders[i].time == hour){
OrderModel.getInstance().orders.splice(i, 1);[code]....
it deletes all the items but 1. I allways have one item left wich should be deleted but it isnt.
Each item in the array in on the stage, each with an x/y position. The item in the top left most position should be items[0]. X should be the primary. Originally I was thinking along the lines of:
var items = [m1, m2, m3, m4, m5, m6];
items.sort(sortMe);
function sortMe(a, b) {
return (b.position[0] - a.position[0]) && (b.position[1] - a.position[1]);
}
But this does not yield the correct results.
If i was loading external content, such as images or what not will the array load the items twice for example:
load = array(){
load images( "local/folder/www.example.com/" );
items("car.jpeg","bike.jpeg","bike.jpeg");
}
The above is in theory, if you notice twice i have the "bike.jpeg" image in the array; its key value would be either items[1] or items [2].
so with the above idea in mind would this bike image be loaded twice or just referenced in the array from the first initial load.