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




Array Issues



Ok this is what I would like to do:
Take the following array
shuffle it and randomly chose three questions
create a new array push the data and populate my quiz.

Here's my existing code

var maxNQuestions = 3;

questions = [new Question (3,
"at which version of flash were you most stoked on?",
["version 1","version 2", "version 3","version 4","version 5", "version 6"]),

new Question (0,
"when was actionscript such a pain in the ass?",
["version 3","version 4", "version 5"]),

new Question (1,
"are you a regular supporter of flash actionscript?",
["yes","no"]),]


//protoype function
questions.shuffle();

//set up new array
questionsArray = new Array();

//start the random push process
selectQ();

function selectQ() {

for(i=0; i<maxNQuestions; i++){
ranydQ=int(math.random()*questions.length);
questionsArray.push(questions[randyQ]);
questions.splice(randyQ,1);
//check to see if the questions are built
if(i>=3){
//start the build
makeQuestion(currentQuestion);
}
}
}


In theory this should work, but for some reason it's not building the GUI
and not only that when debugging the array questionsArray is undefined.

Why is that, is there a way to get my inital array as posted above?

Gonzone



FlashKit > Flash Help > Flash MX
Posted on: 10-31-2003, 10:06 PM


View Complete Forum Thread with Replies

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

Array Issues...
Greets all. I'm looking for some input on this problem I'm having.

I have 5 frames with different graphics and whatnot in them.

I have an array that randomly sends the player to these frames.

What I need to do is have the player go to each of the 5 frames once, in a random order and never play the same frame twice.

Any hints on how I might achieve this?

Array Issues
I have created two arrays from XML the first array (QuestionArray) contains the second array (AnswersArray). The answers to each question in the XML are:
Question 1
-True
-False

Question 2
-Hartford
-Bloomfield
-New Haven
-Washington D.C

But when I trace the answers in my array I get:

True, False

Washington D.C, Bloomfield, New Haven, Washington D.C

Here's my code:


Code:
function buildQuestionArray() {
_global.QuestionsArray = new Array ()
for (var i=0; i<TestNode.childNodes.length; i++){
curQuestion=TestNode.childNodes[i];
var AnswersArray = new Array();
for (var j=0; j<curQuestion.childNodes.length; j++){
curParts=curQuestion.childNodes[j];
for (var b=0; b<curParts.childNodes.length; b++){
if (curParts.childNodes[b].nodeName==null){
curImage=curParts.childNodes[b];
}else if (curParts.childNodes[b].nodeName!=null){
curImage=null;
curAnswers=curParts.childNodes[b];
}
AnswersArray[b]= curAnswers.childNodes
}
}
_global.QuestionsArray[i] = new Question (curQuestion.attributes.number, curQuestion.attributes.format, curQuestion.attributes.correctanswer, curQuestion.attributes.text, curImage, AnswersArray)
}
makeQuestion (currentQuestion);
ClickTrue (currentQuestion);
}

function Question (numbers, format, correct, Text, Image, Answers) {
this.numbers=numbers
this.correct=correct
this.Text=Text
this.format=format
this.Image=Image
this.Answers=Answers
trace (Answers)

}
[/quote]

Help With Array Issues
I am trying to get the global_xw, and global_xh and put them into and array and then access the array to get the actual image sizes when I click on a thumbnail. How can I do this?


Code:
var myScrollPane:mx.containers.ScrollPane;
myScrollPane.contentPath = 'Holder_mc';
//
this.zoom_out.onPress = function() {
myScrollPane.content.myLoader.scaleX /= 1.5;
myScrollPane.content.myLoader.scaleY /= 1.5;
trace(myScrollPane.content.myLoader.scaleX);
myScrollPane.invalidate();
};
this.zoom_in.onPress = function() {
myScrollPane.content.myLoader.scaleX += 100;
myScrollPane.content.myLoader.scaleY += 100;
trace(myScrollPane.content.myLoader.scaleX);
myScrollPane.invalidate();
};
//
var MAX_WIDTH:Number = 65;
var MAX_HEIGHT:Number = 65;
var mclListener:Object = new Object();
mclListener.onLoadInit = function(mc:MovieClip) {
// set variables to keep the original image dimensions
_global.xw = mc._width;
_global.xh = mc._height;
//trace(xw);
//trace(xh);
// where image width is greater than image height
if (mc._width>mc._height) {
mc._width = MAX_WIDTH;
mc._height = (mc._height*MAX_WIDTH)/_global.xw;
// center image
mc._y = (75-mc._height)/2;
}
//where image height is greater than image width
if (mc._height>mc._width) {
mc._height = MAX_HEIGHT;
mc._width = (mc._width*MAX_HEIGHT)/_global.xh;
mc._x = (75-mc._width)/2;
}
};
//
MyPicVars = new LoadVars();
MyPicVars.load("jetPlane.txt");
MyPicVars.onLoad = function(success) {
if (success) {
var t_mc:MovieClip;
Rc = this["Rc"];
//trace(Rc);
for (i=0; i<=Rc-1; i++) {
t_mc = thumbs.content.attachMovie("thumb_mc", "thumb"+i, i, this.getNextHighestDepth());
t_mc._x = 5;
t_mc._y = 5+(i*80);
// load images into thumbs scroll pane
_root["mc"+i] = new MovieClipLoader();
_root["mc"+i].addListener(mclListener);
_root["mc"+i].loadClip("jetPlane/"+this["pic"+i], t_mc.Container_mc);
//
t_mc.i = i;
t_mc.location = this["pic"+i];
t_mc.onRelease = function() {
// load image into pictures scroll pane
//trace(this.location);
myScrollPane.content.myLoader.contentPath = "jetPlane/"+this.location;
myScrollPane.invalidate();
//trace(_global.xw)
//trace(_global.xh)
img_size = new Array(_global.xw, _global.xh);
for (j=0; j<Rc-1; j++) {trace(img_size[1]);
img_size[j] = j;
}
//trace(myScrollPane.content.myLoader.width);
//trace(myScrollPane.content.myLoader.height);
};
thumbs.invalidate();
}
} else {
trace("not loaded");
}
};

Array Issues
I am trying to create a memory game and am having trouble associating a number from an array with a particular movieclip. In the following code (below) cardsListSorted and cardsListSorted2 are two arrays that are populate with random number from 1-9 with repeats. When I get down to the creation of the "cards"/movieclips I have a problem with the following line of code: _root["Card"+i].picture = cardsListSorted[i];

This line is suppose to associate a number with a given "card". It works the first time through the loop, but then I get "Undefined" entry almost as if the arrays cardsListSorted and cardsListSorted2 had no values later in the array. I know this isn't the case. What's going on?

