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




Clear All Elements In An Array?



Is there a way to clear all the elements in an array with redefining it again?

Thanks



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 08-21-2006, 05:20 PM


View Complete Forum Thread with Replies

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

Associating Array Elements With Another Array Keeping The Order.
hi, i have already posted this problem yesterday but i haven't solved it yet.
i have two arrays:

array_1[a,b,c,d]
array_2[01,02,03,04]

the first array represents mcs in my stage - the buttons of the menu.
the second represents other mcs, containing some text.

when i rollOver each element of array_1 i would like to show each element of array_2 in the same order and hide it when i rollOver another menu button to show a new one.

I mean, it always has to be showing a with 01, b with 02, c with 03...

any suggestions?

Given An Array Return An Array With Only Unique Elements
if i have an array of elements like 1,2,2,1,3,3,1,2,...

I want to return only

1,2,3

so to strip out duplicates, I thought this would be easy but its proving harder than I thought.
thanks

Array Elements
hi,

As far as i understand u cannot sent an entire array from php so i need to send one ellemnt at a time to an array in flash...
i.e. txt0=....txt1....txt2....txt3.......




PHP Code:




while($row = mysql_fetch_array($result)){
    print "&txt$count=" . $row["txt"];
    $count++;
}








So if this is the code i'd use in php what would be the code to receive the element of array into flash???

Please help....
Thx....

[F8] Array Elements
Hi guys

I hope that you can help?

I am saving usernames and passwords from a CD game to a shared object and populates 2 arrays with these details.



Code:
myUsers.data.usersSO = new Array();
myUsers.data.usersPas = new Array();


But I am having problems moving the users login details to the beginning of the array if the user types in a username that is already in the SO.

It sort of works the username goes to the beginning of the array but there password doesn't.

Heres the code I have on the button for finding an placing the info to a SO.


Code:
btnNew.onRelease = function() {
var intervalId2:Number = setInterval(myInstrc2, 15000);
this.playSound("60", "ordinary", 0);
validateName();
if (firstnameField.text != "" && passwordField.text != "") {
var found = false;
if (myUsers.data.usersSO != undefined) {
arrowmc._visible = false;
for (var i = 0; i < myUsers.data.usersSO.length; i++) {
if (myUsers.data.usersSO[i] == firstnameField.text) {
myUsers.data.usersSO.splice(i, 1);
myUsers.data.usersSO.unshift(firstnameField.text);
trace("Found: " + firstnameField.text);
found = true;
break;
}
}
if (myUsers.data.usersPas != undefined) {
for (var i = 0; i < myUsers.data.usersPas.length; i++) {
if (myUsers.data.usersPas[i] == passwordField.text) {
myUsers.data.usersPas.unshift(myUsers.data.usersPas.splice(i, 1));
trace("this is the password: " + i);
trace("Password: " + passwordField.text);
found = true;
break;
}
}
}
} else {
myUsers.data.usersSO = [];
myUsers.data.usersPas = [];
}
if (!found) {
arrowmc.gotoAndStop(1);
myUsers.data.usersSO.unshift(firstnameField.text);
myUsers.data.usersPas.unshift(passwordField.text);
myUsers.flush();
}
currentUserName = firstnameField.text;
userPassword = passwordField.text;
firstnameField.text = "";
passwordField.text = "";
getInfo();
lookS0(myUsers);
} else {
arrowmc._visible = true;
arrowmc.gotoAndPlay(2);
}
clearInterval(intervalId1);
myUsers.data.usersSO.findIndex(currentUserName);
};

Elements In Array
I've been working on a project that stores video recordings, images, and other entries into an array. The core code was provided to me and I have built most of my code around this. However I have become stuck on one part which is removing items from an array. This is my datacontainer class: I was hoping someone could show me the way and point me in the right direction.. Thanks in advanced. I have cropped the unncessary code from the bottom....


Code:


