View Full Version : help with an array
rogueblade
02-18-2009, 01:15 AM
hi guys, new here and pretty new to actionscript
I have a fade tween in which I would like it to fade out all the items in my array. There are only 2 items at the moment for the sake of testing. I've been killing myself over this for the past like 2 hours and am hoping I'm just missing something completely obvious. I cannot seem to tell the tween to fade Both items in the array, item 0 and 1
I've tried [0&&1] and all sorts of ridiculous bracket combinations to no avail
FadeOutTween = new Tween(MyArray[0,1],"alpha",None.easeNone,1,0.5,0.3,true);
with an array you can store many object but you can't access these objects all at once you need to access them one by one. This can be done in a for loop or while loop or other ways. For example this would theoretically work:
FadeOutTween = new Tween(MyArray[0],"alpha",None.easeNone,1,0.5,0.3,true);
FadeOutTween2 = new Tween(MyArray[1],"alpha",None.easeNone,1,0.5,0.3,true);
rogueblade
02-18-2009, 05:32 AM
ah thank you, I didn't realize I can't access my array objects all at once the way I was trying too..
So I'm trying to create a for loop, I get the idea, but it's not working out....have a look: (i've edited names of stuff for simplicity)
var liquidsArray:Array = new Array(Hg_btn, Br_btn);
var liquidsTween:Tween;
solids_btn.addEventListener(MouseEvent.CLICK, liquidsShowHide);
function liquidsShowHide(event:MouseEvent):void{
for(var i:int = 0;i<liquidsArray.length(); i++){
liquidsTween = new Tween(liquidsArray[i],"alpha",None.easeNone,1,0.5,0.3,true);
}
}
Error #1006: value is not a function.
at PhoneApp_fla::MainTimeline/liquidsShowHide()
is .length(); the correct term here? or is the entire for loop haggered :confused:
ah thank you, I didn't realize I can't access my array objects all at once the way I was trying too..
So I'm trying to create a for loop, I get the idea, but it's not working out....have a look: (i've edited names of stuff for simplicity)
var liquidsArray:Array = new Array(Hg_btn, Br_btn);
var liquidsTween:Tween;
solids_btn.addEventListener(MouseEvent.CLICK, liquidsShowHide);
function liquidsShowHide(event:MouseEvent):void{
for(var i:int = 0;i<liquidsArray.length(); i++){
liquidsTween = new Tween(liquidsArray[i],"alpha",None.easeNone,1,0.5,0.3,true);
}
}
Error #1006: value is not a function.
at PhoneApp_fla::MainTimeline/liquidsShowHide()
is .length(); the correct term here? or is the entire for loop haggered :confused:
right is length not length()
rogueblade
02-18-2009, 03:49 PM
awesome thanks a mil! But I did happen to work it out on my own just before going to bed last night :D I'm glad to see your solution is the same as what I figured. More questions probably to come :o
rogueblade
02-20-2009, 03:45 AM
Alright here's my next issue. I have a function that runs when a button is clicked and I want a for loop to run through an array of buttons, disabling them all (mouseclick) except for the button that has been clicked to run the function. Trying to work out this 'splice' but it won't work correctly:
gas_btn.addEventListener(MouseEvent.CLICK, gasesShow);
function gasesShow(event:MouseEvent):void{
for(var y:int = 0;y<MenuArray.length; y++){
MenuArray.splice(10,1);
MenuArray[y].mouseEnabled = false;
}
}
Now the issue is that every array item that comes after item number 10 does not get disabled but everything that comes before item 10 does get disabled. I want all except for 10 to be disabled.
(Also I don't know why but var 'y' is turning blue in my code, I tried other letters that did not change color but that made no difference)
rogueblade
02-20-2009, 07:34 AM
hey mods, if you could change the thread to unsolved that would be sweet as I have a new question going here, thanks.
edit: Oh wait, the check mark in the thread means I've posted in it....I think....my bad
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.