ActionScript Code:
initGame();
stop();
function initGame() {
    // make sorted list of cards
    cardsListOrdered = [];
    for (i=1; i<=9; i++) {
        cardsListOrdered.push(i, i);
    }
    // shuffle list
    cardsListSorted = [];
    cardsListSorted2 = [];
    while (cardsListOrdered.length>0) {
        r = int(Math.random()*cardsListOrdered.length);
        cardsListSorted = [cardsListOrdered[r]];
        cardsListSorted2 = [cardsListOrdered[r]];
        cardsListOrdered.splice(r, 1);
        //trace(cardsListSorted)
        //trace(cardsListSorted2)
    }
    // create card clips and assign their location and picture
    x = 0;
    y = 0;
    card_switch = 0;
    for (i=0; i<36; i++) {
        if (card_switch == 0) {
            attachMovie("Card", "Card"+i, i);
            //trace(i);
            //trace(cardsListSorted[i]);
            _root["Card"+i].picture = cardsListSorted[i];
            _root["Card"+i]._x = x*60+200;
            _root["Card"+i]._y = y*60+50;
            // move to next card spot
            card_switch = 1;
        } else if (card_switch == 1) {
            attachMovie("Card2", "Card"+i, i);
            trace(i);
            trace(cardsListSorted2[i]);
            _root["Card"+i].picture = cardsListSorted2[i];
            _root["Card"+i]._x = x*60+200;
            _root["Card"+i]._y = y*60+50;
            // move to next card spot
            card_switch = 0;
        }
        x++;
        if (x>5) {
            x = 0;
            y++;
        }
    }
    firstclip = 0;
}
function clickCard(clip) {
    trace(clip.picture);
    // see whether two cards are showing
    if (secondclip != 0) {
        // turn those two cards back over
        firstclip.gotoAndStop(1);
        secondclip.gotoAndStop(1);
        firstClip = 0;
        secondClip = 0;
    }
    // see whether same card was clicked
    if (firstclip == clip) {
        // turn card back over
        firstclip.gotoAndStop(1);
        firstClip = 0;
        // see whether no cards are showing
    } else if (firstclip == 0) {
        // turn first card over
        clip.gotoAndStop(clip.picture+1);
        firstclip = clip;
        // must be one card showing
    } else {
        // turn second card over
        clip.gotoAndStop(clip.picture+1);
        secondClip = clip;
        // see whether two cards match
        if (firstclip.picture == secondClip.picture) {
            // remove both cards
            firstClip.removeMovieClip();
            secondClip.removeMovieClip();
            firstClip = 0;
            secondClip = 0;
        }
    }
}

Array Issues
Is there a way to change an array so that there is no commas in it. i am making a calculator where you have to hit buttons which then gets pushed into an array. then you choose your operator which then goes into the array, then you choose your other numbers and so on.

when your finished it looks something like this:

1,2,3,4,-,1,2,3,4

flash hasnt got a clue what to do with it bcause it has commas in between. is there any way that you can remove them so that flash can calculate the answer?

any ideas?

thanks

AS3 - Issues With An Array
I am getting this error "TypeError: Error #1010" when I try and run this

ActionScript Code:
var wheel:Array = new Array("wheel_mc.yellow_mc","wheel_mc.orange_mc","wheel_mc.purple_mc","wheel_mc.blue_mc");
var n:Number
    for(n=0;n<wheel.length;n++)
        {
          this[wheel[n]].addEventListener(MouseEvent.MOUSE_DOWN, wheelPress);
          this[wheel[n]].buttonMode = true;
}
    function wheelPress(e:MouseEvent):void {
          var t1:TweenMax;
          var t2:TweenMax;
          var t3:TweenMax;
          var t4:TweenMax;
          var countTwo:Number=1;
          for(n=0;n<wheel.length;n++){
              if(e.target.name == wheel[n]){
                 this["t"+n] = TweenMax.to(this[wheel[n]], .2, {glowFilter:{color:0x000000, alpha:.4, blurX:7, blurY:7, inner:true}});
                  countTwo++;
              }
          }   
      }


Can anyone see what it is that could be causing the problem?

Thanks

More XML Issues-array Looping...
The files are here:
*http://www.daveglanzproductions.com...cs-problem1.fla
*http://www.daveglanzproductions.com/xml/pics.xml

The first frame of code sets up the XML and creates an array of thumbnails, and pushes values into a "jpeg_arr":



code: loaded = false;
jpeg_arr = new Array();

picxml = new XML();
picxml.ignoreWhite = true;
picxml.onLoad = function(success) {
if (success) {
parseXmlDoc(this);

} else {
trace('xml screw up!');
}
};
//thumbnails:
//THIS CODE CREATES THE THUMBNAILS BY CREATING TWO
//EMPTY MOVIECLIPS.
function parseXmlDoc(xmlDoc) {
if (xmlDoc.loaded) {
//LENTH OF XML:
_global.xmlLength = xmlDoc.firstChild.childNodes;
this.createEmptyMovieClip("targetClip", 0);
for (i=0; i<xmlLength.length; i++) {
//populate the thumbnails
xmlThumb = xmlDoc.firstChild.childNodes[i];
imagePath = xmlThumb.attributes.thumbURL;
selectedThumb = targetClip.createEmptyMovieClip("tmb" + i, i);
selectedThumb.loadMovie(imagePath);
selectedThumb._alpha = 0;
selectedThumb._y = yPos;
yPos += 52;
//JPEG ARRAY IS CREATED BASED ON THE JPEG ATTRIBUTE IN EACH NODE
jpeg_arr.push(xmlThumb.attributes.jpegURL);
//trace(jpeg_arr);
}
//THIS IS JUST A LOAD CHECKER
if (this._framesloaded >= this._totalframes) {
loaded = true;
} else {
loaded = false;
}
}
}

picxml.load("pics.xml");



On frame 5, the code loads the files and defines a function for onPress. I've tried to add a "next" and "previous" function here, but my syntax is screwy. I could use help:

code:
//IF LOADED, THE MOVIE GOES TO FRAME 6 AND LOADS THE FILES:
if (loaded) {
stop();
//LOOP THROUGH ALL NODES, CHOOSE THUMBNAIL TO PRESS...
for (i=0; i<xmlLength.length; i++) {
selectedThumb = this.targetClip["tmb" + i];
selectedThumb._alpha = 100;
selectedThumb.num = i;
selectedThumb.onPress = function () {
//THUMBNAIL INDEX 0 WILL LOAD BIG FILE INDEX O, ETC ETC:
imageClip.loadMovie(jpeg_arr[this.num]);
}
}
} else {
gotoAndPlay(1);
}

//HELP!
_global.next = function() {
nextNode = [i];
if (nextNode > 1) {
for (i=0; i<xmlLength.length; i++) {
nextNode = i;
nextNode++
imageClip.loadMovie(jpeg_arr[nextNode]);
}
}
trace(nextNode);
}

