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




Array And Movie Clip



i want to make an array and set the _x and the _y for each array then make the arrays attach to a movie clip on the stage. here is my code not working

var objects:Array = new Array();
objects.push({x:136, y:247});
objects.push({x:136, y:300});

for(var i = 0; i < objects.length; i++){
attachMovie("box", "box" + i,_x,_y);


}
Box is a movie clip with the linckage set to a instance name called "box"



FlashKit > Flash Help > Flash General Help
Posted on: 09-26-2004, 10:30 AM


View Complete Forum Thread with Replies

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

Movie Clip In Array
I’m wondering if someone could help me with a problem I have with the syntax of an array. I have a script, which uses the array description below. It works fine but I’d like to be a bit more compact with the syntax. This script includes a series of movie clips (that acts as buttons) “1t” through to “15t” into an array.

myArray = new Array();
myArray[0] = _root["1t"];
myArray[1] = _root["2t"];
myArray[2] = _root["3t"];
myArray[3] = _root["4t"];
myArray[4] = _root["5t"];
myArray[5] = _root["6t"];
myArray[6] = _root["7t"];
myArray[7] = _root["8t"];
myArray[8] = _root["9t"];
myArray[9] = _root["10t"];
myArray[10] = _root["11t"];
myArray[11] = _root["12t"];
myArray[12] = _root["13t"];
myArray[13] = _root["14t"];
myArray[14] = _root["15t"];

I would like to write this statement like this’

myArray = [_root”1t”, _root”2t”, etc etc]

However as these are actual movie clip with path names this syntax doesn’t seem to work. I’ve tried a few variations and have checked though submissions on the board, however all the examples I have found deal with values which don’t include path names.

Movie Clip And Array
I have a movieclip Named "Card" which has an objects inside a total of five objects an object per frame and i have a cards=[1,2,3,4,5] array.
My problem is that how would i call these objects and paste it in the scene, using the tag in the cards array.
like if i call cards[0], the tag is 1, the it should call the object in "card" movieclip in frame 1...

thanx :-)...

Movie Clip Array?
Is it possible to put multiple movie clips in one array? So if I have myArray[1] = mov_mc, I can do myArray[1].gotoAndPlay(2) and it will do so.

Movie Clip Array
Hello everybody, I'm a bit stuck but think this should be a fairly easy problem to fix.
I have arranged some movieclip instances on the stage (_root) at author-time and would like to hold them in an array. I can't seem to get the loop at the end of this script to work: Any help would be hugely appreciated.

Basically what want to end up with is a load in animation, by setting the array's visibilty to false initially, then looping through a function to set each indexes visibilty to true, with a setInterval variable so that it dosen't happen too quickly. From there I could add a tween to the loop and fade the array instances in one by one.



shapes = _root["eye1","eye2","nose1","dots1","lips1"];
trace(shapes);

//apply some properties to the array
shapes[_root]._xscale = 50;
shapes[_root]._visible = true;

_root.onEnterFrame = function() {
for (var i:Number =0; i < shapes.length; i++) {
if (shape[_root].hitTest(_xmouse, _ymouse, true)) {
shapes[_root]._alpha = 50;
}
}
};

Movie Clip Array
Hello everybody, I'm a bit stuck but think this should be a fairly easy problem to fix.
I have arranged some movieclip instances on the stage (_root) at author-time and would like to hold them in an array. I can't seem to get the loop at the end of this script to work: Any help would be hugely appreciated.

Basically what want to end up with is a load in animation, by setting the array's visibilty to false initially, then looping through a function to set each indexes visibilty to true, with a setInterval variable so that it dosen't happen too quickly. From there I could add a tween to the loop and fade the array instances in one by one.



shapes = _root["eye1","eye2","nose1","dots1","lips1"];
trace(shapes);

//apply some properties to the array
shapes[_root]._xscale = 50;
shapes[_root]._visible = true;

_root.onEnterFrame = function() {
for (var i:Number =0; i < shapes.length; i++) {
if (shape[_root].hitTest(_xmouse, _ymouse, true)) {
shapes[_root]._alpha = 50;
}
}
};

Hmmmmm. Do I need to load each index into a different depth level???

Alphabet Array Changes Movie Clip
Sorry for the obscure subject, I'm just not sure what to call this post.

Here's what I'm trying to do. Any and all help is appreciated.

I have an input text box where you can type in a text message, say something like "Code dummy".

Flash should then take the individual letters and displays separate movieclips that correspond with each particular letter.

A real world example might be using input text and then having each character then be represented by their chracter in sign language. So you take a series of letters and translate the letters to images that are then displayed in sequence.

Here's how I'd at least try to start something like this:

Build the array. Measure the length of the input text, check each letter versus the array. If letter one = "A" then gotoAndStop("A") on a particular movie clip, repeat for length of input text.

Thoughts or suggestions?

Applying The Value Of An Array To A Movie Clip
i am tring make a graph, by attaching 16 different array values to 16 different movie clips, when that value is attached i want to duplicate the movie that many times 5 pix above the previous one. i am pulling this data via the param tags.