package Prototype
{
import flash.events.EventDispatcher;
import flash.events.Event;
import flash.events.NetStatusEvent;
import flash.events.SecurityErrorEvent;
import flash.events.SyncEvent;
import flash.net.NetConnection;
import flash.net.SharedObject;

public class DataContainer extends EventDispatcher
{
public static var SENTDATA:String = "sentdata";
public static var DATACHANGED:String = "connected";

private var m_netConnection:NetConnection;

private var m_sessionListSO:SharedObject;



private var m_bConnected:Boolean;

public function DataContainer()
{
m_netConnection = new NetConnection();
m_netConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
m_netConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);

m_bConnected = false;
}

public function connect(sUri:String)
{
m_netConnection.connect(sUri);
}

private function onConnected()
{
//trace("onConnected");

m_bConnected = true;

m_sessionListSO = SharedObject.getRemote("sessionList", m_netConnection.uri, true);

m_sessionListSO.addEventListener(SyncEvent.SYNC, sessionSyncHandler);
m_sessionListSO.connect(m_netConnection);


}

public function clear()
{
//trace("clear")
m_sessionListSO.clear();
m_sessionListSO.close();
}

//filter by public and type?
//iType = 1 public
//iType = 2 private
//iType = 0 all
public function getUserList(iType:int):Array
{


var tArray:Array = new Array();
if(m_sessionListSO.data.users != undefined)
{
if(iType == 0)
{
return m_sessionListSO.data.users;
}
else if (iType == 1)
{
//trace("length of public "+m_sessionListSO.data.public_array.length)

//trace("length of users "+m_sessionListSO.data.users.length)

//search the public session list
var i:int;
for(i=0;i<m_sessionListSO.data.public_array.length;i++)
{
//trace("-->"+m_sessionListSO.data.public_array[i].session)
var n:int;
for (n=0;n<m_sessionListSO.data.users.length;n++)
{
////trace(" "+m_sessionListSO.data.users[n].session);

if(m_sessionListSO.data.users[n].session == m_sessionListSO.data.public_array[i].session)
{
////trace(" == Found Public == session "+m_sessionListSO.data.users[n].session)
tArray.push(m_sessionListSO.data.users[n]);
break;
}
}
}


}
else if (iType == 2)
{
//trace("length of private "+m_sessionListSO.data.private_array.length)
//trace("length of users "+m_sessionListSO.data.users.length)

//search the public session list

for(i=0;i<m_sessionListSO.data.private_array.length;i++)
{
//trace("-->"+m_sessionListSO.data.private_array[i].session)

for (n=0;n<m_sessionListSO.data.users.length;n++)
{
//trace(" "+m_sessionListSO.data.users[n].session);

if(m_sessionListSO.data.users[n].session == m_sessionListSO.data.private_array[i].session)
{
//trace(" == Found private == session "+m_sessionListSO.data.users[n].session)
tArray.push(m_sessionListSO.data.users[n]);
break;
}
}
}

}
}


return tArray;

}

public function getPublicList():Array
{
//trace("getPublicList "+ m_sessionListSO.data.public_array.length)

return m_sessionListSO.data.public_array;
}

public function getPrivateList():Array
{
//trace("getPrivateList "+ m_sessionListSO.data.private_array.length)

return m_sessionListSO.data.private_array;
}

public function addUser(vUserObject:Object)
{
//trace("addUser "+vUserObject.session);
if(m_sessionListSO.data.users == undefined) m_sessionListSO.data.users = new Array();

m_sessionListSO.data.users.unshift(vUserObject);

m_sessionListSO.setDirty("users");

}

public function addPublicSessionId(sSessionId:String)
{
//trace("addPublicSessionId "+sSessionId)

if(m_sessionListSO.data.public_array == undefined) m_sessionListSO.data.public_array = new Array();

var tObject:Object = new Object();
tObject.session = sSessionId;

m_sessionListSO.data.public_array.unshift(tObject);

m_sessionListSO.setDirty("public_array");
}

public function addPrivateSessionId(sSessionId:String)
{
//trace("addPrivateSessionId "+sSessionId)

if(m_sessionListSO.data.private_array == undefined) m_sessionListSO.data.private_array = new Array();

var tObject:Object = new Object();
tObject.session = sSessionId;

m_sessionListSO.data.private_array.unshift(tObject);

m_sessionListSO.setDirty("private_array");

}


private function sessionSyncHandler(event:SyncEvent):void
{
////trace("sessionSyncHandler "+event.toString())

var i:int;
for(i = 0; i < event.changeList.length; i++)
{
var pname:String = event.changeList[i].name;
var pcode:String = event.changeList[i].code;
var result:String = new String();
if(pcode == "change" || pcode == "success")
{
result = pname+" - "+pcode+" = ";
//check for change and publish event as sent
if(pname.toLowerCase() == "users" && pcode == "success" )
{
//trace("=========POSTING SENTDATA");

dispatchEvent(new Event(DataContainer.SENTDATA));
}
else if(pname.toLowerCase() == "users" && pcode == "change" )
{
//trace("=========POSTING DATACHANGED");
dispatchEvent(new Event(DataContainer.DATACHANGED));
}

} else if(pcode == "delete")
{
result = pname+" - "+pcode;
}

}


}



}

Array Elements Into One Var
I have an array of numbers (of "string" dataType) for example:
var testArray=["1","2","3","4","5"]

I want to add (concatenate) them into a single variable so the variable would contain the string "12345"

How do I do this? I’m sure it must be fairly simple but I can’t seem to think.

Any help greatly appreciated

Sum Of Array Elements?
Hi, new to this forum so hi to all

I 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){
totalSum+=this[a];
a++;
}
return totalSum;
}

var testArray:Array=Array(5,5,5,5,5,5,5,5,5,5);