nextBtn.onRelease = function() { next(); };
//prevBtn.onRelease = function() { prev(); };

//set properties of scroll area:
targetClip._x=3;
imageClip.loadMovie(jpeg_arr[0]);





Thanks!

Array Object Issues...
anyone suggest how i would change the position of an object in an array?...

basically i've 3 bars running across the stage and currently i've got them as 3 individual sprites, but figured their basically the same thing in 3 different position so should really cut down on the scripting and just set them with an array. got up to this stage so far:

code: var band = new Array();

for (var i:int = 0; i< 3; i++) {
band[i] = new Square();
addChild(band[i]);
band[i].width = stage.stageWidth;
band[i].height = 15;
band[i].x = stage.stageWidth/2;
band[i].y = stage.stageHeight/2 + j;
}

just three band 15 pixels height stretching across the stage, but i'm struggling with the y position. i need them to be sthe stage.height/2 then +20, +40 and +60

i cant go down the route of names as it would lead me to that problem of instance names being the same as the variable etc etc, which is well beyond me at the moment, so is there a way i could take the previous sprite's y position and add 20 each time?

thanks

XML And Array Access Issues
I'm learning to work with XML files in Flash, and making some headway. But here's an issue I've come up against hard.

I'm dynamically creating buttons on stage based on the number of certain childNodes; then placing text into these button instances. This works fine. However, I have childNode data related to these buttons. When the user clicks a particular button, text fields will be populated with data related to that button.

I've got all the XML data stored in an array, and naturally my buttons are created using an array. I'm sure there's a way to correlate the info from one array to the other, but I just can't seem to puzzle it out.

Can anyone point in the right direction?

Array And Loader Issues
ok, like alot of people i once was good with actionscript, but alas with 3.0 i am a newbie again. however, i am trying to embrace the new standard, and while i hate that it makes things that used to take me 5 minutes take 30 because i have to research the new methods, i DO understand how as3 improves things and am trying to learn it. so, with that said, heres my problem:

i have a swf file that is intended to load up to 4 swf's from an XML list of 9 files. the container swf loads the XML list into an array, then shuffles the list to create a random order in a new array. it then takes that new array and populates the first 4 entries into mClip_1 thru mClip_4. there is then a timer set up to randomly choose a new item in the array to populate into a randomly chosen mClip.

question number one: is there any way to target the layer that the external SWF files get loaded to? i notice it always seems to go into the top-most layer, which is a problem since i originally wanted to have an additional layer on top of the loaded SWFs that had graphic sectional dividers. if i cant target a layer, is there any way to target a specific blank movie clip like i used to be able to do in AS2?

question number two: is there anyway to remove an array object from the array once its been displayed? id like to ensure that if an item is being displayed, it doesnt get chosen by the randomizer to display elsewhere again as that makes its first instance disappear.

any ideas/help?

Array Length Issues
Whatever i put in for h, tiles at i's length is always 1. tiles' length is correct. Why?







Attach Code

public function level(w:Number, h:Number) {
trace(" Construct: " + w + "x" + h);
tiles = new Array(w);
for(var i:Number = 0; i < w; i++) {
tiles[i] = new Array(h);
trace(" Column " + i + " length: " + tiles[i].length + " =? " + h);
}
}

/* output

Construct: 10x30
Column 0 length: 1 =? 30
Column 1 length: 1 =? 30
Column 2 length: 1 =? 30
Column 3 length: 1 =? 30
Column 4 length: 1 =? 30
Column 5 length: 1 =? 30
Column 6 length: 1 =? 30
Column 7 length: 1 =? 30
Column 8 length: 1 =? 30
Column 9 length: 1 =? 30

*/

[MX2004] Array Issues
I have created two arrays from XML the first array (QuestionArray) contains the second array (AnswersArray). The answers to each question in the XML are:
Question 1
-True
-False

Question 2
-Hartford
-Bloomfield
-New Haven
-Washington D.C

But when I trace the answers in my array I get:

True, False

Washington D.C, Bloomfield, New Haven, Washington D.C

Here's my code:


Code:
function buildQuestionArray() {
_global.QuestionsArray = new Array ()
for (var i=0; i<TestNode.childNodes.length; i++){
curQuestion=TestNode.childNodes[i];
var AnswersArray = new Array();
for (var j=0; j<curQuestion.childNodes.length; j++){
curParts=curQuestion.childNodes[j];
for (var b=0; b<curParts.childNodes.length; b++){
if (curParts.childNodes[b].nodeName==null){
curImage=curParts.childNodes[b];
}else if (curParts.childNodes[b].nodeName!=null){
curImage=null;
curAnswers=curParts.childNodes[b];
}
AnswersArray[b]= curAnswers.childNodes
}
}
_global.QuestionsArray[i] = new Question (curQuestion.attributes.number, curQuestion.attributes.format, curQuestion.attributes.correctanswer, curQuestion.attributes.text, curImage, AnswersArray)
}
makeQuestion (currentQuestion);
ClickTrue (currentQuestion);
}

function Question (numbers, format, correct, Text, Image, Answers) {
this.numbers=numbers
this.correct=correct
this.Text=Text
this.format=format
this.Image=Image
this.Answers=Answers
trace (Answers)

}
[/quote]