AllData = new array(value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16);


any ideas?

i have combed the forums, but with no luck.

thanks so much!

[MX04] Movie CLip Array?
u guys know that game brickout, alleyway....type game where u move the "ship" and bounce the ball into the blocks.

All all those blocks movie clips. Or is there like an array where i can control all of them at once from one movie clip. AKA. How would i make that game?

XML Into Array To Display Within A Movie Clip
I am having a real problem trying to load XML into a movie clip. It is working fine if I put the Text Box on the main movie, but trying to load it into the movie clip is becoming an issue. Nothing is showing up in the Dynamic Text fields in the movie clip but show up fine in the main movie.

Here is the script, please help!
---------------------------------------------
Script from MAIN Movie

//XML Code
function loadXML(loaded) {
if (loaded) {
genretxt = [];
comments = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++){
genretxt[x] = this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue;
comments[x] = this.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue;
}

else {
trace("Error: File is not loaded!");
}
}

-------------------------------------------
Script from Movie Clip

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = _root.loadXML;
xmlData.load("imagedata.xml");

Array Movie Clip Reference
Hi
I got some movie clips' references in an array as follows:

Code:
var buttons:Array = new Array(architektura_mc, urbanistyka_mc);
These movie clips are nested in a movie called 'menu_mc', so I can reference to them like so:

Code:
menu_mc.architektura_mc.property = value;
However, I'd like to facilitate my array in the following way:

Code:
menu_mc.buttons[0].property = value;
It won't work since when I trace menu_mc.buttons[0], it's apparently undefined. How come?

How Do You Load A Movie Clip From An Array?
if I had:

now = 0;
myMCArray = [_mc1, _mcblah];

and I wanted to put the next one in the array (_mc1) on the stage @ _x=200, _y=200, how does that work?

does the movie clip already have to be on the stage somewhere, or can it just be in the library?

Movie Clip Nested Array
I have an array of movie clips and want to make the clips nested so i can click on them.
..
this.createEmptyMovieClip("mcc"+i,this.getNextHigh estDepth());
..

To make them nested and be able to click on a MC how can I refer to each MC with a button press with array notation eg
How can i code a dynamic size MC button press?

mcc?.mcc?.onPress = function () {
}

Movie Clip Array Not Working
This is the code thats not working can anyone spot my problem?


ActionScript Code:
MovieClip.prototype.setRGB = function(newColor) {
(new Color(this)).setRGB(newColor);
}
blockArray = new Array();
for (i=0; i<4; i++) {
duplicateMovieClip(block,"block"+i, i);
}

blockArray[i] = _root["block"+i];

var XML_var:XML = new XML();
XML_var.ignoreWhite=true;
XML_var.load("http://ipad.com.au/room.php?floor=1");
XML_var.onLoad = function(success)
                 {
                    if (success)
                    {
                      var i;
                      var xmlRooms = XML_var.firstChild.childNodes;
                      for (i=0; i<xmlRooms.length; i++)
                      {
                        var index;
                        var room_no = xmlRooms[i].firstChild.firstChild;
                        var status  = xmlRooms[i].firstChild.nextSibling.firstChild;
                        trace("Room No : "+room_no+"Status : "+status+".");
                       
                        index++;
                        switch (status)
                        {
                           case "Sold"     : block[i].setRGB(0xfe3333);break;
                           case "Reserved" : block[i].setRGB(0xfbf676);break;
                           case "Available": block[i].setRGB(0x6fd961);break;
                        }

                      }
                    }
                    else
                    {
                      trace("LOAD FAILURE!!!");
                    }
                  }

Movie Clip Nested Array
I have an array of movie clips and want to make the clips nested so i can click on them.
..
this.createEmptyMovieClip("mcc"+i,this.getNextHigh estDepth());
..

To make them nested and be able to click on a MC how can I refer to each MC with a button press with array notation eg
How can i code a dynamic size MC button press?

mcc?.mcc?.onPress = function () {
}

Clearing Array In Movie Clip
In frame 1 one presses a button and an array ("array 1") of 11 jpgs load into a movie clip "_root.overview".
On frame 2 when another button is pressed another array ("array2") loads into the same movie clip "_root.overview". The only problem is that the second array has one less image than the first array and the extra image remains persistent if one toggles back.

Is there a way to clear an array before reloading another in the same clip. I tried unloadMovie but that unloads everything. I need a way to refresh the array each time it is clicked.

Thanks

Duplicating Movie Clip Into An Array In AS3
Hi anyone
I am writing an interactive 'bingo' game which creates a bingo card with 20 boxes. In AS2 I used duplicateMovieClip and 'push'ed the duplicate into an array. I could them access each movie clip when clicked (to turn a cross on or off on the movie clip). I'm new to AS3 and am really struggling to get to grips with the new coding protocols. Can anyone help with the attached code?
My original movie clip is called symbol_box_mc and the array I want to push it into is called symbol_box
I've a load of other queries about this project but one step at a time!
I've defined the array earlier with...
var symbol_box:Array = new Array();