trace(testArray.sum());
this gives me NaN

any help most appreciated!

Clear Array?
Hi, anyone know how to clear an array till empty for my next time use?

Thanks..

Clear Array ?
Can I clear all values from an array and not let any of them be undefined. Like reduce the array size length or some thing. I have MC names in the array and need to refer to var’s from the MCs and can’t have any be undefined

Clear An Array?
probably really simply I just don't know the AS but is it possible to clear an array so that it has no values in it? I don't want to delete it, I just want to repopulate it and it's length.

Randomizing Elements Within An Array
I have an array setup as follows :

myArray=new Array("1","2","3","4","5","6","7","8","9","10","11 ","12","13","14","15");

I'm looking for a way to completely randomize the elements within the array so the order is never the same twice, any insight ?

Thanks !

Removing Array Elements
hey all,

just trying to find out if there is a way to remove an element from an array other the just pop method for the last element or shift method for the first element. If I wanted to remove an element somewhere in the middle how would I go about doin that.

thanks for any help,

Jeff

Targetting All Elements In An Array
I am wondering if anyone can help with an array problem that I have been having. I have written a simple script that changes the alpha on six mc. using a counter, which counts to six targeting each mc and then resets to zero . My problem is at one point I want to target all the mc in the array at once and as yet haven’t be able to phrase to script properly. At the moment I have the script working by naming each mc in the array. I have tried “.join” and other variation but no success can any one help?


myArray = new Array();
myArray[0] = _root["one"];
myArray[1] = _root["two"];
myArray[2] = _root["three"];
myArray[3] = _root["four"];
myArray[4] = _root["five"];
myArray[5] = _root["six"];

i = -1;


_root.onEnterFrame = function() {
if (i<5) {
i = i+1;

myArray[i]._alpha = 20;

} else if (i=5) {
i = i=-1;
myArray[0]._alpha = 100;
myArray[1]._alpha = 100;
myArray[2]._alpha = 100;
myArray[3]._alpha = 100;
myArray[4]._alpha = 100;
myArray[5]._alpha = 100;
}
dynabox.text = i;
};

Rearranging Array Elements?
howdy guys-

is there any way... to move around positions of things in an array. for example, when i hit a button, i want this to happen-

I have 6 items in the array (they are #'s and 1 letter, the letter is determined by the first button hit by the user)

and i want the numbers to "slide" from right to left.

So element 1 disappears, element 2 then will "take the place" of element 1, and so on. So the new button indicates what the value of element 5 will be.

if my array (being displayed in a text box) is like:
N 43430

and the user hits the 5, it should become this:
N 34305

hmmmmmmmmm......

thanks in advance

How To Access Array Elements?
hi, i'm currently trying to use arrays for the first time, and i've made a simple array myArray with 50 elements 1, 2, 3... 50. but i encounter a problem that makes me suspect that i don't understand the array concept at all: how can i access the value of an element in the middle of the array?

failed attempt #1: why is trace(myArray[x]) undefined and not simply x?
failed attempt #2: i tried to make a new array with the slicing method (referred to in flash help), like myArray.slice(x,x+1). then i reckoned i could access the element from this new array by the pop or shift method. but where on earth IS this new array, and what's the name of it??
failed attempt #3: an expression like
secondArray=myArray.slice(x);
myVariable=secondArray.shift();
didn't work either.


EXTRA QUESTION (OPTOINAL...) what i'm planning to make is an application that jumps between 50 frames, just one visit in each, in a random order. i will use the array to accomplish this, by deleting one element after each frame is visited, in order to avoid a condition for testing whether a frame has been visited (don't know if this was understandable). am i on the right track by using arrays or is there another/simpler way?

Array Elements In Class
Hi,
Could anyone give me a little advice on what they feel is the best way to include the elements of an array in the arguments of a class. What I'm using it for is to create a drop down menu with an arbitrary number of menu items w/ text in each one. The number of different menu items is listed as an argument, and the text is put into dynamic text boxes on each menu item, but where should I include what the actual text is going to be? In the parameters/arguments section? Is it possible to have an arbitrary number of arguments, as the number of menu items is arbitrary, and the number of text boxes will be too?
Any help would be most appreciated.

Thanks,
aaroneousmonk

Array Elements In Class - What's The Best Way?
Hi,
Could anyone give me a little advice on what they feel is the best way to include the elements of an array in the arguments of a class. What I'm using it for is to create a drop down menu with an arbitrary number of menu items w/ text in each one. The number of different menu items is listed as an argument, and the text is put into dynamic text boxes on each menu item, but where should I include what the actual text is going to be? In the parameters/arguments section? Is it possible to have an arbitrary number of arguments? The number of menu items is arbitrary, and the number of text boxes will be too.
Any help would be most appreciated.

Thanks,
aaroneousmonk

Comparing Array Elements
How can I most efficiently compare array elements? I am using Flash MX.