Array Issues - Please Help (i'm Doing This For Work)
When I try to do something to a single element in an array, it does it to every element. I'm dynamically populating the array with images that I load dynamically from an xml file.

In AS2, if I had something like: trace(photoArray[i]._x it would trace the x value of each item in the array (if it was in a for loop).

Now, in AS3, if I do trace(photoArray[i].x it treats the array as a single object and it gives me the x value for the entire arrray.

I have the images scrolling left accross the screen, what I need them to do is once they get past the screen on the left side they need to reset and go to the end of the line on the right side of the screen. Right now I'm dealing with 32 images.

How to I get it so I can do stuff to each item individually? It works when I have a mouse over event, or a click event, or a mouse out event... just not with anything else besides mouse events.

Here's all my code:


Code:

package
{
import flash.display.*;
import flash.events.*
import flash.net.URLLoader;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.xml.XMLDocument;
import flash.text.*;
import flash.filters.BlurFilter;
import flash.filters.BitmapFilterQuality;

public class Slideshow extends Sprite
{
public var xmlLoader:URLLoader = new URLLoader();
public var xmlData:XML = new XML();
public var totalPhotos:int = 32;
public var photo:MovieClip;
public var photoArray:Array = new Array();
public var photoSliding:Boolean = true;
public var pageNum:int;
public var textBox:TextField = new TextField();
public var showingText:Boolean = false;
public var imagesLoaded:int = 0;

public var filter:BlurFilter;
public var filter_array:Array = new Array();


function Slideshow ()
{
addEventListener(Event.ENTER_FRAME, onEnterFrame);

xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("issue_xml.xml"));

function LoadXML(e:Event):void
{
xmlData = new XML(e.target.data);
for (var i:int = 0; i < totalPhotos; i++)
{
photo = new MovieClip();
var imageRequest:URLRequest = new URLRequest(xmlData.page[i].attribute("mini_thumb"));
var imageLoader:Loader = new Loader();
imageLoader.load(imageRequest);
imageLoader.x = 150 * (i+2) + (i * 3);
imageLoader.y = ((stage.stageHeight / 2) - (195 / 2));
imageLoader.name = ("" + (i + 1));
photo.addChild(imageLoader);
addChild(photo);
photoArray.push(photo);
}
}
function onEnterFrame (event:Event):void
{
for (var i:int = 0; i < photoArray.length; i++)
{
photoArray[i].addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
photoArray[i].addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
photoArray[i].addEventListener(MouseEvent.CLICK, onClick);
photoArray[i].alpha = .75;
if (photoSliding == true)
{
photoArray[i].x -= 1.5;
}
if (photoArray[i].x < -(150 * photoArray.length))
{
photoArray[i].x += 150 * (photoArray.length);
}
photoArray[i].name = ("photo" + (i + 1));
trace(photoArray[i].x);
}

}
function onMouseOver (e:MouseEvent):void
{
photoSliding = false;
e.target.alpha = 1.25;
}
function onMouseOut (e:MouseEvent):void
{
photoSliding = true;
e.target.alpha = 1;
if (showingText == true)
{
removeChild(textBox);
showingText = false;
}
}
function onClick (e:MouseEvent):void
{
textBox.text = ("Photo " + e.target.name);
textBox.background = true;
textBox.backgroundColor = 0xCCCCCC;
textBox.border = true;
textBox.borderColor = 0xCCCCCC;
textBox.height = 40;
textBox.width = 80;
textBox.autoSize = TextFieldAutoSize.CENTER;
textBox.x = stage.mouseX;
textBox.y = stage.mouseY - 25;
addChildAt(textBox, numChildren - 1);
showingText = true;
}
}
}
}
Also, on the mouse over event, if I do something like: trace(e.target.x) that value never changes, no matter where the image is on screen (it scrolls to the left).

[MX2004] Array Issues
I have created two arrays from XML the first array (QuestionArray) contains the second array (AnswersArray). The answers to each question in the XML are:
Question 1
-True
-False

Question 2
-Hartford
-Bloomfield
-New Haven
-Washington D.C

But when I trace the answers in my array I get:

True, False

Washington D.C, Bloomfield, New Haven, Washington D.C

Here's my code:


Code:
function buildQuestionArray() {
_global.QuestionsArray = new Array ()
for (var i=0; i<TestNode.childNodes.length; i++){
curQuestion=TestNode.childNodes[i];
var AnswersArray = new Array();
for (var j=0; j<curQuestion.childNodes.length; j++){
curParts=curQuestion.childNodes[j];
for (var b=0; b<curParts.childNodes.length; b++){
if (curParts.childNodes[b].nodeName==null){
curImage=curParts.childNodes[b];
}else if (curParts.childNodes[b].nodeName!=null){
curImage=null;
curAnswers=curParts.childNodes[b];
}
AnswersArray[b]= curAnswers.childNodes
}
}
_global.QuestionsArray[i] = new Question (curQuestion.attributes.number, curQuestion.attributes.format, curQuestion.attributes.correctanswer, curQuestion.attributes.text, curImage, AnswersArray)
}
makeQuestion (currentQuestion);
ClickTrue (currentQuestion);
}

function Question (numbers, format, correct, Text, Image, Answers) {
this.numbers=numbers
this.correct=correct
this.Text=Text
this.format=format
this.Image=Image
this.Answers=Answers
trace (Answers)

}
[/quote]

Size Issues Using Multidimensional Array
Has anyone experienced any performance or other problems using large multidimensional arrays with Flash MX?

My project is a cross-platform CD-ROM featuring 2500 images, subsets of which are dynamically loaded depending on user input. The CD must play on a P300 or better system. The plan is to store information about the images in a text file on the CD and to read that information into a nested array at runtime. The array will be sorted and used for navigation.

Plan 1: Put information about ALL images in a single text file ("data.txt"), then sort that information to create a navigation array. So, for example if the user needs to view all images that have a tree in them, the navigation array would be sorted on the "tree" field to create a navigation array.

The array might look like this:
NestedItemArray = [itemName,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
ItemArray = [NestedItemArray0,NestedItemArray1, >>>> and so on to >>>> NestedItemArray2500]

Plan 2: Keep the information organized in separate smaller text files. So, for example if the user needs to view all 400 images that have a tree in them, the variables from ONLY the text file "tree.txt" would be loaded to create the array.

The array might look like this:
NestedTreeArray = [itemName,0,0]
ItemArray = [NestedTreeArray0,NestedTreeArray1, >>>> and so on to >>>> NestedTreeArray400]

So, my questions are:
— Does anyone have experience using large arrays on slow computers (PC & Mac) without performance (or other) problems?
— Does someone have experience with a better way?

Thanks.

Multi Dimensionsal Array Issues (i Think....)
hello all; i'm having some bother, yesterday i wrote a function to parse an xml document (my first major off my own back attempt at coding; my mom would be so proud...) and this morning realised that just tracing the data to the output window is stupid. and pointless. (but very useful for debugging) So now what i'd like to do is pass a second paramater to the function which creates a new array on the _root with a name based upon the paramater i pass it. then i do.... erm... well i know that i want.... i'm not explaining this very well.

ok: say i pass it blog

and the xml to put into this is on loads of levels

i'd want to be able to access information like so:

_root.blog.item[0].title

can anyone help?

x

Array Child Issues: Simple
Here is the situation:
10 X 10 array of objects all children of the same Class. Want to delete selected children out of the array and off the screen.

Here is the code I create to delete selected "(boxes[i].alpha == .5)" objects:

function kaPow(event:KeyboardEvent): void {
if(event.keyCode ==32){
items_txt.text = "kaPow";
for(i = 0; i < boxes.length; i++) {
//lets me know if the object is selected by alpha
if(boxes[i].alpha==.5){
boxes.slice(boxes);
removeChild(boxes[i]);
}
}
}
}

Works the first time around but the second time gives me this error message:

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at bad_test_fla::MainTimeline/kaPow()

Any suggestions?

Array Issues; Removing Movie Clips
Hi,
Using Flash 5: I'd really appreciate if someone could teach me how to keep my movie from slowing down as new movie clips are added. I though that by removing old movie clips as new ones are added the movie would not slow down, but it still does. I think it may be that the array continues growing and the elements from the removed clips are still there; when the script cycles, it loops though the array, but takes longer and longer because it has become very long. Therefore, I think I need to learn how to remove the elements from the array as I remove the movie clip. I tried splice and pop, but think I used them incorrectly -- could not get the movie to keep from slowing. Please help!!

Image Array And Loader Component Issues
im trying to create an array of images and use them in a Loader component. so far ive got this as my code...

SmImgs = ["Images/xpc1.jpg","Images/xpc2.jpg","Images/xpc3.jpg","Images/xpc4.jpg","Images/xpc5.jpg","Images/xpc6.jpg","Images/xpc7.jpg","Images/xpc8.jpg","Images/xpc9.jpg","Images/xpc10.jpg"];
LgImgs = ["Images/xpc1_2.jpg","Images/xpc2_2.jpg","Images/xpc_23.jpg","Images/xpc4_2.jpg","Images/xpc5_2.jpg","Images/xpc6_2.jpg","Images/xpc7_2.jpg","Images/xpc8_2.jpg","Images/xpc9_2.jpg","Images/xpc10_2.jpg"]
IMGList1.contentPath=trace(SmImgs[0])
MainIMG.contentPath=trace(LgImgs[0]);

it would b even better if i could make it just make the array out of watever was in a certain folder...
any help?

[FMX04/F8] XML->Array->DataGrid... Column Issues...
First post here - believe me I searched high and low before asking this question...

I know a similar question has been asked many times before but I have a datagrid that is fed from XML that is pushed to an array. the XML contains an <id> tag for each firstChild.childNodes. The dataprovider for the grid is the aforementioned array.

Without overly complicating my explanation, I've taken all the paths to each child node and assigned it to a variable. I then just created an array and pushed each variable to it. The end result is that the datagrid shows only the information from the XML that I want it to show. I use a listener event to track when a user clicks on any row in the datagrid, at which point it captures the value in that child's <id> tag (a numerical value) and assigns that to a new "currentID" variable.

I then loop thru the original XML object searching for an <id> tag == currentID. This is working sweetly. When it finds the corresponding ID tag, it takes the paths to the other node info I want and sets it to some more variables. I then just info1.text = variable A, info2.text = variable B, etc.

Now I'd like to hide the <id> column from displaying in my datagrid. Problem is, when I remove it from the array, i no longer have a ID value to reference to go digging thru my nodes again after the fact. I guess I don't really mind it, but it's not something I really want in the grid. Tried the width thing - no luck. I need the ID info to load TO the drig, just not be displayed. If it doesn't make it to the grid, I have nothing to reference.

Any suggestions on keeping the ID column from displaying without throwing my reference out the window?

Also, how does .width() work? I mean, I know you just specify getColumnAt(-column index-).width = a given amount of pixels, but when I try and set the width of one column how do I know what other columns will be impacted? If you set one column width, do you need to go specify them ALL?

Sorry for the long winded post. Hope to get some answers though. Seems most other AS/Flash forums are nothing but repositories for unanswered questions.

v/r,
Steve

Issues Targeting Movie Clip Names Through An Array
HELP! this is driving me crazy.... I'm simply trying to target an array of movie clip instances, but cannot seem to get it right. The names placed directly on the root work, but not the ones that are placed inside a separate clip imported via loadMovie & named "additionalRow"?!

here is the code:

var instanceArray:Array = [additionalRow.FalconsMC, additionalRow.SeahawksMC, VikingsMC, additionalRow.PanthersMC];
var arrayLength:Number = instanceArray.length;
for (var i:Number = 0; i<arrayLength; i++) {
//this.additionalRow.instanceArray[i].tween("_alpha", 50, 1, 0);
this.instanceArray[i].tween("_alpha", 50, 1, 0);
}

any help would be greatly appreciated.

Loading Movie IsSues And Other Issues
i have a main movie and i when an name is cliked on the navigation bar i would like the new movie to load. so there are seeral issues i am having..

1. i am not sure if i am doing this correctly - i am trying to use tutorials.
2. when i load the "services" movie my text will not show up either.
3. i need help by some one that has a lot will be nice i am in a learning phase

CAN SOME ONE PLEAE HELP

THIS IS THE LINK - GIV EIT AINUTE I HAVE NOT PUT ANY PRELOADERS UP YES. I CAN SEND THE FLA FILES FOR MORE HELP

Array, Array HELP - Importing A External File Into N ARRAY - Almost There
I am reading and external file with the following code:

ActionScript Code:
on (release, keyPress "<Enter>") {
lv = new LoadVars();
lv.onLoad = function() {
questions1 = this.filelist0.split(",");
answers1 = this.filelist1.split(",");
for(i=0;i<questions1.length;i++)
//trace(questions1[i]+"   "+answers1[i]);
trace(questions1[i]);

//assumes same number of scores in each list
};
lv.load("questions.txt");
}


When I parse the file it puts it into an columar format as it should...however I need it to look like this:

questions1=new Array ("2+4=?","What is the capital of Illinois?","What color is the sky?","10x(5+2)=?");

answers1=new Array ("8","springfield","blue","70");


How do I do that?

Text file look like this:

&questions1=2+4=?,What is the Capital of Illinois?,What color is the sky?,10x(5+2)=?")&
&answers1=8,springfield,blue,70&

Browswer Size Issues + New "FlashObject" Detection Kit Sizing Issues
Hi,

After a few years of trying to learn Flash there is one aspect that really still remains a grey area to. What size to publish a movie.

Do I look to make my movies a set size on publishing – by using “Match Movie” & if so what should that set size be – 800 x 600?

I know of 3 other ways to get round the browser size issue

1.) Use the “Stage Object” in conjunction with onResize to allow some clips to fill a screen while keeping others to a set size.
2.) Ascertain a users browsers size & direct them to an appropriate version of your site.
3.) Scale your movie according to an ascertained browser size so if the movie was designed @ 1020 x 760 & the user has an 800 x 600 you scale the main movie accordingly using x & y scale.

