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




Passing Javascript Arrays To Flash Array? PLEASE HELP ME DEAR GOD



is there a way to create an array (in javascript), and pass it to an array in flash? everytime i try, it gets to flash as a string of values, not as seperate values, each in it's own array slot.


thanks - matt



FlashKit > Flash Help > Flash ActionScript
Posted on: 10-25-2001, 03:59 PM


View Complete Forum Thread with Replies

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

Passing Array Variables Into Functions (and Why I'm Hopeless At Arrays)
OK, I have spent a day on this now and have done some fairly extensive searching online. The problem is - I am hopeless with arrays (and probably just actionscript generally for that matter)

I want to create an array of buttons, so I set up an array of actions, step through each item and then try to pass that array action into an onclick button for an attached button

The problem I have is that the onclick function ALWAYS returns the last item in the array.

Help!

Code below:

----------------------------------------------------------------







Attach Code

//set up array
var myArray:Array = new Array("action1","action2","action3");
// for each item in the array
for (var i:Number = 0; i < myArray.length; i++) {
var myArrayNode = myArray[i];
myArrayIndex = i+1;
var myButton:MovieClip = attachMovie("workIndexBtn", myArrayIndex, this.getNextHighestDepth());

//ignore -- offset each button by 100px
myButton_x = myArrayIndex*100;
myButton._x = myButton_x;
//end ignore

//action button for each item in the array with correct action
myButton.onRollOver= function() {
trace(myArrayNode); //always returns action3
};
}

Passing Arrays Into Flash
Hi,

Is there a simple way to pass an array into Flash?

I have a database that I want to query.
I need the results of the query passed into an array in Flash.

I'm using Flash MX 04, SQL DB, and ASP.

My Process is currently as follows:

I've got a DB in SQL with data.

I'm using ASP to query the database and return the results.
In asp, I'm formatting a string of variables -
&item1=a|b|c&item2=d|e|f&item3=g|h|i and so forth

In Flash I'm using LoadVariablesNum and pointing to the asp page.
I parse the string so that item1's data will be in array[0], item2's data will be in array[1] and so forth.

The data to be passed into flash is a bit long so the strings are quite long.

Is there an easier way to do what I am doing?

Thanks.

Passing Arrays To Flash From PHP
Hi

I need to let my admin guy enter dates into external files for my calendar in my swf to load onto an events calendar.

The events calendar is actually more of a timeline, and these dates will place dots on the timeline.

Any ideas on the best way to do this??

Thanks a lot,

Chris
http://emma.dar.cam.ac.uk/~cdj21/smrtj/aru

Passing Arrays Back To Flash
Hi All,

I am currently using PHP to retrieve content from a database dynamically, I have been successfull in generating basic text content and then displaying it in the swf, now I need to pass data back to Flash so that Flash recognises it and puts it in array...

Ive tried passing the data back as:
- stores[0]=bla bla abla&stores[1]=blalblablba
- stores=blablablbla&stores=blablabla

but they dont work...

Is this possible?

Thanks,
Craig

Arrays: Searching An Array In Flash... Syntax?
Trying to do something like PHP where you can take a value and search an array for that value. How can I do this without a loop?

Dear Flash God, HELP
Okay, I'm tired and a bit out of sorts, so I'm coming here for help. I've got a little fishy that wants to swim all round the screen, following the mouse, but he really wants to change directions. He's really liking swimming left to right, but when the mouse goes right to left, he's going backwards. He wants to swim up and down and all sorts of neat tricks. How can I get the little guy to change directions? It's probably really simple, but I'm not thinking clearly at all. I want to maybe include a little change to direction animation so it looks as if he's really turning, too.

Oh, help, please?

Here's the script for the following of the mouse. What do I need to add?

onClipEvent (enterFrame) {
// x movement
mx = _root._xmouse;
if (mx<_x) {
dx = _x-mx;
} else {
dx = mx-_x;
}
moveSpeedx = dx/10;
if (mx<_x) {
_x = _x-moveSpeedx;
} else {
_x = _x+moveSpeedx;
}
// y movement
my = _root._ymouse;
if (my<_y) {
dy = _y-my;
} else {
dy = my-_y;
}
moveSpeedy = dy/10;
if (my<_y) {
_y = _y-moveSpeedy;
} else {
_y = _y+moveSpeedy;
}
}

Array Passing From Flash To ASP
Hi,
how do i pass an array from flash to ASP...

thanks,
shilps

Passing PHP Array To Flash
Hello,

I have read several of the threads regarding this and am still thoroughly confused! I'm proficient in PHP, but Flash and AS are TOTALLY new to me - so I'm feeling out of sorts.

I am trying to generate a small dynamic text block in Flash that will house an array of text received from a PHP file. Thus far, the PHP file is a-ok and looks something like this:


PHP Code:



$eventsQuery = "SELECT * FROM events_tb ORDER BY eventID DESC LIMIT 5";
                                    $eventsResult = mysql_query($eventsQuery);
                                    echo "events=";
                                    
                                    while ($eventsRow = mysql_fetch_array($eventsResult))
                                    {
                                    echo "<a href='content.php?fcn=events&pieceid=".$eventsRow['eventID']."'>".$eventsRow['eventName']."</a>,";
                                    } 




I did this based on the need to seperate the strings using commas or some other indicator.

Here's what I have for the ActionScript:


Code:
var select_lv:LoadVars = new LoadVars();

select_lv.send("flIndexEvents.php", "newwin", "GET");
At this point, I am at a complete loss as to how to populate my dynamic text box (lets call it 'eventsText') with the text generated above. Incidentally, the text being passed are links to other pages in the site that contain details regarding the event. This little block would be situated on the home page like a little marquee.

The good news is that I know I'm connecting to my file correctly as the window is appearing. I simply am at a loss as to how to display the string in the dynamic text window.

Any assistance would be very much appreciated!

Help Passing An Array From Flash To Php
Hi everyone,

I'm majorly struggling passing an array to php from flash in AS2. This is exactly what I need to send...


container[qc][PIC1] = "PIC1"


pls. note that this array refers to an array in PHP. how do I do it? I keep getting errors. any hep is greatly appreciated, thanks.

Help Passing An Array From Flash To Php
Hi everyone,

I'm majorly struggling passing an array to php from flash in AS2. This is exactly what I need to send...


container[qc][PIC1] = "PIC1"


how do I do it? I keep getting errors. any hep is greatly appreciated, thanks.

Passing An Array In Flash To PHP
hello all!

im can retrieve information from a php script and make use of it in flash. however, i seem to be having some trouble doing the opposite transaction.

i need to take an array of emails ive built in flash and pass it to a php script.

i tried passing the array $email_array which shows up in php like this email1@email1.com,email2@email2.com

and splitting it like so: $email_array = split($email_array, ",");

but...it doesn't seem to work

anyone know what im doing wrong here

thanks

Passing Array From Php To Flash
Hello,

i am bussy making a site in flash that show different collections of art items, now i want to pass php arrays with info like price, category, name, collection and so on to flash so i can use arrays in flash. it is a bit to havy to pass those items in string form.

does anybody know how i can pass php arrays to flash/actionscript.

manu thanks

Passing A Flash Array To Html
Hey everyone,

When I click on a button in my FlashMX application, I want it to open an HTML page, and fill the table on this page with the content of an array in my Flash application. Is there any way to pass an entire array from Flash to another HTML page?

Thanx in advance

Passing A Array From An Asp Page To Flash
How would I pass an array from an asp page to a flash file?

Dear Lord, Flash Is Stupid...
Ok originally, I have this:on (release) {
_root.current = 104;
if(this==_level0.nav.contenus.nav.style.sub){
this.container2.contenant.output.text = eval("_root.smenu"+1+"texte");
}
}

which loads a text into "output". It works great. Now I have to load an image in another movie clip. So I add the line

loadMovie(_root.smenu1image,this._parent._parent._ parent.introSwf);

So it loads the image but the text that line 4 loads disapears...why???

Passing Array To Lotus Domino / Javascript... From Flash Mx?
Passing Array to Lotus Domino / Javascript... from flash... I using Lotus Domino I already know how to pass a string from flash to Lotus but using the same method for a Array is not working... any Ideas???

Thanks,
Carlos

Passing Arrays
I wrote a class that requires an array of sprites that it then assembles them into one sprite. In the timeline I instantiated the class and entered the array of sprites as a parameter, but I get an error #1010 "that an object is undefined and has no properties". Can an array be passed as a parameter?

Copying Array Inside Array Of Arrays
Hi,

I've got an array made up of other arrays, and I need to copy one of the arrays to a tempory array (so i can copy it)

I've tried using...

TempArray = ArrayList[0].splice();

but TempArray just shows (in debugger) as undefined, any idea's??

thanks

phil.

Passing Arrays Via HTML Tag?
I know that variables can be set via HTML (such as movie.swf?var1=data&var2=moredata) but is it possible to pass Flash arrays this way?

e.g. movie.swf?array=["data1","data2","data3"]

I can't test at the moment, if anyone else knows or is able to try it can you post a reply please.

TIA

Leon

Passing Arrays Into Functions
Can I pass an array into a function by using a string variable to represent the array? For example:

myArray = new Array();

could myArray be represented as a string?

newValue = "myArray";

function myFunction(array){

temp = array;

trace(temp[0]);

}

myFunction(newValue);


this doesn't work, and I need to be able to pass a an array to a function, but I would like to do it by referencing the array using a string variable. Please help me!

Passing Arrays Into Functions
Ok, I don't think I explained my situation very well. I want to use a string variable of the same name as the array, to pass into a function. I need that string variable to be able to call the array.

I appreciate the help from before, it got me a little closer. I can find a way around, but this would be useful. Here is my code.

function cityPop(string){ // string represents the city's name
// which is also the array name I want to
// extract information from

_parent.city = string[0];// here "string" represents the
_parent.pop = string[1]; // array's name

}

is there some method which will turn the string being passed into a form which will allow it to be evaluated as an array?

Thanks in advance!

Passing Arrays To Functions
I'm having trouble sending an array to a function. Maybe someone could help.

For example:

function makeArray()
{
test =
[
[ "category1","item1","item2" ],
[ "category2","item1","item2" ]
];

displayArray(test);
}

function displayArray(array)
{
trace(array[0][2]);
}


It just displays "undefined"

Thanks in advance.

Passing Arrays Between Classes
how do I create an Object Array in one class and pass it to another class?
if I can't do this, what's the workaround?

Passing Arrays To Packages
I really need to sit down and sort out referencing in packages... it's really holding me back from using them.

Could anyone please explain how a private function in my external package can reference an array declared in a frame script on the main timeline of my fla?

And is this the correct way to um, call(?) my package from a frame script:


Code:
var InstigateNewDock:Dock = new Dock();
It certainly triggers all the traces in the Dock class. Should I perhaps pass the array I want to use here?

Passing Arrays Between Classes;
Hi there,

If I have a multidimensional Array "myArray" in an instance of class A containing a variety of datatypes,
what is the best way of getting this data to an instance of class B? I need the data to be in the same structure, but without maintaining a reference to the original "myArray"?

Is there a way of taking a snapshot of an array in it's current state and then creating a totally new array from it?

I guess what I'm asking is can you clone an array?

Thanks

Passing Arrays As A Variable
So, i'm sure i'm making this harder than it really is, but this is my problem. I have a very simple image gallery and I'm creating next & previous buttons.. I've created an array for these buttons and it works perfectly. the only problem is when i send the output of the array to my function it doesn't recognize it as a variable.

these are the actions for my buttons
nextBTN.onRelease = function() {
++pos;
if (pos>6) {
pos = 1;
}
_root.currentImage = ["image"+pos];
//i'm trying to get the array to output image# as a variable
trace(_root.currentImage);
_root.loadImage();
};
prevBTN.onRelease = function() {
--pos;
if (pos<1) {
pos = 1;
}
_root.currentImage = ["image"+pos];
trace(_root.currentImage);
_root.loadImage();
};
these are in a mc called imageViewerMC
on the main timeline is where i have my loadImage function and it loads my images into the loader component.
function loadImage() {
imageViewerMC.loader.load(currentImage);
}
the variable currentImage is established by each thumbnail button, and there it works fine. i.e. ignore the rest, just focus on the red.
tn1.onRelease = function() {
imageViewerMC.preloader._visible = true;
if (_root.imageViewerMC._currentFrame == 15) {
currentImage = image1;
imageViewerMC.pos = 1;
loadImage();
} else {
imageViewerMC.gotoAndPlay("open");
currentImage = image1;
imageViewerMC.pos = 1;
checking = setInterval(checkLabel, 1000);
}
};
and each variable there is defined before as a url,
so image1="/folder/folder/58980-13890-181.jpg";
image2="/folder/folder/489027-18900.jpg";
so on and so forth.


Like i said the array works fine and when I trace the output of the array i get the correct text "image#" whatever the next image is, but.. here's my problem. loader tries to load that as the url instead of reading it as a variable. when i'm just loading the variable from the thumbnail buttons it works fine, but from the array it doesn't recognize it as a variable. how do i fix this?

Passing Arrays Between Classes
how do I create an Object Array in one class and pass it to another class?
if I can't do this, what's the workaround?

Passing Arrays Between Classes
how do I create an Object Array in one class and pass it to another class?
if I can't do this, what's the workaround?

Passing Arrays To An Jsp File
Last edited by Flexbaby : 2005-02-14 at 05:57.
























Ey all, i have a problem when im trying to parse an array to an jsp file... im Parsing both variables and arrays, and the variables is getting parsed perfectly. When im parsing the array it ses the array as an string/variable and not an array...

im using LoadVars,

ActionScript Code:
var userCreate = new LoadVars();
    userCreate.interessArr = new Array();
    for (i=0; i<interesseArray.length; i++) {
        userCreate.interessArr[i] = interesseArray[i];
    }
   
   
    userCreate.firstname = _root.one.txtholder.firstname;
etc
etc
userCreate.sendAndLoad("user_create_commit.jsp", userCreate, "POST");


Hope this makes sense

Passing Objects With Arrays
i made a dataload class for my flash site which loads a php page and creates an object with arrays in (news, menu, bio, ...).
I can make the dataload object and get the object witth everything in
but from the moment I pass my object from my dataload class to the timeline I can't access the arrays in the object (everything is accessible in the class itself)

I find it strange that I can't pass an object with arrays in it to the timeline in a proper manner


ActionScript Code:
var pierot_obj:dataTous = new dataTous("php/tous_pierot.php");
var alles = pierot_obj.getDataObject();


when i trace alles.mmenu (the array with menu items) i get undefined
but when i trace the same in my dataTous class (dataload) I get the array with menu items

this is how i pass teh object to the timeline

ActionScript Code:
public function getDataObject():Object {
        return xmlDataObject;
    }

Passing Arrays To And From Shared Objects
I have two arrays in my frame 1 root timeline

clips[menu,middle,background,bottom]
colours['0x336666', '0xCC9933', '0x1234cc', '0x1111BB']

When a user clicks on certain buttons it adds colors to the colours array, at specific places

on(release){
colours[1]=0x123456
}

on(release){
colours[3]=0x546534
}

etc, etc

Several buttons will add colour value elements to the array

When the user hits the 'save' button the 'colours' array should be saved on his computer as a saved object (.sol) for the sake of arguments called 'scheme'

When the user returns, the array elements he saved should be loaded into the colours array.

How should I do this?

Passing Images Through Loaded Swf's Via Arrays(FUN)
HI

here is the thing, my company has asked me to amend some code it got which to say is complex is an understatement and will not run when exported as flash player 7

The Brief
To make a fully dynamic swf that can go into a forenamed folder count the amount of jpegs in it import them and fire them into this complex code that makes a magazine. it will be online, and there potentially could be alot of jpegs long download, all jpegs must be fully loaded before entering magazine.

Now the script on Frame 1 to import the images, name them and build an array is...
code:
var count = 0;
var intMaxPages = 20;
var objListener = new Object();
var objLoader = new MovieClipLoader();
var pageOrder = new Array();

objListener.onLoadComplete = function(target_mc){
//pageOrder.push(["page" + count]);
var strSeperator = "";

if (target_mc._url.indexOf("\") > 0){
strSeperator = "\";
} else {
strSeperator = "/";
}

var strPagename = target_mc._url.split(strSeperator)[target_mc._url.split(strSeperator).length-1];

//strPagename = strPagename.split(".")[0];

pageOrder.push(strPagename);

trace("image Loaded for page " + strPagename);
}

objListener.onLoadError = function(target_mc, errorCode) {
trace("Removing move " + target_mc);
target_mc.removeMovieClip();
}

objLoader.addListener(objListener);



while(count<= intMaxPages){
this.createEmptyMovieClip("page"+ count, 10*count);
this["page" + count]._x= 801;
//loadMovie("pageImages/page" + count + ".jpg", this["page" + count]);
objLoader.loadClip("pageImages/page" + count + ".jpg", this["page" + count]);

count++;
}


obviously this is using the MovieClipLoader.loadClip() which is flash player 7 only and as I said before the other code will not run in 7

So.. I exported the "pageflip_empty.swf"as version 6.
After the code above runs through this loader check on frame 2 on an empty movieclip is

code:
onClipEvent (enterFrame) {
trace("check me out man " + _parent.pageOrder.length);
if (_parent.pageOrder.length == undefined) {
_parent.gotoAndPlay(2);
} else {
_parent.gotoAndPlay(3);
}
}


I' ve done this as the images were not loading in time and not populating the array.

The code on frame 3 then loads the "pageflip_empty.swf"

code:
trace("this is the page" + pageOrder);
loadMovie("pageflip_empty.swf", "magholder_mc");

stop();


So we have an swf(Flash player 7)that imports images from a folder, counts how many there are, checks if they are fully loaded and then imports an swf(flashplayer 6)...which then need to import the jpegs via an array called pageOrder via attachMovie!
now if you follow all that WELL DONE!

NOW THE PROBLEM

the array passes through to the "pageflip_empty.swf" but the jpegs that loaded need to be passed/pathed through "pageflip_empty.swf" so that it can be used via attachMovie

please dont tell me to put them in one swf unless you have a piece of code that does all of the above whilst exported in flash player 6



I am totally stuck ANY THOUGHTS WILL BE GRAND!

Problems With Passing Parameters And Arrays---- Please Help :s
Hello everyone!
I'm kinda new to actionscript programming and currently i'm making a very small photo album. in this photo album, i have thumbnails and a main view area. i have actually achieved making it but the coding i have done is not really suitable.. like it's very long.. i'm trying to use arrays to achieve the same task which results in shorter coding.

well first, here is the code i programmed firstly which works perfectly:

ActionScript Code:
///////////////////////////////////////////////
var opened:Object = new Object();
var top:Number;

// "mc1..2..3" are the pictures in the library
// "f1...2...3" are shapes where the pictures are set to their positions/scales

this.attachMovie("mc1","mc1",this.getNextHighestDepth());
mc1._height= f1._height;
mc1._width= f1._width
mc1._x= f1._x;
mc1._y= f1._y;
this.attachMovie("mc2","mc2",this.getNextHighestDepth());
mc2._height= f2._height;
mc2._width= f2._width;
mc2._x= f2._x;
mc2._y= f2._y;
this.attachMovie("mc3","mc3",this.getNextHighestDepth());
mc3._height= f3._height;
mc3._width= f3._width;
mc3._x= f3._x;
mc3._y= f3._y;
this.attachMovie("mc4","mc4",this.getNextHighestDepth());
mc4._height= f4._height;
mc4._width= f4._width;
mc4._x= f4._x;
mc4._y= f4._y;
this.attachMovie("mc5","mc5",this.getNextHighestDepth());
mc5._height= f5._height;
mc5._width= f5._width;
mc5._x= f5._x;
mc5._y= f5._y;
this.attachMovie("mc6","mc6",this.getNextHighestDepth());
mc6._height= f6._height;
mc6._width= f6._width;
mc6._x= f6._x;
mc6._y= f6._y;

//user clicks on the thumbnail to view enlarged picture.

mc1.onRelease= function(): Void {
   
    view("mc1");
};
mc2.onRelease= function(): Void {
   
    view("mc2");
};
mc3.onRelease= function(): Void {
   
    view("mc3");
};
mc4.onRelease= function(): Void {
   
    view("mc4");
};
mc5.onRelease= function(): Void {
   
    view("mc5");
};
mc6.onRelease= function(): Void {
   
    view("mc6");
};



function view (slink:String):Void {
   
       
    if (opened[slink] != undefined ) {
        opened[slink].swapDepths(top);
        return;
    }
    var index:Number = this.getNextHighestDepth();
    var mcPic:MovieClip = this.attachMovie(slink, "mcPic"+ index, index);
    opened[slink]=mcPic;
    top=index;

//mcView is a simple shape where the picture is positioned and scaled on it

    mcPic._height= mcView._height;
    mcPic._width= mcView._width;
    mcPic._x= mcView._x;
    mcPic._y= mcView._y;

}

///////////////////////////////

well.. i hope my comments help you there to understand the code. sorry i'm not very used to commenting my codes lol as i'm new to flash.

as you can see the code "above" is very repetative so i thought i could use arrays to short it down.

the following is the new code i been working on, which partly works. the part that works is the thumbnails.. but when i click on them..nothing happens :s .. i'm not sure how to send an array of parameters to the function "view()"... please help:

/////////////////////////////////////////////////////

ActionScript Code:
var opened:Object = new Object();
var top:Number;
var myPics:Array = new Array("mc1", "mc2", "mc3", "mc4", "mc5", "mc6");
var myArray:Array= new Array(f1, f2, f3, f4, f5, f6);


for (var i:Number=0; i< myPics.length; i++){
var mc:MovieClip = this.attachMovie(myPics[i], "mc"+ i, i);
var mov:Array= new Array (mc0, mc1, mc2, mc3, mc4, mc5);
mov[i]._height= myArray[i]._height;
mov[i]._width= myArray[i]._width;
mov[i]._x= myArray[i]._x;
mov[i]._y= myArray[i]._y;

mov[i].onRollOver= function():Void {
    this._alpha=70;
};
mov[i].onRollOut= function():Void {
    this._alpha=100;
};
///// everything works fine up to here//////////

mov[i].onRelease= function(): Void {

////i'm pretty sure this is where the problem is----->> view(mov[i])
        view (mov[i]);
};

}

//// in here consider --->>slink:MovieClip .... should i be using a diff var type?

function view (slink:MovieClip):Void {
    mcPic.removeMovieClip();
    if (opened[slink] != undefined ) {
        opened[slink].swapDepths(top);
        return;
    }
   
    var index:Number = this.getNextHighestDepth();
    var mcPic:MovieClip = this.attachMovie(slink, "mcPic"+ index, index);
    opened[slink]=mcPic;
    top=index;
   
    mcPic._height= mcView._height;
    mcPic._width= mcView._width;
    mcPic._x= mcView._x;
    mcPic._y= mcView._y;
}

////////////

any small help would be a great help to me.. I'd really really appreciate it

thanks

Passing Arrays With Objects To A Function
I am working with the 3D engine in one of the tutorials, but I am expanding one of the functions to have an Array with objects as a parameter:

Code:
backAndForthAndSideToSide = function (pointsArray:Array) {
var screenPoints = new Array();
for (var i = 0; i<pointsArray.length; i++) {
var thisPoint = pointsArray[i];
if (direction == "left") {
thisPoint.y -= speed;
if (i == pointsArray.length-1 && thisPoint.y<=-150) {
direction = "backward";
}
} else if (direction == "backward") {
thisPoint.z += speed;
if (i == pointsArray.length-1 && thisPoint.z>=150) {
direction = "right";
}
} else if (direction == "right") {
thisPoint.y += speed;
if (i == pointsArray.length-1 && thisPoint.y>=150) {
direction = "forward";
}
} else if (direction == "forward") {
thisPoint.z -= speed;
if (i == pointsArray.length-1 && thisPoint.z<=-150) {
direction = "left";
}
}
With the array:

Code:
MakeA3DPoint = function (x, y, z) {
var point = new Object();
point.x = x;
point.y = y;
point.z = z;
return point;
};
MakeBox = function (Num, Width, Depth, Height) {
_root.createEmptyMovieClip("box"+Num,Num);
Points = new Array();
Points = [[-Width/2, -Height/2, -Depth/2], [Width/2, -Height/2, -Depth/2], [Width/2, -Height/2, Depth/2], [-Width/2, -Height/2, Depth/2], [-Width/2, Height/2, -Depth/2], [Width/2, Height/2, -Depth/2], [Width/2, Height/2, Depth/2], [-Width/2, Height/2, Depth/2]];
for (i=0; i<Points.length; i++) {
Points[i] = MakeA3DPoint(Points[i][0], Points[i][1], Points[i][2]);
}
return Points;

};
this.pointsArray2 = _root.MakeBox(2,80, 80, 80);
box.onEnterFrame = backAndForthAndSideToSide(pointsArray2);
Thank you to any insight you can provide,

Passing Arrays From Text File
Hi all,

Can someone give me an idea on how to do the above? I am able to trace the values but it appears that it is parsed as a big chunk of string like

"apple","orange","pear"

etc

so when I tried to assign the value to an array with:

myArray = [fruits]

instead of becoming:

myArray = ["apple","orange","pear"]

instead of being able to trace(myArray[1]) to yield "orange", I get undefined

really at my wits end so can someone help me?
tks!

Passing Arrays With Objects To A Function
I am working with the 3D engine in one of the tutorials, but I am expanding one of the functions to have an Array with objects as a parameter:

Code:
backAndForthAndSideToSide = function (pointsArray:Array) {
var screenPoints = new Array();
for (var i = 0; i<pointsArray.length; i++) {
var thisPoint = pointsArray[i];
if (direction == "left") {
thisPoint.y -= speed;
if (i == pointsArray.length-1 && thisPoint.y<=-150) {
direction = "backward";
}
} else if (direction == "backward") {
thisPoint.z += speed;
if (i == pointsArray.length-1 && thisPoint.z>=150) {
direction = "right";
}
} else if (direction == "right") {
thisPoint.y += speed;
if (i == pointsArray.length-1 && thisPoint.y>=150) {
direction = "forward";
}
} else if (direction == "forward") {
thisPoint.z -= speed;
if (i == pointsArray.length-1 && thisPoint.z<=-150) {
direction = "left";
}
}
With the array:

Code:
MakeA3DPoint = function (x, y, z) {
var point = new Object();
point.x = x;
point.y = y;
point.z = z;
return point;
};
MakeBox = function (Num, Width, Depth, Height) {
_root.createEmptyMovieClip("box"+Num,Num);
Points = new Array();
Points = [[-Width/2, -Height/2, -Depth/2], [Width/2, -Height/2, -Depth/2], [Width/2, -Height/2, Depth/2], [-Width/2, -Height/2, Depth/2], [-Width/2, Height/2, -Depth/2], [Width/2, Height/2, -Depth/2], [Width/2, Height/2, Depth/2], [-Width/2, Height/2, Depth/2]];
for (i=0; i<Points.length; i++) {
Points[i] = MakeA3DPoint(Points[i][0], Points[i][1], Points[i][2]);
}
return Points;

};
this.pointsArray2 = _root.MakeBox(2,80, 80, 80);
box.onEnterFrame = backAndForthAndSideToSide(pointsArray2);
Thank you to any insight you can provide,

Flash 8 - Trouble Passing Info In Array To Dynamic Text Field On Rollover
Hello,

I am trying to pass information to a many dynamic text fields when rolling over various movieclips that are generated using a loop. I have tried everything I know but can not get pahting to work prpoerly. The rollover works in that the curser changes by does not execute the lines of code within the in line function. Any help is greatly appreciated (see red, bolded text (towards bottom) for problem). the Attached zipped swf is what it looks like as is.

Code:

//how many floors are there in the building?
var floors:Number = 25;
//on each floor starting with the 1st, how many tenants to a floor (0-6)? - all entries must have quotes around them
var tenantAmt:Array = ["1", "1", "1", "6", "6", "6", "5", "5", "5", "5", "5", "5", "4", "4", "4", "4", "4", "3", "3", "3", "3", "2", "2", "2", "1", "1", "1", "1", "1", "1", "1", "2", "2", "1", "1", "1", "1", "1", "1", "1"];
// on each floor starting with the first, how many spaces are vacant (0-6)? - all entries must have quotes around them
var spaces:Array = ["1", "0", "1", "3", "2", "1", "5", "4", "3", "2", "1", "0", "4", "3", "2", "1", "0", "3", "2", "1", "0", "2", "1", "0", "1", "0", "0", "0", "0", "0", "0", "1", "0", "1", "0", "0", "0", "0", "0", "0"];
//change initial x or y coordinate to compensate for more or less floors
var ypos:Number = 550;
var xpos:Number = 50;
// change divider to space floors closer(increase value) or farther apart (decrease value)
var divider:Number = 1.75;
// change the height or width of the floors to compensate for more or less floors
var Xscale:Number = 100;
var Yscale:Number = 100;
var txtypos:Number = ypos;
var txtxpos:Number = xpos - 40;
var sftxtxpos:Number = xpos + 200;
//enter in SF by floor number
var floorTXT:Array = [
["201,265", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2", "5", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"],
["2,405", "5,896", "0", "8,888", "508", "10,891"]];
trace(floorTXT[0][0]);
var sfTextArray:Array = new Array();
for (var i:Number = 0; i < floors; i++)
{
if (tenantAmt[i] == "1")
{
this.attachMovie("single", "nFloor" + [i], i, {_xpos, _y:ypos});
ypos -= this["nFloor" + i]._height / divider;
this["nFloor" + i]._yscale = Yscale;
this["nFloor" + i]._xscale = Xscale;
this.attachMovie("dtext", "dtext" + [i], i + 100, {_x:txtxpos, _y:this["nFloor" + i]._y - 5});
this["dtext" + i].textformatting.text = i + 1;
this.attachMovie("sfText", "sfText" + [i], i + 1000, {_x:sftxtxpos, _y:this["nFloor" + i]._y+20 });
//trace(["dtext" +i]);
}
if (tenantAmt[i] == "2")
{
this.attachMovie("double", "nFloor" + [i], i, {_xpos, _y:ypos});
ypos -= this["nFloor" + i]._height / divider;
this["nFloor" + i]._yscale = Yscale;
this["nFloor" + i]._xscale = Xscale;
this.attachMovie("dtext", "dtext" + [i], i + 100, {_x:txtxpos, _y:this["nFloor" + i]._y - 5});
this["dtext" + i].textformatting.text = i + 1;
this.attachMovie("sfText", "sfText" + [i], i + 1000, {_x:sftxtxpos, _y:this["nFloor" + i]._y +20});
//trace(["dtext" +i]);
}
if (tenantAmt[i] == "3")
{
this.attachMovie("tri", "nFloor" + [i], i, {_xpos, _y:ypos});
ypos -= this["nFloor" + i]._height / divider;
this["nFloor" + i]._yscale = Yscale;
this["nFloor" + i]._xscale = Xscale;
this.attachMovie("dtext", "dtext" + [i], i + 100, {_x:txtxpos, _y:this["nFloor" + i]._y - 5});
this["dtext" + i].textformatting.text = i + 1;
this.attachMovie("sfText", "sfText" + [i], i + 1000, {_x:sftxtxpos, _y:this["nFloor" + i]._y+20});
//trace(["dtext" +i]);
}
if (tenantAmt[i] == "4")
{
this.attachMovie("quad", "nFloor" + [i], i, {_xpos, _y:ypos});
ypos -= this["nFloor" + i]._height / divider;
this["nFloor" + i]._yscale = Yscale;
this["nFloor" + i]._xscale = Xscale;
this.attachMovie("dtext", "dtext" + [i], i + 100, {_x:txtxpos, _y:this["nFloor" + i]._y - 5});
this["dtext" + i].textformatting.text = i + 1;
this.attachMovie("sfText", "sfText" + [i], i + 1000, {_x:sftxtxpos, _y:this["nFloor" + i]._y+20});
}
if (tenantAmt[i] == "5")
{
this.attachMovie("quint", "nFloor" + [i], i, {_xpos, _y:ypos});
ypos -= this["nFloor" + i]._height / divider;
this["nFloor" + i]._yscale = Yscale;
this["nFloor" + i]._xscale = Xscale;
this.attachMovie("dtext", "dtext" + [i], i + 100, {_x:txtxpos, _y:this["nFloor" + i]._y - 5});
this["dtext" + i].textformatting.text = i + 1;
this.attachMovie("sfText", "sfText" + [i], i + 1000, {_x:sftxtxpos, _y:this["nFloor" + i]._y+20});
//trace(["dtext" +i]);
}
if (tenantAmt[i] == "6")
{
this.attachMovie("sex", "nFloor" + [i], i, {_xpos, _y:ypos});
ypos -= this["nFloor" + i]._height / divider;
this["nFloor" + i]._yscale = Yscale;
this["nFloor" + i]._xscale = Xscale;
this.attachMovie("dtext", "dtext" + [i], i + 100, {_x:txtxpos, _y:this["nFloor" + i]._y - 5});
this["dtext" + i].textformatting.text = i + 1;
this.attachMovie("sfText", "sfText" + [i], i + 1000, {_x:sftxtxpos, _y:this["nFloor" + i]._y+20});
//trace(["dtext" +i]);
}
sfTextArray.push("sfText" + i);
if (spaces[i] == "1")
{
this["nFloor" + i].gotoAndStop("one");
}
if (spaces[i] == "2")
{
this["nFloor" + i].gotoAndStop("two");
}
if (spaces[i] == "3")
{
this["nFloor" + i].gotoAndStop("three");
}
if (spaces[i] == "4")
{
this["nFloor" + i].gotoAndStop("four");
}
if (spaces[i] == "5")
{
this["nFloor" + i].gotoAndStop("five");
}
if (spaces[i] == "6")
{
this["nFloor" + i].gotoAndStop("six");
}

}
// how do I write the below code w/o coping/pasting thousands of lines of code and to get the initial alpha properties to work correctly ?
nFloor[i].first1. _alpha = 0;
nFloor[i].second1._alpha = 0;
nFloor[i].third1._alpha = 0;
nFloor[i].fourth1._alpha = 0;
nFloor[i].fifth1._alpha = 0;
nFloor[i].sixth1._alpha = 0;

nFloor0.first1.onRollOver=function(){
this["nFloor"+[i]].first1._alpha = 100;
sfText0.gotoAndPlay("go")
sfText0.mtclip.text=floorTXT[0][0];
trace(_parent.sfTextArray);
}
first1.onRollOut = function()
{
sfText0.gotoAndStop("hold")
first1._alpha = 0;
trace("rollout");
};
second1.onRollOver = function()
{
second1._alpha = 100;
trace("rolled");
};
second1.onRollOut = function()
{
second1._alpha = 0;
trace("rollout");
};
third1.onRollOver = function()
{
third1._alpha = 100;
trace("rolled");
};
third1.onRollOut = function()
{
third1._alpha = 0;
trace("rollout");
};
fourth1.onRollOver = function()
{
fourth1._alpha = 100;
trace("rolled");
};
fourth1.onRollOut = function()
{
fourth1._alpha = 0;
trace("rollout");
};
fifth1.onRollOver = function()
{
fifth1._alpha = 100;
trace("rolled");
};
fifth1.onRollOut = function()
{
fifth1._alpha = 0;
trace("rollout");
};
sixth1.onRollOver = function()
{
sixth1._alpha = 100;
trace("rolled");
};
sixth1.onRollOut = function()
{
sixth1._alpha = 0;
trace("rollout");
};

Filling Array - Passing Array In Function
hello

I'm trying to fill an array then pass it to a function i'm tying to do it that way
but it giving me strange results when I trace things (try it and you'll see):


Code:
////////////////// fiiling the array /////////////////
for (i=1; i<=numberof_player;i++){

pos_array = new Array(numberof_player)
pos_array [i]= i
trace("in array"+pos_array [i])
}

////////////////// pasing array in function //////////////////////



function rolldice( pos_array:Array){
trace(pos_array) /// gives 4,undefined,undefined,undefined,4
}
///////////////////////////////////////////////////////////////////
maybe i'm stupid

Thanks

T

[F8] An Array Of Arrays
I'm loading a number of arrays from a text file. I want each of those arrays to be loaded into another array. The number of arrays may change depending on the info in the text file. How can I dyamically create the array of arrays?

Example:

My textfile

&thisTitle=Clothing - La ropa&
&arr_p1=boots|las botas|las botas|las botas|las botas|Quiero comprar|las botas|negras.|sound1&
&arr_p2=socks|los calcetines|los calcetines|los calcetines|los calcetines|Quiero comprar|los calcetines|blancos.|sound2&
&arr_p3=dress|el vestido|el vestido|el vestido|el vestido|Quiero comprar|el vestido|azul.|sound3&
&arr_p4=swimming suit|el traje de baño|el traje de baño|el traje de baño|el traje de baño|Quiero comprar|el traje de baño|azul.|sound4&

My LV code

lv = new LoadVars();
lv.load("sounds/first.txt");
lv.onLoad = function(success) {
if (success) {
myTitle = this.thisTitle;
p1 = this.arr_p1.split("|");
trace(p1);
p2 = this.arr_p2.split("|");
p3 = this.arr_p3.split("|");
p4 = this.arr_p4.split("|");
}
};

I want to end up with ...

myArray [p1, p2, p3, p4];

...but this array may change based on the number of arrays put into the text file.

Thanks for your help.

An Array Of Arrays?
(Using flash CS3/AS2/3)

The code I have now, (see attached zip link) picks colors randomly from the myColors class.

I want to modify this code so the Class has sets of "myColors" (EG "myColors2", "myColors3") and the fla will pick a random "myColors" array and only use the colors within that array to display in the swf each time it is run. does that make sence?

Ive got this far but cant workout the next bit, which im sure isnt a big step and your help would be most helpful.

Thanks
Chris

Array Of Arrays
Can someone please help me with this. I am trying to make an array of arrays.

ActionScript Code:
var bodytype:Array = new Array;
var gender:Array = new Array;
var allArrays:Array = new Array;

bodytype = [fbody_small, fbody_medium, fbody_large];
gender = ["boy", "girl"];
allArrays = [bodytype, gender];

function hideAll (ev:Event):void{
for (var i:Number = 0; i < allArrays.length; i++) {
        allArrays[i].visible = false;
        trace ("gooooooood");
}
Thanks

Arrays Within An Array
Hi,
how can I read a 2dimensional array.

I have a main_array:
var main_array:Array = Array();
the main_array looks like: [x,x,x,x,x,x,x,x,x,x]

I have a itemA_array, looks like: [A,AA,AAA]

I have a itemB_array, looks like: [B,BB,BBB]

I put the 2 arrays into the main_array:

main_array.splice(2,1,itemA_array);
main_array.splice(3,1,itemB_array);

So far no problem. I load the main_array up with LV to the Database.
It arrives correctly.
The main_array is 10 elements,
itemA is on [2]
itemB is on [3]

The problem:
when I read the data in with LV like:

var main_array:Array = Array();
main_array = this.main_array;

Flash cannot read, that the elements on [2] and [3] are arrays.
Now my main_array has a length of 14 elements, it reads the As + Bs as single elements.
How can I read the 2 item arrays??

Thank you in advance.
Luciewong

Copy Array Containing Arrays
Hi,

How would you, copy an array, that contains other arrays? I think "slice" only works 1 level deep?

thanks
phil.

Sorting Arrays Within An Array
hi there,

I have several values stored in multiple arrays (let's call these 'secondary arrays'). Each 'secondary array' is stored in one cell of another array ('main array'). The structure would look something like this:


Code:
mainArray(secondaryArray(number, textField, textField,...), secondaryArray(number, textField, textField,...), ...)
I was wondering if there was a way to sort the secondary arrays according to one of the values in them (namely the 'number')

Is that possible at all? Any help would be appreciated

Ta

Array Of Arrays, Multidimensionals Maybe?
Hi All,

First time posting, after spending the last week trying to get into actionscript. My question has to do with arrays, specifically, I want to record all mouseup and mousedown actions on the stage, then eventually use the drawing API to draw lines between each down and the following up point. But the current problem is probably more simple:


Code:

var this.ptArray:Array = new Array();

//array will contain [indexnumber:number, connected_to_previous:boolean, _x, _y]

this.onMouseDown = function(){
this.myX = _xmouse;
this.myY= _ymouse;
this.myTempArray = new Array();
this.indexnum = this.ptArray.length+1;
this.myTempArray.push(indexnum, 0, myX, myY);
trace(" myTempArray : "+myTempArray);
this.ptArray.push(myTempArray)
trace(" ptArray : "+this.ptArray);
}
The problem - I can't get my temp array to populate the ptArray. I've also tried changing all of the this.ptArrays to _root.ptArrays, but it still appears empty upon trace?

Thanks,
dialectric

Arrays In One Single Array?
Hi!
is there a way to place arrays in one arrays?
like i got three arrays here, and i want to place them in one array.


ActionScript Code:
var aVisible1:Array = new Array(mcMPR1, mcMPR2, mcMPR3, mcMPR4, mcMPR5);
var aVisible2:Array = new Array(mcMPR6, mcMPR7, mcMPR8, mcMPR9, mcMPR10);
var aVisible3:Array = new Array(mcMPR11, mcMPR12, mcMPR13, mcMPR14, mcMPR15);

//now I want to place all arrays in one array something like
var aAllarraysInOne:Array = new Array(aVisible1, aVisible2, aVisible3);
//but that's not the right way.

anyone who can help?

thanks in advance*

Create Arrays From Array
Hey guys,
tryign to use something liek this:

ActionScript Code:
var section:Array = new Array();section = ["a","b","c"];for(item in section){    _root[item]= new Array{}        }


to create array objects from each item in the 'section' array, basiically giving me

a= new Array;
b= new Array
c = new Array

What am i doing wrong here?!

Combining Arrays To Form New Array
Hi,
I need to create an array by combining 4 others. If I just create the array naming the variable name of the other arrays as the elements, it leaves me with a 4 element array. I need all of the elements of all 4 arrays in the combination array. What is the best way to do this?
TIA,
aaroneousmonk

Can I Make An Array Of Pointers To Other Arrays?
Hi again, I'm building a really cool system to parse through properties of a sports team.

I've gotten quite far, but I have a little peice of code I'd like to optimize.

Basically I have a number of arrays called: "KeyTeam[]", "KeyPlayer[]" etc.
And with each array I need to perform a language logic match based on some entered data.

My question is this: I'd like to make a loop so i can call all the arrays via one function, I thought I'd be "smart" and use a reference array named "lookUpKey" so i can replace the array object name with a pointer to the array. But AS thinks I am inserting a string, and not a pointer to the array... is there anyway to have an array with pointers to another array (object)?

Here is a striped snip of the code I am using:

Thanks!!!


Code:
KeyTeamStr = [];
KeyTeam = [];
KeyPlayer =[];
KeyPlayerStr =[];
KeyWhere = [];
KeyWhereStr =[];
KeyWhen = [];
KeyWhenStr =[];
KeyWhat = [];
KeyWhatStr =[];
KeyVs = [];
KeyVsStr =[];

lookUpKey = new Array ("KeyTeam", "KeyPlayer", "KeyWhere", "KeyWhen", "KeyWhat", "KeyVs");//pointer to actual arrays with these names

lookUpKeyStr = new Array ("KeyTeamStr", "KeyPlayerStr", "KeyWhereStr", "KeyWhenStr", "KeyWhatStr", "KeyVsStr");//pointer to actual arrays with these names

//main logic loop:
for (u= 0; u < lookUpKey.length; u++) {
trace("LOOP:"+u);
trace("lookUpKey[u]:"+lookUpKey[u]);
//the problem is this next line, it thinks these are strings and not my arrays:
stepIntoMatches (KeyString, lookUpKey[u], lookUpKeyStr[u]);
}

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