Attach Code

//create an array to hold used symbols
for (i=0; i<20; i++) {
var newImg_mc:MovieClip = symbol_box_mc.duplicateMovieClip("newImg_mc"+i, dep++);
symbol_box.push(newImg_mc);
}

Movie Clip That Rotates Through Array
Hello,

I'm trying to use the kirupa newsticker. I have it configured to load from an XML doc. Works great.

PROBLEM: I need to be able to run it using loadvars() from a php script instead of XML because my host (godaddy - never again) will not provide a safe environment that will allow me to use fopen, fwrite, etc. to create the XML doc using php. (I was going to write a script that would output the necessary xml for the newsticker to run so it could be managed from the Db management interface we are using)

Can anyone instruct me as to how to modify the newsticker to do this? I don't know AS well enough to do it!

Here is the XML Version:


Code:

function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
title_arr = [];
day_arr = [];
date_arr = [];
blurb_arr = [];
pic_arr = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
title_arr[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
day_arr[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
date_arr[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
blurb_arr[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
pic_arr[i] = xmlNode.childNodes[i].childNodes[4].firstChild.nodeValue;
}
first_item();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("<A href="http://www.jeffcenter.org/flash.xml?blarg="+new">http://www.jeffcenter.org/flash.xml?blarg="+new Date().getTime());
//
function first_item() {
delay = 3500;
p = 0;
display(p);
p++;
}
//
function timer() {
myInterval = setInterval(ticker, delay);
function ticker() {
clearInterval(myInterval);
if (p == total) {
p = 0;
}
fadeout();
}
}
//
function display(pos) {
/* over = new TextFormat();
over.underline = true;
//
out = new TextFormat();
out.underline = false; */
//
jcflash_mc.blurbTextMC.blurbText._alpha = 100;
jcflash_mc.titleTextMC.titleText._alpha = 100;
jcflash_mc.dateTextMC.dateText._alpha = 100;
jcflash_mc.dayTextMC.dayText._alpha = 100;
jcflash_mc.evtPic._alpha = 100;
//
jcflash_mc.blurbTextMC.blurbText.text = blurb_arr[pos];
jcflash_mc.titleTextMC.titleText.text = title_arr[pos];
jcflash_mc.dateTextMC.dateText.text = date_arr[pos];
jcflash_mc.dayTextMC.dayText.text = day_arr[pos];
jcflash_mc.evtPic.loadMovie(pic_arr[pos]);
/* newsMC.onRelease = function() {
getURL(url[pos], "_self");
};
newsMC.onRollOver = function() {
this.newsText.setTextFormat(over);
};
newsMC.onRollOut = function() {
this.newsText.setTextFormat(out);
}; */
timer();
}
function fadeout() {
this.onEnterFrame = function() {
if (jcflash_mc.blurbTextMC.blurbText._alpha>=0) {
jcflash_mc.blurbTextMC.blurbText._alpha -= 5;
} else {
display(p);
p++;
delete this.onEnterFrame;
}
if (jcflash_mc.titleTextMC.titleText._alpha>=0) {
jcflash_mc.titleTextMC.titleText._alpha -= 5;
} else {
display(p);
p++;
delete this.onEnterFrame;
}
if (jcflash_mc.dateTextMC.dateText._alpha>=0) {
jcflash_mc.dateTextMC.dateText._alpha -= 5;
} else {
display(p);
p++;
delete this.onEnterFrame;
}
if (jcflash_mc.dayTextMC.dayText._alpha>=0) {
jcflash_mc.dayTextMC.dayText._alpha -= 5;
} else {
display(p);
p++;
delete this.onEnterFrame;
}
if (jcflash_mc.evtPic._alpha>=0) {
jcflash_mc.evtPic._alpha -= 5;
} else {
display(p);
p++;
delete this.onEnterFrame;
}
};
}

Array Of Movie Clip Widths
Ok, I swear that arrays and loops will be the death of me, and I still cant find any "Jeez you are stupid so I'll spell it out slowly and COMPLETELY for you" tutorials.

I have 5 movie clips, currently. and I am positioning them via actionscript. The instance names are nar, mv, dance, bio, clients, contact. (pretty obvious this is navigation for a portfolio site, huh?)

here is the positioning i currently have...


Code:
var spacing = (((Stage.width*.75) - (nar._width + mv._width + dance._width + bio._width + clients._width + contact._width))/5);
nar._x = 10;
mv._x = 10+nar._width+spacing;
dance._x = 10+nar._width+mv._width+(spacing*2);
bio._x = 10+nar._width+mv._width+dance._width+(spacing*3);
clients._x = 10+nar._width+mv._width+dance._width+bio._width+(spacing*4);
contact._x = 10 + nar._width + mv._width + dance._width + bio._width + clients._width + (spacing*5);

Now, I know that this can be done with an array and a loop, something like, loop through all movie clips for width, then use the total in the spacing variable, then for each clip in the array, set the _x to 10 + the width of the clips before it + spacing times its array position, but man, I can just NOT figure out the syntax.

Any help would be greatly appreciated.

~nik

Can An Instance/movie Clip Name Be An Array?
I've got some text and picture areas that I'd like to populate dynamically (i.e. 4 headings with associated photos) Rather than hardcode them, can I make the instance names arrays? like movie clip name "picture[0]"?

for example, why doesn't this work...
picture_[4].loadMovie("images/" + storyImg[j], 1);

but this does...
picture_4.loadMovie("images/" + storyImg[j], 1);

BTW: iyo- what is the best book for learning more about flash & actionscripting?

CG

Loading A Swf Into A Movie Clip At The End Of An Array
What I'm trying to do is create a slide show of sorts using an array to load the images dynamically. There is going to be about 60-70 images, so I'm tring to keep the file size manageable, hence loading them dynamically. The problem is that I hit the end of my array and that is all I hit. What (if anything) can I do to so when I hit the end of the array I could switch to a different scene or really anything at all to add some functionality to get out of the array? Here is the code
Code:

var slides:Array = new Array(["", "Carter-1.png"], ["", "Carter-2.png);
var currentSlide:Number;
function changeSlide(number){
   if (number >= 0 && number < slides.length){
      currentSlide = number;
      title_txt.text = slides[number][0];
      loadMovie (slides[number][1], "loader");
   }
}

Duplicater Movie Clip And Radom Array?
I dont know what to ask for....
I have a movie clip with a motion tween and a stop label at the end.
I want to use some actionscript to make it play multiple instances in a random location(within a certain area) over and over.

The effect i am looking for is streaks like a starfield.... Can anyone gimme some code?

Multiple Movie Clip Instances With An Array
Hey everyone,

I've tried numerous different things, but as I'm still sort of a newbie to flash I still haven't gotten it to work. Here's what I'm trying to do with the preloader I'm trying to make:

I want to have 7 instances of the same movie clip., which contains a dynamic text box, which will contain a letter. On the _main part of the movie, I want each of the 7 seven instances to send its name (which will be the letter it will display L, O, A, D, I, N or G) to a switch statement in a FOR-loop that will assign each clip the appropriate letter after reading in the clip's name. What's the best way to do this?

I'm sure that this is just more of a pain in the butt than its worth, but it seems my curiosity has gotten the best of me yet again.

Thanks in advance for you help!
-Steve

Targeting An Array In A Movie Clip Returns NAn
ActionScript Code:
//in function, function executes itself
_root.universal.propertyinfo["Art Museum"]["buypay"] = 400

//in onRelease for an mc, then in a function() in an array which is in the parameter of another function
calc((_root.universal.propertyinfo["Art Museum"]["buypay"]), -1, "*")

/*
calc calculates numbers without Number()

trace(calc(1, 1, "+")) //traces 2
trace(calc(2, 4, "*")) //traces 8

*/

What is my problem? It seems like it should work, but the calc() returns nAn!

Movie Clip Array Values Undefined
Hey. Just wrote a quick little piece of code that is supposed to make little circles travel in waves across the screen. Here's a link to the nopaste( that way I can point to line numbers ) :

http://rafb.net/paste/results/5xXlmK76.html

Problem is that the trace you see on line 14 returns undefined. Hence, I don't think my movie clips are properly initializing. I figured out that I was supposed to link the wave symbol to the action script but that still hasn't helped.

Your help is appreciated,
Mike Whitfield

Current Frame Of A Movie Clip Within An Array
How can i get the _currentframe of a movieclip within an array?

(in making a battleships game)
I have two arrays (OpponentGrid and PlayerGrid) with 100 elements in each.

ActionScript Code:
OpponentGrid = new Array(o0,o1,o2,o3,o4,o5,o6,o7,o8,o9,o10...
PlayerGrid = new Array(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10...

I'm currently focusing on OpponentGrid and hope that it's solution will fix the other.

each of the movieclips inside are instances of the same movie clip.
Frame 1 => untested (with fire button) - shown if it is the players turn
Frame 2 => Hit
Frame 3 => Missed
Frame 4 => untested (without fire button) -shown if it is not the players turn

I need to loop through this array to update the grid dependant on a string:
0 = untested
1 = hit
2 = missed

My current code:


ActionScript Code:
for(i=0; i<100; i++){
    var temp:Number = _global.pGrid.charAt(i);
    _root.PlayerGrid[i].gotoAndStop(temp+1);
   
    switch(_global.oGrid.charAt(i)){
        case 0:  // untested cell
            if(_global.turn == _global.playerId) OpponentGrid[i].gotoAndStop(1);  // show fire button
            else OpponentGrid[i].gotoAndStop(4);  // dont show fire button
            break;
        case 1:  // hit
            OpponentGrid[i].gotoAndStop(2);
            break;
        case 2:  // miss
            OpponentGrid[i].gotoAndStop(3);
            break;
    } // end switch(_global.pGrid.charAt(i))
} // end for(i=0; i<100; i++)

the player is able to fire even if it is not their turn, and when the grid is fired on, the grid string (oGrid) is properly updated, but the visible grid does not at all.

The PlayerGrid part appears to work fine, but only the first time it is performed
the correct cells are changed to the correct frame.
however, when the other person fires, the grid string (pGrid) changes correctly, but again the visible grid does not (it does however change the correct cell to the incorrect frame)

I've run out of ideas why this isnt working and hope someone here can offer a suggestion.

ps i'm sorry for the long post, but its a complicated project

Accessing An Array In A Duplicated Movie Clip
I have a movie clip that has a script declaration of:
var myCGroup:Array = Array();
in the first frame.

(I've also tried var myCGroup:Array; var myCGroup:Array = new Array(); and var myCGroup:Array = []; )

I duplicate this movie clip multiple times. I'm having trouble targeting the variable myCGroup from elsewhere in the timeline. Other non-array variables that are declared in the same place are fully accessible.

The only code I've been able to write that writes to this variable is:
eval(targetThumb).myCGroup = prodFlush[2].childNodes;

which actually takes the childnodes and creates an array with them.

However, reading them back out from a separate function later is impossible:
trace("colors to target =====" + eval(masterProds[sm]).myCGroup);
returns nothing. I can read and write to other variables from the same function using the same targeting.

(yes, materProds[sm] == targetThumb)

Also, the following code results in an undefined array:

//for(cg=0;cg<cGroupArray.length;cg++){
//eval(targetThumb).myCGroup.push(cGroupArray[cg].firstChild.nodeValue);
//trace("time: " + cg + " || adding this color group " + cGroupArray[cg].firstChild.nodeValue + " to product: "+ targetThumb + "===== " + eval(targetThumb).myCGroup)
//};

Is this a bug, or a documented local vs. global variable option that I'm unaware about regarding arrays?

Any other thoughts? I'm at my wits end.

Thanks in advance.

-r

Is It Possible To Declare Array Inside Movie Clip?
If it's possible, how?
And how to access it's value?

I've been trying like this:

mymovieclip.myArray = ["mc0","mc1","mc2","mc3"]

and I try to access it's value via:
mymovieclip.mc0 = function(){
do this
else
do that
}

and doesn't work.

Thanks

Can't Reference A Movie Clip Array Via For Loop
Hello everybody, I have this problem since many weeks ago, I can't figure out how to resolve it. My partial code is:

function checkCollision(rect) {
for(j=0; j < drop.length; j++) {
temp2 = eval(drop[j]);
if(eval(rect._droptarget) == temp2){
rect._x = temp2._x;
rect._y = temp2._y;
}
else {
rect._x = rect.origX;
rect._y = rect.origY;
}
}
}

I send to the function a movie clip that I use for drag and drop, so when I drop this function is called. The problem is that of the three rectangles that I use for contain the others, only the last senses the drop target. I read the Canadian post of frequently asked questions, and one of the questions is very similar, but I can't figure out how to apply it here. Any help please. Thanks

Populating And Accessing An Array In A Movie Clip
Googling around, I see plenty of advice on populating an array with movie clips. Fine, useful, but I already know how to do that.

What I'm trying to is populate an array that occurs in each instance of a movie clip:


Code:
for(i=0; i<something; i++) {
//attach the movie first
//the clip with linkage an MC has an empty array called someStuff
clipName="anMC_"+i;
thisClip=_root.attachMovie("anMC", clipName, i);
//now populate the array someStuff in each of the clips
//***THIS DOES NOT SEEM TO WORK***
for(j=0; j<somethingElse; j++) {
thisClip.someStuff[j]=otherStuff[j];
}
}
Tried giving the movie clip some time, the stage some time, etc. No matter what I do, though, the array in all instances of anMC comes out completely empty.

Would simplify what I'm trying to do a great deal, but that's presuming that what I'm talking about is even possible. So... my question basically is... can this even be done? Apparently it's not possible... if I'm right about this, why is this so?

Is It Possible To Declare Array Inside Movie Clip?
If it's possible, how?
And how to access it's value?

I've been trying like this:

mymovieclip.myArray = ["mc0","mc1","mc2","mc3"]

and I try to access it's value via:
mymovieclip.mc0 = function(){
do this
else
do that
}

and doesn't work.

Thanks

Finding Variables In Movie Clip Array
So I have a number of movie clips on the stage, each of which declares the variable "tagNum" on load. Each movie clip has a different value for "tagNum".
Example:

Code:
onClipEvent (load) {
this.tagNum = 3;
}
Here's what I want to do. As part of my script, I want to cycle through all the clips, and determine the value of "tagNum" for each clip. Thing is, I can't figure out how do this this.

When I tried this...
Code:
for (var i in this) {
if (typeof (this[i]) == "movieclip") {
trace(this[i].tagNum);
}
}
I keep getting "undefined" returned.

Could someone please tell me what I'm doing wrong and how I can fix it?

Problem With Duplicate Movie Clip Which Is Tracked In An Array
I have a problem with my inventory code using Shared Objects. What i did was to track the collected items in an array. Each time the user collects an item, the original iconMC is duplicated and loads a picture of the item (function loadImage). However, my problem is that this retains the original array so even if I already added new items into the inventory, the newest item doesn't show. original array length = 2, new array length = 3; the last item doesn't show. If I reload my flash, its the only time that this shows. Now if I get an item and lessen the inventory, it still retains the original length and doubles (or triples, depending on how many items i lessened) the last item.

var so:SharedObject = SharedObject.getLocal("lakbayUser", "/");
var i:Number = so.data.currentUserIndex;
var ctr = 0;
var iconCtr;
var iconArray: Array; //temporary storage of items placed inside icon

function selectIcon(num){
eval("iconMC"+num)._alpha = 0;
so.data.users[15][0] = true;
so.data.users[15][1] = iconArray;
}

//loads the next icon
function setNextIconMC(itemCtr, iconCtr){
if(iconCtr > 0) {
newName = "iconMC" + iconCtr;
newPos = 130 * iconCtr;
_root.itemaHolderMC.iconHolderMC.iconMC0.duplicateMovieClip(newName,iconCtr+1);//does not duplcate if unloadMovie is called
this[newName]._x = newPos;
this["iconMC"+iconCtr].enabled = true;
this["iconMC"+iconCtr]._alpha = 100;
loadMovie("gamit/icon"+itemCtr+".jpg",_root.itemaHolderMC.iconHolderMC[newName]);
trace(_root.itemaHolderMC.iconHolderMC[newName]);
}
else {
iconMC0.enabled = true;
iconMC0._alpha = 100;
loadMovie("gamit/icon"+itemCtr+".jpg",_root.itemaHolderMC.iconHolderMC.iconMC0);
}
}

//loads all the icons into the container
function loadImage(){
iconCtr=0;
iconArray = new Array();
for(itemCtr = 0; itemCtr < so.data.users[14].length; itemCtr++){
if(so.data.users[14][itemCtr] == true){
iconArray[iconCtr] = itemCtr;
setNextIconMC(itemCtr,iconCtr);
iconCtr++;
}
}
if(iconCtr==0){
iconMC0._visible = false;
}
else iconMC0._visible = true;
}

loadImage();
so.flush();
stop();

Movie Clip Objects Stored In An Array: Would This Work?
Hi guys!

I just started using ActionScript few weeks ago, so I'm not really that familiar with some things yet.

Anyway, I am having problems with storing movie clip objects in an array because when I try to access them, it kinda loses its properties as a movie clip. Say, i have mc_1 stored in the array,and in the course of the flash movie, a button is triggered to change its visibility to "false".. what i do is, arr[0]._visibility = false. hehehe, yeah i know, this won't work. do you have any suggestions? Please.. I really need it semi-urgently.

So here's what I'm really trying to do with my school project: I have 24 movieclips, i named them field1, field2, ..., field24. I stored them in an array. Initially, they're invisible. Then, a button is clicked to show one field. If the button is clicked again, the second field is displayed, and so on.

I really hope you could help me in this. Thanks a lot!





Joey

XML Slideshow/Portfolio Array Value Not Passing To Movie Clip
Hello,
I've adapted Kirupa's xml portfolio and slideshow to something that works pretty well. But I haven't been able to get a certain important function to work within a loop. The following script loads the xml file, defines several variables and creates an array. The array variables are assigned within a 'for' loop. Then the thumbs are loaded into their correct mc's using the 'i' value. When I try this with the thumb links, the 'i' value gets lost and I get back an 'undefined' message. I can have it trace the image array and the others but passing the value of the thumb that you click doesn't work. For instance, if you click thumb[5] (as passed through the loop), it should pass that [5] to the 'bigimage_mc'.

Here's the code. Any help would be greatly appreciated. I'd even be willing to exchange my adaptation (a portfolio with thumbs, swapping big image, and previous/next buttons).

//LOAD XML FILE AND CREATE ARRAYS FROM THE DATA///////////////
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
thumb = [];
image = [];
title = [];
caption = [];
// VARIABLE COUNTING THE PICTURE NODES
total = xmlNode.childNodes.length;
// THE LAST INTEGERS MATCH THE CHILDNODES ORDER IN THE XML CORRESPONDING TO THE VARIABLE NAME
for (i=0; i<total; i++) {
thumb[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
image[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
title[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
caption[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
//LOAD THUMBS. THIS WORKS FINE.
thumbmenu_mc["thumb_mc"+i].thumbimg_mc.loadMovie(thumb[i]);
//COULDN'T PASS THE ARRAY VALUE TO THE 'bigimage' TARGET WITH 'onPress' FUNCTION
thumbmenu_mc["thumb_mc"+i].onPress = function() {
bigimage_mc.picture_mc._alpha = 0;
bigimage_mc.picture_mc.loadMovie(image[i]);
bigimage_mc.title_txt.text = title[i];
bigimage_mc.desc_txt.text = caption[i];
};
}
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("paintings.xml");

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.

[CS3] Problem With Duplicate Movie Clip Which Is Tracked In An Array
I have a problem with my inventory code using Shared Objects. What i did was to track the collected items in an array. Each time the user collects an item, the original iconMC is duplicated and loads a picture of the item (function loadImage). However, my problem is that this retains the original array so even if I already added new items into the inventory, the newest item doesn't show. original array length = 2, new array length = 3; the last item doesn't show. If I reload my flash, its the only time that this shows. Now if I get an item and lessen the inventory, it still retains the original length and doubles (or triples, depending on how many items i lessened) the last item.

It works perfectly fine during the first call. But if I call loadImage again, it doesn't duplicate the last clip.

Here's the code

Code:
//loads the next icon
function setNextIconMC(itemCtr, iconCtr){
if(iconCtr > 0) {
newName = "iconMC" + iconCtr;
newPos = 130 * iconCtr;
_root.itemaHolderMC.iconHolderMC.iconMC0.duplicateMovieClip(newName,iconCtr+1);//does not duplcate if unloadMovie is called
this[newName]._x = newPos;
this["iconMC"+iconCtr].enabled = true;
this["iconMC"+iconCtr]._alpha = 100;
loadMovie("gamit/icon"+itemCtr+".jpg",_root.itemaHolderMC.iconHolderMC[newName]);
}
else {
iconMC0.enabled = true;
iconMC0._alpha = 100;
loadMovie("gamit/icon"+itemCtr+".jpg",_root.itemaHolderMC.iconHolderMC.iconMC0);
}
}

//loads all the icons into the container
function loadImage(){
iconCtr=0;
iconArray = null;
iconArray = new Array();
for(itemCtr = 0; itemCtr < so.data.users[i][14].length; itemCtr++){
if(so.data.users[i][14][itemCtr] == true){
iconArray[iconCtr] = itemCtr;
setNextIconMC(itemCtr,iconCtr);
iconCtr++;
}
}
if(iconCtr==0){
iconMC0._visible = false;
}
else iconMC0._visible = true;
so.flush();
}

loadImage();

[F8] Movie Clip Object Loses Values When Pushed To Array.
Hello I'm trying to make a simple game not using OOP with Flash 8 and ActionScript 2.0.

Basically I'm starting to write a function for spawning enemies but once I attachMovie and push the movieclip into an array the properties like ._x become undefinded.



Here's the code as I figure it should work.


PHP Code:




function spawnMob():Void{
    
    attachMovie("Monster1", ["mob" + spawnID], this.getNextHighestDepth());
    arSpawns.push(["mob" + spawnID]);
    arSpawns[spawnID]._x = 100;
    arSpawns[spawnID]._y = 100;
    spawnID ++;
}







Your help is appreciated! Thanks.

AttachMovie - Looping Thru An Array To Attach 6 Movie Clips Into An Empty Clip
Heres my issue...

Im loading in 6 different external icon button images using an XML file into an movieclip. well now i dont want external images to load from an xml file, i want the images to be inside flash in the library. I gave them a linkage name and made an array of them called menuIcons.

how do i get my icon images to load into flash without loading external images from an xml file...

heres my code..


var xml:XML = new XML();
xml.ignoreWhite = true;

xml.onLoad = function()
{
var nodes = this.firstChild.childNodes;
numOfItem = nodes.length;
for (var i=0; i<numOfItem; i++)
{
menuIcons = ["healthySkin", "environMoist", "lowerSkin", "drySkin", "waterInfusion", "healthyCellular"];

var t = home.attachMovie("item", "item" + i, i + 1);
t.angle = i * ((Math.PI * 2)/numOfItem);t.onEnterFrame = mover;
t.nameClip = (nodes[i].attributes.nameClip);
t.content = (nodes[i].attributes.content);
t.icon.inner.loadMovie(nodes[i].attributes.image);t.icon.onRollOver = over;
t.icon.onRollOut = out;
t.icon.onRelease = released;
}
}

thanks

slalonde44

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");
}

}
}

Making A Movie Clip In A Movie Clip Go To The Next Frame Of The Original Movie Clip
I have a movie clip (for simplicity I'll call it movie_a) in movie_a I have another movie clip movie_b.

in movie_a i have a button that when pressed makes movie_b play (it has a stop frame every once in a while so the button acts as a "next" button)

I want it so that when i get to the last frame of movie_b and press the button, it will go to the next frame of movie_a

I hope that doesn't confuse u and u can help me solve this problem, as i am stumped and I've tried everything I could think of (which isn't that much as I'm not too good with actionscript)

thnx

Targeting A Frame Label In A Movie Clip From A Button In A Separate Movie Clip.
I have two separate movie clips placed on a timeline-MovieclipA and MovieclipB. I have a button in MovieclipB clip that wants to target a frame label located in the MovieclipA timeline. Can someone help me?

Movie Clip Buttons Nested Inside Movie Clip Dont Work
Hi people!
im having a problem here.

in my first frame i have a movie clip named "menu_mc".
i have this AS for this movie:

Code:
this.menu_mc.onRollOver = function() {
menu_mc.gotoAndPlay(8);
}
this.menu_mc.onRollOut = function() {
menu_mc.gotoAndStop(7);
}

thats working ok, the menu_mc plays on rollover from frame 8 till frame 12 where stops.
On frame 12 (this is inside the menu_mc movie clip) i have another movie clip, named button1_mc.
and also i have AS controling that MC:

Code:
this.button1_mc.onRelease = function() {
getURL("index.htm", "_self");
}


The problem is that when i rollOver on menu_mc it work fine and the button1 appears, the problem is when i try to click button1...
doesnt work.

the swf you can see it on www.wt.com.mx/menu.swf
can anybody help me please?
what im doing wrong?
or what other ideas can you give me so i can make that work.

thanks!

Mouse Rollover On One Movie Clip Increase Decrease Alpha Of Another Movie Clip..
So I really haven't messed with Actionscript much for a couple years and here is my issue.

I have several movieclips I put together that will eventually be a menu for my website. When you roll over a menu option (movieclip) I am trying to get another movie clip to fade in giving the description of the menu item.

For example - when you roll your mouse over the 'Live Chat' option a brief text description would appear telling you what the live chat is about. This description is a seperate movie clip appearing away from the original menu.

I have made the movieclips for the menu and the movie clips for the descriptions. I tried this action on the menu option to get the description to fade in:


Code:
onClipEvent (load) {
this._parent.mc_text_discussionBoard._alpha = 0;
}
onClipEvent (enterFrame) {
this.onRollOver = function() {
if (this._parent.mc_text_discussionBoard._alpha<100) {
this._parent.mc_text_discussionBoard._alpha += 5;
}
};
}
But the alpha only increases on the description (mc_text_discussionBoard) by 5 when I keep rolling my move over and out and over again. It makes sense why it does that, but I'm not exaclty sure how to get it to continually increase the alpha by 5.

any help would be great and I am anxiously waiting to get this solved!
Kevin

Code 4 MovieClip Button To Load A Movie Clip Into A Placeholder Movie Clip.
Yeah that title sounds a little confusing...so i will explain:

Is there a way to tell a "movie clip button" that once it is clicked on to load a "movie clip" into a "movie clip placeholder". So instead of loading an external swf into the placeholder, it will be a movie clip from within the same library. Putting every single custom clip on the timeline would take a while, so that is why I thought it would be easier like this, and the other movie clips are not that large that I want to load into it so there is no need for external swfs, trying to keep it clean. Here is the code along the lines I am trying to go for.

__________________________________________

this.profile_mc.onRelease = function() {
placeholder_mc.loadMovie("profileSection_mc","plac eholder_mc","_root.content");
}
__________________________________________

- "profile_mc is the button I am trying to activate to load the
"profileSection_mc" into the "placeholder_mc". but so far no good.

- the movie clips are within the same library, not on the timeline or external library.

- Is this possible?

Using A Button In A Movie Clip To Control The Movie(and Not Movie Clip) Timeline
Ok i have a button placed in a movie clip. I want this button, when released, to go in another scene, frame one, on the movie(scene) timeline and not on the movie clip timeline.

So i tried: gotoAndPlay("mission", 1); (mission is the name of my scene)

But it goes to the frame 1 of my movie clip, It would be great if someone could tell me how i can control the movie timeline while my button is in a movie clip

thaks
Vakarm

A Movie Clip Inside A 2nd Movie Clip Colliding With 4th Movie Clip That's In The 3rd
sorry if that sounds a bit odd, this is really a simple problem that i can't seem to nail.

Can u please give the the hittest that shows when a movie clip collides with another regardless of their level.

How To 'stop' A Movie Clip Within A Movie Clip Within A Movie Clip Loop
I've done searches, laughed, cried, and punched holes through the wall, but I can't figure this out.

I'm in Flash MX (pro) and I have a MovieClip on my main timeline (frame 1). Inside that clip is another animation (the static animation scrolling across the screen), and another inside of it of the static animation (6 characters on a train each animated uniquely).

Confused yet? Ha! OK, so I just want the damned animation on the main timeline to run once and then stop (or to 270 frames). I've tried:

myMovieClip.stop()

to no avail. I've tried attaching the script to the movie clip itself, and also to the frame.

Any suggestions?

Making A Draggable Movie Clip Control The Location Of Another Movie Clip
http://www.kineticz.net/jba/residental.jpg that is a picture of what i am trying to do. the white bar at the bottom is the draggable movie clip and the group of 3 pictures right above that is the movie clip that i am trying to control w/ the draggable clip. I am having trouble writing a script that will do this. any help you can give will be much appreciated.

When I Click On A Movie Clip I Need The Movie Clip To Goto And Play Frame 2
i have created a movieclip and draged it on to the stage i tryed used on mouse down then tell target goto and play but that ment when ever the mouse clicked any where, how do i tell in to only play when i click on the movieclip ?

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