The problem has been somewhat complicated for me by the introduction of Geoff Stearns brilliant “FlashObject” detection kit. With that you have to specify the size of the element that the Flash movie will load into & also set a fixed size for the Flash movie. From what I can see this will cut out the option of publishing a movie @ 100% & resizing or not resizing using the stage object.

Could someone please advise me of what is best practice as far as sizing is concerned.

Loading Issues & FLV Issues
Sooo, I've finally, after fours days (including two on the weekend), managed to build a .swf that will play FLVs within the Crisp Template....however, I have come across two problems:

1. the FLVs continue to play when you click on other menu items. How can I stop the FLV from playing with a command from the _root timeline to a timeline in a completely different swf? and where would that code be placed within the menu button actionscript?

2. I'm using Actionscript 2.0 and the FLV Behaviors "Set Video List" option. The FLVs are loaded dynamically, but I only want them to load upon request, otherwise it takes 10 minutes to load the page due to the number/volume of FLVs. Is there a way to code the "ready" event handler so that it doesn't fully load? The code I currently have in is:
// Set a 'ready' event handler to load the videos
videos.ready = function( evt:Object ):Void
{
if(!this.loaded){
this.loaded = true;
for( var n=1; n<this.list.length; n++ ){
if( videos.list[n].indexOf(".flv") != -1 ){
m.activeVideoPlayerIndex = n;
m.contentPath = videos.list[n];
this.length++;
}
}
m.activeVideoPlayerIndex = 0;
}
}
m.addEventListener("ready",videos);