I have an array of 6 elements and want to compare them to detect when all elements in the array are the same.

Now I am using the code:

if(balls[0].ballNumber==balls[1].ballNumber==balls[2].ballNumber==balls[3].ballNumber==balls[4].ballNumber==balls[5].ballNumber)
{
//then do something
}

This isn't working.

I thought I did get it to work using the following code....but it doesn't seem to be correct all the time.

if((balls[0].ballNumber==balls[1].ballNumber)&&(balls[2].ballNumber==balls[3].ballNumber)&&(balls[4].ballNumber==balls[5].ballNumber))
{
//then do something
}

Any advice would be appreciated.

Thanks!
Alysen

Array Elements In Functions
I'm using FLASH MX and I'm trying to use Array Elements in a function and I'm not sure if I'm going about it correctly

I've set up an Array to store names of movie clips that will be used with the attachMovie() method.

var mcList = new Array(4);

mcList[0] = "null"//nothing
mcList[1] = "whoMC" //movie name
mcList[2] = "whoMCa" //movie name AS Export
mcList[3] = "whoMCnew" //movie name new instance

then, in a frame action I've used the following bit of code:

this.attachMovie(mcList[2], mcList[3], 1);

where:
mcList[2] is the name made for AS Export and
mcList[3] is the new instance name of said movie.

This works fine, the proper movie loads and begins to play. However, once I try to assign one of these array elements to a function, I don't get the results I expect.

this.attachMovie(mcList[2], mcList[3], 1);
mcList[3]._x = 379 //position x axis
mcList[3]._y = 208 //position y axis

The movie does not position itself correctly. If I used the actual movie name in place of the array element, mcList[3], it works fine.

I'm not sure what I'm doing wrong and would appreciate any advice.

Thanks!

Comparing To Elements In An Array
How would i go about comparing a variable to all the numbers in an array?

i thought it might be something like:
if ( var != my_array[0,1,2,3,4...] ) {
...
}

but it doesn't seem to work
any suggestions?

Combining Array Elements
Hey. I'm having trouble combining two Array Elements. I have a very untidy peice of code here, but it's just a small 5 test at the moment so I will clear things up once I get it working. Well basically, I have two for loops. One is running through an array, and the other is just counting from 0 to 4. Well what I want to do, is combine each Array element, with the number produced in my second for loop. Here is the code I am using at the moment:

code: bars = 3;
function callSFX(riff) {
s = new Sound();
s.attachSound(riff);
s.start();
}
for (i=riffs.length; i>=0; i--) {
riffs = ["Tom", "Ob Bass2", "CHH", "C_Snare", "C_Kick", "C_HC"];
for (a=0; a<=bars; a++) {
final = riffs[i]+[a];
final.onRelease = function() {
_root.callSFX(this._name);
trace(this._name);
};
}
}

And these are the values I want to create:

C_HC0
C_HC1
C_HC2
C_HC3
C_Kick0
C_Kick1
C_Kick2
C_Kick3
C_Snare0
C_Snare1
C_Snare2
C_Snare3

Etc...

Addign Up The Elements In An Array
so my array size will always be changing

I need a small script to add up at the elements int he array.

I had this:

for (i=0; i<timeArray.length; i++) {
total = total+timeArray[i]
trace("total = "+total);
}

but it just adds it onto the end of the existing "total" like its a stiong and not numeric,

anyone help?

Arranging The Elements Of An Array
Im trying to figure out how it would be possible to arrange th elements of an array depending on their value. For example
dog[0] = 5
dog[1] = 4
dog[2] = 6
dog[3] = 2
How could i change them arround so it would be
dog[0] = 6
dog[1] = 5
dog[2] = 4
dog[3] = 2


any idea?

Moving Elements From One Array To Another
Hi,
I've been trying to move elements of an array to another.

So from an array "array1" i use the "push" method to add an element to an "array2".


PHP Code:



array1=new Array();
array1[0]="something here";
array1[1]="something else here";
array1[2]="and so on";
//and more elements here

array2=new Array();

var x = random(50);
var select=array1[x];
var plus=1;
var new = _root.stage.attachMovie(select, "newsel",plus)

plus+=1;

array2.push(select);




Here i've been trying to "remove" from array1 the element pushed in array2. Remember that it's a random element so 'shift' or 'splice' methods won't do....

Any idea?

[F8] Array Elements Undefined? A Little Help, Pls.
Hi,
I'm sure anyone here but me can answer this: I have a nested array - of movieclip names, but when I trace the individual elements, it returns "undefined". Why dat? Do the movieclips have to pre-exist before accessing the array?


Code:

// subNav architecture buttons array
var sN_grp0_array:Array = [sN_arc0, sN_arc1, sN_arc2, sN_arc3, sN_arc4, sN_arc5, sN_arc6, sN_arc7, sN_arc8, sN_arc9, sN_arc10, sN_arc11];
// subNav design buttons array
var sN_grp1_array:Array = [sN_des0, sN_des1, sN_des2, sN_des3, sN_des4];
// subNav theArch buttons array
var sN_grp2_array:Array = [sN_the0, sN_the1, sN_the2, sN_the3];
// array of subNav button arrays
var sN_grps_array:Array = [sN_grp0_array, sN_grp1_array, sN_grp2_array];

trace(sN_grps_array[0][1]); // returns undefined
Any thoughts appreciated...

Display Array Elements
hi, i need a script to display element of an array individually.
This is what i have: a dynamic text box and a button to click to show next array element.
[img=http://img135.imageshack.us/img135/5204/dtext4mj.th.jpg]

this is the array I wanna show. one by one. string values.
http://img147.imageshack.us/img147/6955/array7va.th.jpg

currently it shows undefined.
[img=http://img217.imageshack.us/img217/4179/undefine9zn.th.jpg]

can anyone help me with the script? much appreciated.

Push To Array - All Elements The Same
This is stupid. I define an array, I push elements onto it. I check the length of the array. Everything is all dandy since it shows the right number of elements (3). I loop through the array and it has 3 elements of the same! And its always 3 of the last element i pushed onto the array!!!


ActionScript Code:
var files:Array = new Array();

var fileRef:FileReference = new FileReference();
fileRef.addEventListener(Event.SELECT, addFilesToList);

function addFilesToList(event:Event):void {
    files.push(event.target);
}

//This method is run by a button being clicked and the horror begins!
function browseFiles(event:Event):void {
    fileRef.browse();
}

So WTF is going on! Thanks for any help.

Tweening Elements Of An Array
Hello all,
In the below code you will see that I created random little balls (ha ha) onto the stage and pushed them all into an array. My question... how do I get all of the balls to Tween, how do I get the entire array to move.

As you can see in my Tween function I can only get one ball to move with the current code. Any suggestions??


Code:
package
{
import flash.display.Sprite;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.events.MouseEvent;

public class Ball extends Sprite
{
private var myBall:Sprite;
private var theBall:Sprite;
private var myArray:Array;

public function Ball():void
{
myArray = new Array();

for (var i:Number = 0; i <= 28; i++)
{
theBall = makeBall();
theBall.x = Math.random() * 500;
theBall.y = Math.random() * 350;
addChild(myBall);
myArray.push(theBall);
}

trace(myArray);
stage.addEventListener(MouseEvent.CLICK, onClick);
}
private function makeBall():Sprite
{
myBall = new Sprite;
myBall.graphics.lineStyle(1, 0xFF8844);
myBall.graphics.beginFill(0xFF8844);
myBall.graphics.drawCircle(0, 0, 5);
myBall.graphics.endFill();
return myBall;
}

private function onClick(e:MouseEvent):void
{
var myTweenX:Tween = new Tween(theBall, "x", None.easeNone, theBall.x, Math.random() * 500, 1, true);
var myTweenY:Tween = new Tween(theBall, "y", None.easeNone, theBall.y, Math.random() * 350, 1, true);
}
}
}

Adding Elements Of One Array Into Another.
I know this can be done with concat, but why doesn't it work with splice or push? I'd like to be able to insert elements from one array into the middle of another array. Additionally, I'd like to have the changes affect the original array, but concat creates a new array.

ie.

Code:
var n1:Array = new Array();
n1.push(1,2,3);

var n2:Array = new Array();
n2.push(4,5,6);

n1.splice(n1.length, 0, n2)

// n1 = [1,2,3,[4,5,6]]
// n1 != [1,2,3,4,5,6]
Seems strange since all three functions use the ...args for the parameters to add.

Is there a way to use splice or push how I'm intending? Maybe with a for or for each statement to modify the array parameter?

Shortcut For The Sum Of Array Elements?
I have an array of twenty integers, and I'd like to find the sum of all the integers. The obvious way is

ActionScript Code:
var sum:int = arr[0]+arr[1]+arr[2].... //etc.
I'm wondering if there's a shortcut way of adding the elements up? Many thanks.

Matching Array Elements
hi!
I want to matched up the elements of two separate Arrays eg;

ActionScript Code:
country = Array("Ausralia", "Brazil", "Canada", "Denmark", "Egypt");
     capital = Array("Canbera", "Brasilia", "Toronto", "Coppenhagen", "Cairo");
     n = country.length;
     r = Int(Math.random()*n);   
     question = country[r];
     country.splice(n,1);


// button


if(capital[0] == country[0]){   // this is where I'm stuck
    gotoAndStop(2);
}else{
    gotoAndStop(3);
}
what I want is, say the country variable displayed a Country in random and
the user enter the correct city into the input textfield then press on the enter button and somehow they have to match up.I hope it made sense
Here I attached a rough example.

Controlling Array Elements
HI -
I have a mc that plays an FLV. When the video ends AS moves the timeline to another frame where other stuff happens. At that point I want all the video controls to fade and be disabled.
I made an array of all the video controls but I can't seem to get the array of controls to fade or be disabled.
Would someone please help me understand this?
TIA your expertise,
JL







Attach Code

var vidControls:Array = new Array();
vidControls[0] = "playPause_btn";
vidControls[1] = "volScrub";
vidControls[2] = "sndOnOff_btn";
vidControls[3] = "progressBar";
vidControls[4] = "loadBar";
vidControls[5] = "vid";

var i:String;

function fadeControls() {

if (_currentframe == 14) {

for (i in vidControls) {
trace("id:" + i + ", name: " + vidControls[i]); // this works great...
}

// but not this
vidControls.enable = false;
vidControls._alpha = 30;
}
else { // all vidControls are fully functional
}
}

Removing Array Elements
Hello,

Here is what I am looking to do.

I have an animation where there are 10 doors on the first frame. When the user clicks on one of the doors, there is a tween effect and then the user gets to see what is behind that door. Once they see what is there, they click on the screen and they are taken back to frame 1. All 10 doors are movieclips which I have in an array. What I want is to have the length of the array decrease by 1 when the user clicks to go back to the first frame. I tried the delete operator with no success.

Any help would be greatly appreciated!

Thanks

Doug

Getting The Array Elements Of An Object. Am I Doing This Right?
Hello Everyone,

I have created a simple object called car. Within car, I have also created member array. When I run the for loop to get all the props of the object, I have no problem displaying the properties of that object. But I am unable to display the elements of the array within the object. Appreciate your wisdom.

Thanks a lot.







Attach Code

var car:Object = {}; // OBJECT CREATED
car.my_arr = []; // ARRAY CREATED
my_arr.push("SILVER"); PUSHING ELEMENTS IN
my_arr.push("BLUE");
my_arr.push("RED");
car.bodytype = "4drs";
car.classification = "Sprots";
car.maker = "Ferarri";

// FOR LOOP SHOW THE PROPERTIES OF THE OBJECT:

for(props in car)
{
trace(car[props]);
}

//Do I need to write two FOR LOOPS, One for the properties and for the array elements?

// FOR LOOP FOR THE ARRAY ELEMENTS

for(i=0; i<car.my_arr.length;i++)
{
trace(car.my_arr[i]);
}

Help With Elements Getting Lost In An Array.
Hello all. I need a little help figuring something out.

Flash CS3 : AS 1 - 2.


I was messing around with colorTransform and running it through an array of movie clips and somewhere along the way elements of my array started getting lost. Meaning, when i started a " trace (elementArray) " would recognize each element as a movieclip.


Now when i test only elements 1,2, and 5 are recognized as clips and the others come up undefined.


Now the only thing i can think of is the difference in the naming conventions for the mcs (i pulled them from two other files.). but that shouldnt be an issue. I have checked and double checked the instance names and they are correct. Any insight into this would be really appreciated.


Thanks.







Attach Code

//** two variables not necessary but buttonColor will be inserted into the "Settings Frame"
var buttonColor:Number = 333399
var btnColor:Number = Number("0x"+ buttonColor)


//** imports
import flash.geom.ColorTransform;
import flash.geom.Transform;


var colorTrans:ColorTransform = new ColorTransform();

colorTrans.rgb = btnColor;
trans.colorTransform = colorTrans;


//** Movie Clip Array.
var elementArray = new Array()


elementArray[0] = BACK.btnColor_mc
elementArray[1] = RESET.btnColor_mc
elementArray[2] = animScrubber.scrubButton.btnColor_mc
elementArray[3] = _PLAY_PAUSE.btnColor_mc
elementArray[4] = NEXT.btnColor_mc
elementArray[5] = AUDIO_.btnColor_mc
elementArray[6] = TRANSX.btnColor_mc


//** colorSet sets up the color for all color clips in the "elementArray"
function colorSet(){

for(var i:Number = 0; i< elementArray.length; i++){

elementArray[i].clr = btnColor;

elementArray[i].transform.colorTransform = colorTrans;

elementArray[i].colorTransformer = trans.colorTransform

}
}

colorSet();
stop();

Hiding Elements Of An Array?
say you had array that contained a few movie clips, is there actionscript than can hide all the elements within the array from the screen, or do i have to use the ._visible = false for each individual item?

thank you please

Searching Array Elements
Hi,

I am trying to execute a condition to see if a particular value is an element of an array. say something like

if(a== elementOf(idArray)) {

trace("yes");
}

Is there a way to do the above or the only way is to code it to search through the array. Kindly pour in some ideas...

Thanks,
jay

Grouping Array Elements
I have a problem kind of lost it..how to grouping the elements in array into 2 section/or put in 2 new array...

Ok the scenario is :I have several data retrieve from dtbase like in this as code

ActionScript Code:
stop();

var getCusDt:LoadVars = new LoadVars();
var receCusDt:LoadVars = new LoadVars();
receCusDt.onLoad = loadCusDt;

loadBtn.onPress = function () {
getCusDt.usr_name = usrname.text;
getCusDt.sendAndLoad("http://localhost/finalecard/finalecard/getcus.php",receCusDt,"POST");
}

//////////////////////////////////////
function loadCusDt(success:Boolean){
if(success){
info.text = this.message;
for (var i = 0; i<this.items; i++) {
dtCustomize = this["datacustomize"+i];
plotting(dtCustomize);
usrname.text = "";
}
}else{
info.text = this.message;
}
}
////////////////plotting part////////////
function plotting(dt:String){
//trace(dt);
var descriptor:Array = [];
//insert into array..
descriptor = dt.split("|");
//okay the problem is here...how to separate the dt to become 2 section 1 for mymc* and for another 1 is for textholder section...meaning that I can separate into 2 section...
trace(descriptor);
//output --> ,textholder0*29*26*100*100*fifin04*courier new*oxcc0000*18,mymc0*80*101*241*243

}




It means I will get the long string like this from the database

Code:
|textholder0*29*26*100*100*fifin04*courier new*oxcc0000*18|mymc0*80*101*241*243
so my question is how to grouping it just like this

Code:
mcArr = [mymc0*80*101*241*243,mymc1*80*101*241*243]

textArr = [textholder0*29*26*100*100*fifin04*courier new*oxcc0000*18,textholder1*29*26*100*100*fifin04*courier new*oxcc0000*18]
from the long string...

Adding The Value Of Array Elements Together?
ok, i've been completely stuck on this for the past two hours. i just need someone to help point me in the right direction as far as what method to use here.

i have a clip on the stage that is 650px wide. i am placing dynamicaly sized clips on top of that clip. when they are created, their names are placed into an array. I am trying to take the items out of the array, find their widths, and then figure out if the width will be greater than 650 if the next clip is placed down. i'm stuck on the loop.

("track1Clips" is the array i have the clips in) here's what i have
for (i=0; i<_root.track1Clips.length; i++) {
clipName = _root.track1Clips[i];
clipName._width = clipWidth;
}

i want to add all the values of clipWidth together inside the loop to get the width of all the clips together, and then substract that value from 650 to get how big the last clip needs to be. I'm lost as to how to do this. can someone please give me a nudge. any help would be so greatly appreciated.

it's so add to look up help on this cause all i can find is how to add an element to an array, not add the values of the array together

Help XML Array Elements Need To Be Clickable
I have created an application using Flash CS3 and Actionscript 2.0 that uses an XML file to display employees names, photo, and job title. I have also implemented a search feature that allows users to search for names, etc.

When the user executes a search, the results populate a dynamic text field. I would like the users to be able to click on one of the results and have it pull up that persons corresponding photo.

At the moment, users are only able to navigate through photos using a Next and Previous button.

So the question is, how do I allow for individual elements in an array to be clickable links that bring up the data?

Here is what a portion of the code looks like (the function "displayresults" is the function that I need to modify to work, it currently only brings up the last image in the array):


Code:
function DisplayNodes (nodes, field_txt){
field_txt.htmlText = "";
var entry;
var separator = "<br>_______________________<br>";

firstname = [];
lastname = [];
position = [];
photo = [];
listnumber = [];





for (var k=0; k<nodes.length; k++){

firstname[k] = nodes[k].childNodes[0].firstChild.nodeValue;
lastname[k] = nodes[k].childNodes[1].firstChild.nodeValue;
position[k] = nodes[k].childNodes[2].firstChild.nodeValue;
photo[k] = nodes[k].childNodes[3].firstChild.nodeValue;
listnumber[k] = nodes[k].childNodes[4].firstChild.nodeValue;



p = listnumber[k];
//trace(p)
_root.total = nodes.length


entry = "";
entry += "<b><a href='asfunction:gotoresult'>"+ nodes[k].childNodes[0].firstChild.nodeValue +"</a></b> ";
entry += "<b><a href='asfunction:gotoresult'> "+ nodes[k].childNodes[1].firstChild.nodeValue +"</a></b>";
entry += "<br><b>"+ nodes[k].childNodes[2].firstChild.nodeValue +"</b>";
//entry += "<br>"+ nodes[k].childNodes[4].firstChild.nodeValue;

field_txt.htmlText += entry + separator;

firstImage();


}
}

function gotoresult ()
{


picture.loadMovie(photo[p],1)
fn_txt.text = firstname[p];
ln_txt.text = lastname[p];
pos_txt.text = position[p];
picture_num();

}

Hiding Elements Of An Array?
say you had array that contained a few movie clips, is there actionscript than can hide all the elements within the array from the screen, or do i have to use the ._visible = false for each individual item?

thank you please

Searching Array Elements
Hi,

I am trying to execute a condition to see if a particular value is an element of an array. say something like

if(a== elementOf(idArray)) {

trace("yes");
}

Is there a way to do the above or the only way is to code it to search through the array. Kindly pour in some ideas...

Thanks,
jay

_root Array Of Elements
Hi All,
I am trying to find a way to iterate over all of the elements of a MovieClip. Is there a property similar to all[ ] in JavaScript in which you can reference each of the child elements of a MovieClip ?

eg.

for (var i=0; i < _root._all.length; i++) {
  if (_root._all[i] instanceof MovieClip) {
    _root._all[i].stop();
  }
}

dachyon

How To Get A Subtotal Of Elements In A Array?
I need to the subtotal of elements from a Array.

And can I use this subtotal to get that amount of elements out from another array?

am I close to spamming this forum?

Each Array Elements As Parameters? How?
I have an array populated DINAMICALLY with itens that will be properties i´ll maipulate later like:

props = ["prop1","prop2","prop3","prop4","prop5","prop6"]; //extracted properties from a movieclip, for

example

this is defined with a loop (for..in) inside the movie clip that will call a function like:

callbackfunction(parameter1, parameter2, parameter3, and so on...);

I NEED to make the parameters list dinamic cause the callback function will serve for others obejcts!(And this

function will take care about the number of parameters to porcess according to the task)

I´ve tried to pass the array as parameter to see if its reads each element as a parameter individually, but it

didnt.
If I pass the array as the parameter, the function only 1 parameter! The array it self...

I ask:

There´s any way to transform each item from an array into a parameter?
The callback function can receive a dinamic list of parameters, o do i need to define them even if with a null

value??

Thanks in advanced for all;
-db-

Adding (sum) Array Elements
Just started working on a commerce app... price data is being successfully placed in an array within Flash (from mySQL DB), but trying to add two prices together comes out like: 13.5013.50

Seems like Flash isn't recognizing the price as a "Number". Any suggestions?

Pad" Array Elements
hi,
from a text file, i create an array of track/artist titles -

songvars.onLoad = function (){
timespl = songvars.toTimeArray.quicksplit(",");
mp3splt = songvars.toMP3Array.quicksplit(",");
namespl = songvars.toTrackArray.quicksplit("|");
};

i wish to add the namespl and timespl arrays to a track
info listbox component, but in such a way that the individual
elements in the array are padded with spaces - " ", so as the
length of the shortest string element in the namespl array
is made equal to the length of the longest string, I have -

for (var j=0; j<namespl.length; j++) {
myItem2 = new Object();
space = " - ";
myItem2.label = namespl[j]+space+timespl[j];
myItem2.data = mp3splt[j];
aInfo[j] = myItem2;
}
trackinfo.setDataProvider(aInfo);

and the listbox output is -
Jeff Beck - Space for the Papa| * time array val
Jeff Beck - Another Place| * time array val

by adding spaces i would like it to be-
Jeff Beck - Space for the Papa| * time array val
Jeff Beck - Another Place""""""| * time array val

many thanks for any help
jak

How To Clear Array Content
I've try to write information from text file into the array

info:
date,phone,text,message
date1,phone1,text1,message1

I've managed to write the info into the array eg array[i]=phone; array[i+=4]=phone.

However, from time to time there will be additional info and when I write the info into the array, it will append every info found in the text into the array. This had caused duplication and the sequence of data is wrong.

Can someone enlightened how to solve this problem such that when the new info is in the text file, i can append just the new data to the end of array.

Clear An Array Completely?
Hey Guys,

I am currently running this function, I need to know if there is a way to clear the arrays before the for loop, I want the active, unavailable, available, completed arrays to be completely wiped like a fresh new variable before the for loop is run, here is the function:


ActionScript Code:
//===================<sortArrays>
        //Creates all the question pools!
        public function sortArrays():void {
            console("Sorting the Arrays...");
            console("--------------------");
// Clear all the Arrays here
// reset all arrays to blank??
            for (var i=1; i < 81; i++)
            {
                switch(qArray[i])
                {
                    case "not attempted":
                    unavailable[i] = qArray[i];
                    console("Added question " +i+ " to unavailable - "+ unavailable[i]);
                    break;
                    case "browsed":
                    available[i] = qArray[i];
                    console("Added question " +i+ " to available - "+ available[i]);
                    break;
                    case "incomplete":
                    active[i] = qArray[i];
                    console("Added question " +i+ " to active - "+ active[i]);
                    break;
                    case "completed":
                    completed[i] = qArray[i];
                    console("Added question " +i+ " to completed - "+ completed[i]);
                    break;
                }   
            }
        }
        //===================</sortArrays>

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