// End Set Videos Behavior

What needs to change to make this happen?

Please see: http://www.kimiporter.com/hydeparktest/ to witness both errors in action

Pls Help: Need To Create New Array Taking 3 Random Entries From An Existing Array
Hello

I have a 2d array:

qTeeth[1] = [How many teeth do we have?, 1-10, 11-20, 21-30, 11-20]
etc.

It goes [question, option1, option2, option3, real answer]

I now just want to extract 3 or so of these entries and create a new array with them. Since I want to just use 3 or so questions randomly from a large array of questions.

Does anyone know a good tidy script to do this with??


Thanks in advance,
Ben.

If I Type Array[1]=array[2] Their Values Are Permanently Linked. How Do I Change This
e.g.

Code:
array[2][0] = 4;
array[1] = array[2];
array[1][0] = array[1][0] + 3;

trace("array[1]= " + array[1]);
trace("array[2]= " + array[2]);


Result:
array[1]=7;
array[2]=7;


The result I want is:
array[1]=4;
array[2]=7;




How do I achieve this?

Array Text Into Textfield And Creating New Line For Each Array Element
I have an array called dropTarg1 which stores dropped-in items.

I want to loop through this array and in a textfield, display each array item on a new line of this text field

I think I need to use something like Array.join("/n") but I can't get it working properly. I hope that the /n would create a new line of the text field called reviewBoxContentText.

for(var i:Number = 0; i<dropTarg.length; i++){
with(reviewBoxContent.reviewBoxContentText){
autoSize = true;
text = dropTarg1.join("/n");
}
}

All that is happening though is that the text field displays on a single line with /n in between each array element.

Calling A Function With An Array Variable As Arguments Is Resetting Array?
I'm going to post the full code of the two functions, disregard the "fluff" unrelated to the two functions as it is all working flawless, I've tested this HEAVILY and cannot understand why it keeps setting the entire array to undefined!

Any help would be grateful.

ActionScript Code:
// processReplace Function    function processReplace(transferFiles) {        var processArray:Array = transferFiles.slice();        var fileName:String = new String();        var filesArray:Array = new Array();        var replaceArray:Array = new Array();        var exists:String = new String();        var error:String = new String();        var promptResult:String = new String();        // Check        for (i=0; i<processArray.length; i++) {            // This is where it bugs up            <b>exists = processSearch(transferFiles[i][1]);</b>             if (exists == "replace") {                replaceArray.push(processArray[i]);            } else {                filesArray.push(processArray[i]);            }        }        // Prompt        if (replaceArray.length>0) {            error = "Replace "+replaceArray.length+" item(s):

";            for (i=0; i<replaceArray.length; i++) {                error += " - "+replaceArray[i][1]+"
";            }            promptResult = mSystem.messageBox(error, "Replace Existing Files?", 4);        }        // Action                  if (promptResult == "NO") {            transferFiles = filesArray;        } else if (promptResult == "YES") {            transferFiles = filesArray.concat(replaceArray);        }        processTransfer(transferFiles);    }

The processSearch

ActionScript Code:
// == processSearch Function    function processSearch(sentInfo) {        for (i=0; i<_global.boxFiles.length; i++) {            if (_global.boxFiles[i] == sentInfo[1]) {                return "replace";                break;            }        }    }

Basically it's supposed to check to see if the file exists and return as true if it does and add it to a replace array, then the replace array is processed into a single string and put into a dialog box through the flash wrapper prompting them to "replace the files or not".

It makes the replace array just fine, it actually even has the right "count" in it but it's setting all the "filenames" to undefined because of the exists = processSearch function.

I even tried to make a new array and run the search just from that one and set the values from the old one and it's still failing.

Is it because of the "break" or can anyone figure it out? Iknow it's hard because you can't use the code

ANY Solution ideas are welcome, even if you think it's dumb

Thanks!

Dynamic Array/change Array Size At Run Time
how can i make a dynamic array
so i can change its size at run time
add and delete values fom the array
and his size will change as needed
10X
peleg

Array.splice Works But Array.slice Doesnt?
This should be simple enough. I have an array of objects, and I want to SLICE a piece of the array and assign it to a new array. All of my attempts have failed. SPLICE works, and I could duplicate my original array into a temp array and splice out what I want, but surely slice is supposed to save me this trouble, right?

I'm a bit baffled, but here's the code:


Code:

private function createGlist() {

var glistObj:Glist = this;

xml_object = new XML();
xml_object.ignoreWhite = true;

xml_object.onLoad = function(success:Boolean):Void {
if(success) {
var i:Number = 0;
for (var this_node = this.firstChild.firstChild; this_node != null; this_node = this_node.nextSibling) {
glistObj.thumb_array.push(new Gthumb(glistObj, glistObj.thumb_array_mc.getNextHighestDepth(), this.firstChild.childNodes[i]));

i++;
}

var load_start:Number = 2;
var load_count:Number = 2;
glistObj.thumb_load_array = glistObj.thumb_array.slice(load_start,load_count);
trace(glistObj.thumb_load_array); //no result, no error
trace(glistObj.thumb_array.slice(load_start,load_count)); //no result, no error
trace(glistObj.thumb_array.splice(load_start,load_count)); //outputs [object Object],[object Object]
} else {
//error
}
}

xml_object.load(xml_url);
}

Array Copy Points To Original Array Instead Of Duplicating
Hey all.
Spent a long time trying to figure out what was wrong with my code. Then I remembered about arrays being objects instead of primitive variables. My question is, how can I make a duplicate copy of an Array?

Details:

So this code

PHP Code:




package{
    import flash.display.*
    public class tester extends MovieClip{
        var a:Array = [1,2]
        public function tester () {
            var b = a
            trace (a)
            b.splice(1,1)
            trace (a)
        }
    }
}







results in this output:

PHP Code:




1,2
1







How can i make b an actual duplicate of a, instead of a pointer?

PHP Code:




b = new Array
b = a






doesn't work either.
Thanks!
DHP

Creating Multi-dimentional Array From Single Array
I have an array

myArray=[hello,bye,fred,1,2,3,4,5,6];

I need to convert it to a multi-dimentional array that would look something like below

array1=[hello,bye,fred];
array2=[1,2,3];
array3=[4,5,6];

newArray=[array1, array2,array3];

I am not sure how to split the array can anyone help? myArray.length/3 would give me the number in each of the new arrays but I am puzzled after this?

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?

Array Of Movie Loaders/array Of Image Files
Alright. I'm fairly new to Actionscripting, so if we can somewhat lame out the tech talk to mild to medium I'd appreciate it. what I am trying to do is create an swf movie that will interact with a PHP script. first lets start with saying the PHP script reads the directory that it is currently in and filters out any file that is not a GIF,PNG, or JPG and then it suffes all of this into a URL encoded string and the directory path ,such as :

?pictures=image1+image2+image3+image4&path=http://servername/directoryPath

now i have flash load the variables "pictures" and split the images and stuff those into an array and the directory path of course stays in its own seperate variable. ive gotten this far with no problems.

so what im trying to do now with this info is create a bit of a slide show. I want to take the array of pictures and load those into an empty movie clip displaying each picture consecutively. Ive made several attempts but no such luck. Ive tried to use a for() loop to cycle through the array of pictures loading them into the empty clip. im still very new and rather lost with these objects and class use i. Im sure im probably not using a listener of somesort that i need and what not. I am sorry i am probably not giving enough info for all this. the whole idea of this clip is to be able to display an indefinite amount pictures , so the flash player will not know ahead of time how many pictures till the php script has sent all the names of what is in the directory. this movie needs to be able to dynamically load any images that are in that directory.so any suggestions on what i can do with an array an an empty clip? thank you to anyone who can make suggesions.

How Do I Lope Through Array, Delete Clip And Remove From Array
I have a function that creates an instance of a movieClip and adds it to an array.

In my gameloop I loop through the array and change some values. Now I want a cleanup function that loops through the array, and if the y value exceeds a certain value, I want to delete the clip instance and remove the record in the Array.

Could someone please help me with the syntax for that? I will lay the code out below.

Thankyou







Attach Code

var myClipArray = new Array();

public function createClipInstance() {
var myClipInstance:myClip = new myClip();
myClipInstance.y = 0;
addChild( myClipInstance );
myClipArray.push(myClipInstance);
}


// loop through array and check y value
// if y > 400: Delete clip and remove from array



public function cleanClips() {
for (var n:int = 0; n<myClipArray.length; n++){
if (myClipArray[n].y > 400) {

// DELETE CLIP AND REMOVE FROM ARRAY

trace("this is where I need help");
}

}
}

Generate Random Value From Array 'excluding' The Current Array Value
getting my head round flash (sorta!)...

ok, nearly got this working; i have 11 movie clips on the root timeline and a empty controller movie. what i need to happen is for a random movie clip to play. when it reaches a point in it's own timeline, it sets the playNext variable to true and the controller movie clip works out the next random movie to play.

the problem comes when the controller 'randomly' picks the movie clip thats already playing! then the whole thing breaks...

is there a way that i can say 'generate me a random clip to play from this array 'excluding' the currently playing movie clip'?

any suggestions would be grand.

this is what i have on my controller clip:

onClipEvent (load) {
//define a new array
video_array = new Array();
//list each of the videos
video_array[0] = "zero";
video_array[1] = "one";
video_array[2] = "two";
video_array[3] = "three";
video_array[4] = "four";
video_array[5] = "five";
video_array[6] = "six";
video_array[7] = "seven";
video_array[8] = "eight";
video_array[9] = "nine";
video_array[10] = "ten";
//this is the count of how many elements (videos) are in your array
max = video_array.length;
//set the playNext to true
_root.playNext = true;
}
onClipEvent (enterFrame) {
//if playNext is true
if (_root.playNext) {
//generate a new random video to play
randomNumber = Math.floor(Math.random()*max);
//store the name
randomVideo = video_array[randomNumber];
//tell that video to play
_parent[randomVideo].gotoAndPlay(13);
//record the video we are playing
crntVideo = randomVideo;
//set playNext to false
_root.playNext = false;
}
}

Load Xml Images-->Array-->Duplicate Array: AHAA
Hello Kirupians!
[Summary]
I want to load images from an XML, then store the images inside an array, then duplicate that array into other clone arrays so that I can addChild() copies of the images into stage whenever i want (and be able to change their properties).
Basicly i have to create two duplicates; big_img and icon_image

[SYMPTOMS]
Everything is loaded fine;the big_imgloads and positions correctly, but, when i try to load icon_image the first big_img disappears! as if the new array has hasn't duplicated the original array (as if it's only a shortcut, not a real copy).

The cody thing:

ActionScript Code:
// total images read from XMLvar axiLength=Accessoir.length();// main image container arrayvar axxARR:Array = new Array();// add images to arrayfor (var k=0; k<axiLength; k++) {    var axxLoader:Loader = new Loader();    axxLoader.load(new URLRequest(Accessoir.PHOTO.text()[k]));    axxARR.push(axxLoader);    axxLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, axxLoaded);}function axxLoaded(e:Event):void {    // show big image    if (axiLength==axxARR.length) {        axxShow(0);    }}function axxShow(ID_AXX:Number) {    // duplicate images array    var axxImage:Array=axxARR.concat(axxARR);    // reposition it    axxImage[ID_AXX].x = product_details_swf.axx.x+(axxImage[ID_AXX].width/2)-5.5;    // Add init image to accessoires    axxImage[ID_AXX].name="axxImage";    product_details_swf.axx.addChild(axxImage[ID_AXX]);}// here i got an event listner to a button, once rolle over is triged it // should make small copies of the whole array images and put them on stage//....function rollover_button(ID_AXX:Number) {    for (var i=0; i<axiLength; i++) {        axxCreate(i);    }    function axxCreate(ID_AXX:Number) {        var axxPic:Array=axxARR.concat();        imageResizer(axxPic[ID_AXX], 50, 50);        axxPic[ID_AXX].name="axxPic_"+ID_AXX;        axxPic[ID_AXX].x=product_details_swf.axx.getChildByName("axxBG_"+ID_AXX).x+axxPicSpacingX;        axxPic[ID_AXX].y=product_details_swf.axx.getChildByName("axxBG_"+ID_AXX).y+axxPicSpacingY;        product_details_swf.axx.addChild(axxPic[ID_AXX]);    }}


[MORE INFORMATION]
I tried array duplication using; concat and slice but not work, it doesn't creat copies of the orriginal array, but just a shortcut to it!

thanx for any tips!

Generate Random Value From Array 'excluding' The Current Array Value
getting my head round flash (sorta!)...

ok, nearly got this working; i have 11 movie clips on the root timeline and a empty controller movie. what i need to happen is for a random movie clip to play. when it reaches a point in it's own timeline, it sets the playNext variable to true and the controller movie clip works out the next random movie to play.

the problem comes when the controller 'randomly' picks the movie clip thats already playing! then the whole thing breaks...

is there a way that i can say 'generate me a random clip to play from this array 'excluding' the currently playing movie clip'?

any suggestions would be grand.

this is what i have on my controller clip:

onClipEvent (load) {
//define a new array
video_array = new Array();
//list each of the videos
video_array[0] = "zero";
video_array[1] = "one";
video_array[2] = "two";
video_array[3] = "three";
video_array[4] = "four";
video_array[5] = "five";
video_array[6] = "six";
video_array[7] = "seven";
video_array[8] = "eight";
video_array[9] = "nine";
video_array[10] = "ten";
//this is the count of how many elements (videos) are in your array
max = video_array.length;
//set the playNext to true
_root.playNext = true;
}
onClipEvent (enterFrame) {
//if playNext is true
if (_root.playNext) {
//generate a new random video to play
randomNumber = Math.floor(Math.random()*max);
//store the name
randomVideo = video_array[randomNumber];
//tell that video to play
_parent[randomVideo].gotoAndPlay(13);
//record the video we are playing
crntVideo = randomVideo;
//set playNext to false
_root.playNext = false;
}
}

Copying Loaded Array Into A Local Array
I'm loading an array through loadVariablesNum (into level 0). The script properly returns array values... I've checked by using text boxes on my stage. But, when I try to store the loaded array within a local Actionscript array for manipulation, it doesn't seem to be able to read the loaded values. It's as if the stage and the frame Actionscript were independent of each other. Can anyone help?

Thanks

Inserting An Array Into An Array To Make It Multidemensional
hi there,
Using an ASP script I've managed to get strings into flash
at the moment the strings come in like this:

array1=data1,data2,data3,data4,data5
array2=celeb1,celeb2,celeb3,celeb4,celeb5

currently I'm doing this:

webfoldercontents = new Array();
webfoldercontens = websubfolders.split(",");

which creats a 2d array. what I need is this:

multidemesionalarray = [array1[array2]]

any help v.appreciated!

Danny

Saving An Array Then Importing Saved Array?
I am creating a kids activity. At the moment I am working on the stamp tool that allws them to stamp a shape in different colours over the canvas... this is working fine, however I need to track the position and colour (and maybe more later) so that the child can save the activity and go back to it later.

So far I have managed to create an array for each propery (_x position, _y position and colour) in seperate arrays as a new stamp is attached it is given a number (1,2,3,4...) and in each array entry of that number are the position or colour properties. When I save these arrays (using FSCommand in Flash5) I think thay form a string in the text document.

When I loads the array from the text document, that looks like this:

&colourArray=255,255,255,16711680,16711680,1671168 0,16711680,16711680,16711680,16711680&XposArray=23 3,420.95,389,262,556.95,674.95,619.95,481.95,458.9 5,280&YposArray=109,167,313,211,301,158,80,105,174 ,451.95

I cannot pull out the data from the arrays (colourArray[2] traces as undefined) What I want to do is a loop based on the lenght of one the arrays that attaches the stamp MC in the correct position and colour.

Hope someone can shed light on this for me... I think I need to find a way to convert the text file data from a string to an array?!?

Cheers
Oll

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.

Tracing An Array :: Sending Array Through JS Proxy
Correct me if I'm wrong, but I thought when you traced an Array, the output was [object]. For example:
code:
var x = new Array();
x.push("one");
x.push("two");
x.push("three");
x.push("four");
trace(x);


Would output: [object Object], not the array as a comma delimited string, correct?

Having a problem where I'm passing an Array to a JS function throuh the JS proxy (flash-javascript kit) and JS picks it up as a string.

How To Duplicate Array?Array.slice() Can Not Work
I test it, and Array.slice() can not work.

var arNew:Array = new Array();
var arOld:Array = [
{checked:0},
{checked:0},
{checked:0}
];

arNew = arOld.slice();
for(var i = 0; i < arNew.length; ++ i)
{
arNew[i].checked = 1;
}

for(var i = 0; i < arOld.length; ++ i)
{
trace(arOld[i].checked);
}

It seems that "arOld" had been changed and "arNew" is not a copy of "arOld", but a reference of "arOld".

How should I copy a array?

thanks for any help

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

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

Random Array, Array Name Selected Randomly
Random Array, Array Name selected Randomly

Here is the code:

var RDNumber2x:Array = [2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36, 38,40];

var RDNumber3x:Array = [3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54 ,57,60];

var RDNumber4x:Array = [4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,7 2,76,80];

var RDNumber5x:Array = [5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85, 90,95,100];

var RDNumber6x:Array = [6,12,18,24,30,36,42,48,54,60,66,72,78,84,90,96,102 ,108,114,120];

var RDNumber7x:Array = [7,14,21,28,35,42,49,56,63,70,77,84,91,98,105,112,1 19,126,133,140];

var RDNumber8x:Array = [8,16,24,32,40,48,56,64,72,80,88,96,104,112,120,128 ,136,144,152,160];

var RDNumber9x:Array = [9,18,27,36,45,54,63,72,81,90,99,108,117,126,135,14 4,153,162,171,180];

var RDNumber10x:Array = [10,20,30,40,50,60,70,80,90,100,110,120,130,140,150 ,160,170,180,190,200];

var RArray:Array = ["RDNumber2x","RDNumber3x","RDNumber4x","RDNumber5x ","RDNumber6x","RDNumber7x","RDNumber8x","RDNumber 9x","RDNumber10x"];

var RArrayBox:String;
var RArrayBoxS = 0;


RArrayBox = RArray[Math.floor(Math.random() * RArray.length)];


RArrayBoxS = RArrayBox[Math.floor(Math.random() * RArrayBox.length)];


trace(RArrayBoxS);

Heres The error:

ReferenceError: Error #1069: Property 6 not found on String and there is no default value.
at randomarray_fla::MainTimeline/randomarray_fla::frame1()

What I am trying to atchieve is randomly selecting the array name and then randomly selecting something from that array.

So I am randomly selecting from a randomly selected array

Can anyone help with my problem?

Assigning Array Objects To Variables In An Array
how do i take an array with objects [orange, red, yellow, green, blue] and assign them to another array 5 random variables named [Slot1, Slot2, Slot3, Slot4, Slot5]

so i can get results such as

Slot1 = color*
Slot2 = color*
Slot3 = color*
Slot4 = color*
Slot5 = color*


thanks !

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