How Do I Make A Array Of MovieClips?
I am using the duplicateMovie function to populate an Array. I wont to be able to perform function with the array like (myArray[i].play(), myArray._x, ect.) The clip I wont to duplicate is the first in the array, I do this one manually (meaning it is not put there though a for loop like the rest). The MC functions stated abouve work with it(myArray[0].stop(),ect.). When I tested it, pulled up the variable list, I found that myArray[0] shows up as a movie clip ("MovieClip:'mc'"). All of the other MC show up as string ("mc1","mc2","mc3", ect). I figure I need all of them to be as the first, the clip itself and not just its name. Do any of you know any thing about this If so how do I remedy this. Mind you i am using for loop to populate the array, so the solution would have to work in that situation.
Now if you don’t understand what i am asking please tell me and I will elaborate.
FlashKit > Flash Help > Flash General Help
Posted on: 01-20-2003, 09:03 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Can't Duplicate Movieclips As An Array Within An Array
Hello.
I have an animation that loads an xml into it and traces back an array within an array. I have tried to apply this to duplicated movieclips thereby creating a structured set of links. What I am trying to do is this:
Chicken Nuggets
__Compression
__Texture
__Disgust
Mega Warhead
__Taste
__Hardness
__Pain
This traces fine but I can't seem to get the duplicated movieclips to assemble in this fashion.
The code for the XML is as follows:
var controlArray:Array;
var variable:Array;
var testTopic = new Array ();
var test = new Array ();
var controlsXML:XML = new XML();
controlsXML.ignoreWhite = true;
controlsXML.onLoad = function(success:Boolean){
if (success){
var mainnode:XMLNode = controlsXML.firstChild;
var controlNodes:Array = controlsXML.firstChild.firstChild.firstChild.firstChild.childNodes;
var list:Array = new Array();
for (var i:Number = 0; i < controlNodes.length; i++) {
var personnode:XMLNode = controlNodes.attributes.Name;
trace(personnode);
testTopic.push (new struct (personnode));
var specificNode:Array = controlNodes.childNodes;
for (var j:Number = 0; j < specificNode.length; j++){
var itemnode:XMLNode = specificNode[j].attributes.Variable;
trace(itemnode);
test.push (new struct2 (itemnode));
}
}
printer ();
printer2 ();
} else {
trace('error reading XML');
}
};
controlsXML.load ("controls3.xml");
The code for the movieclip duplication is as follows:
x = 50;
function printer ()
{
for (m = 0; m < testTopic.length; m++)
{
duplicateMovieClip ( slotTopic, "slotTopic" + m, m );
slotTopic = eval ( "slotTopic" + m );
slotTopic._y += x;
slotTopic.slotTopicContent.text = testTopic[m].personnode;
}
}
function printer2 ()
{
for (k = 0; k < test.length; k++)
{
duplicateMovieClip ( slot, "slot" + k, k );
slot = eval ( "slot" + k );
slot._y += x;
slot.slotContent.text = test[k].itemnode;
}
}
function struct (personnode)
{
this.personnode = personnode;
}
function struct2 (itemnode)
{
this.itemnode = itemnode;
}
On the stage are two movieclips, titled "slotTopic" and "slot". Within those are dynamic text boxes titled respectively "slotTopicContent" and "slotContent". When I preview this file it only displays the text within the "slot" movieclip and it lists all six of the subtopics with no break. So, there are two dilemmas:
1) The movieclips won't duplicate into the structured set of links that I want.
2) "slotTopic" is not displaying text at all.
If anyone has any advice, I'd really appreciate it. Thx!
Duplicate Movieclips: Array Within An Array
Hello.
Having a problem with duplicating movieclips within an array within another array.
I'm trying to setup a horizontal categorical menu drawn from an xml file.
I want this:
0
mainMenuSmall0.jpg
1
mainMenuSmall1.jpg
2
mainMenuSmall2.jpg
...etc.
The following is the code:
var array = new Array ();
var xml = new XML ();
xml.onLoad = function ()
{
var header, link, image;
for (var i = 0; i < this.firstChild.childNodes.length; i++)
{
if (this.firstChild.childNodes[i].nodeName != null)
{
header = this.firstChild.childNodes[i].attributes.header;
}
for (var j = 0; j < this.firstChild.childNodes[i].childNodes.length; j++)
{
if (this.firstChild.childNodes[i].childNodes[j].nodeName == "link")
{
link = this.firstChild.childNodes[i].childNodes[j].firstChild.nodeValue;
}
}
for (var k = 0; k < this.firstChild.childNodes[i].childNodes.length; k++)
{
if (this.firstChild.childNodes[i].childNodes[k].nodeName == "image")
{
image = this.firstChild.childNodes[i].childNodes[k].firstChild.nodeValue;
}
}
array.push (new struct (header, link, image));
}
printer ();
};
xml.load ("dbase.xml");
function printer ()
{
for (i = 1; i < array.length; i=i+2)
{
slot.duplicateMovieClip ( 'slot'+i,i,{_y:100});
slot.header = array[i].header;
slot.link = array[i].link;
slot.image = array[i].image;
slot = eval ( "slot" + i );
slot2.duplicateMovieClip ( 'slot2'+(i+100),i+100,{_y:50});
slot2.header = array[i].header;
slot2.link = array[i].link;
slot2.image = array[i].image;
slot2 = eval ("slot2" + (i+100));
}
}
function struct (header, link, image)
{
this.header = header;
this.image = image;
this.link = link;
}
'Slot' and 'Slot2' are what the movieclips (blue and green) that should contain the menu item text. I've attached the .xml file and the result of what I get when I publish. Essentially the movieclips are not positioning correctly and the only one of each menu item is displaying.
Any advice would be much appreciated.
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
[CS3] Getting Value For Array Of Movieclips (AS2)
Ok, here goes..
I have an array consisting of 60 movie clips, and when the user clicks anyone of them, I need a value for use in the rest of the script.
Now, the part of the script making this is here:
for (var t = 0; t<foodMCs.length; t++) {
foodMCs[t].onRelease = function() {
var activeFood = this;
//trace(activeFood);
- The "activeFood" var will now be for example "level0.food30" - I want it to be just "30". There's got to be an easy way, but I can't seem to find it.
Thanks in advance.
/Rasmus
Array Of MovieClips
How do I populate an array with movie clips?
I found this in another thread, but it doesn't seem to work.
When the push command is used, the only thing that is pushed into the array is a string value.
movieclips=new Array()
for(i=1;i<=nummovieclips;++i){
duplicateMovieClip("originalmovieclip","newname"+i ,i)
movieclips.push("newname"+i)
}
This is what I have. I was hoping that by passing the value I'd be able to recast the string as moveclip. I don't get any errors, but I don't think I'm populating the array with movieclips either. Please help! THANKS!
var AUTHOR_ARRAY:Array = ["prata", "myler", "weeks"];
var MC_NAME_ARRAY:Array = [];
MCName = "programmer" + AUTHOR_ARRAY[0];
IDName = AUTHOR_ARRAY[0] + "person";
NewName = AUTHOR_ARRAY[0] + "person_01";
loadexample(MCName);
function loadexample(PassedMcName:MovieClip){
createEmptyMovieClip(MCName, getNextHighestDepth());
MC_NAME_ARRAY[0] = PassedMcName; //i also tried MC_NAME_ARRAY[0] = MCName;
MC_NAME_ARRAY[0].attachMovie(IDName, NewName, getNextHighestDepth());
MC_NAME_ARRAY._x = 500;
}
Movieclips In Array
hi,
i want to put a load of images (held in container movieclips) into an array on the stage. then be able to pop the movieclips out of the array into a new array in a different position on the stage.
surely this is possible?
any help greatly appreciated,
dave.
Array With All MovieClips
Is there a build in function within flash to get all the mc's paths/names in a swf file in an array? I want to build a function to see how many frames these mc's are and calculate the total movie length.
Thanks in advance,
Tijs
Array Of Movieclips
from an onMotionFinished i want to somehow animate an array of mcs _alpha
at a setInterval
creating a situation where one paragraph fades up then out after the other about 5-8 seconds apart?
Movieclips In An Array.
From what I can tell, array's are only good for text?
Because I have 2000 MC's that I've separated into 10 different categories. I really don't want to create a giant MC with them all in it, so I was thinking of going with an array. I just learned what they are, but I can't find a tutorial on how not only to create an array with MC's but also be able to go Next and Prev through them on the stage.
And also, I'm trying to duplicate them too, which I've kind of figured out, but what would be the least problematic way of going about deleting, rotating, increase the alpha, flipping, etc. the duplicate MC's? I was thinking of holding the mouse down on the duplicated MC and clicking on a certain button, but that's starting to look complicated.
How Can I Put Movieclips Into An Array Using AS3
I want to put each movie clip created with this for loop into an array so that I can load images into each movie clip in a later script.
var total1:int=2;
var spacing:Number = 100;
var box_mc:MovieClip;
for(var but:int = 0; but < total1; but++)
{
box_mc= new Box();
box_mc.instanceName = "box"+but;
box_mc.x = spacing + but*(box_mc.width+spacing);
box_mc.y = 125;
addChild(box_mc);
}
Array Of Movieclips
How can I create an array of movieclips using for loop.
There's a dozen of movieclips named image1,image2......
when I create an array like;
PHP Code:
images = [image1,image2,....image20];
and call
images[0].onRelease = somefunction;
It works perfectly fine. But if I use for loop like;
PHP Code:
var images = new Array(16);
for(i=0;i<16;i++){
images[i] = "pict"+(i+1);
}
It gives me alot of undifined message;
Why dose this happen?
-KazchiX
Array With All MovieClips
Is there a build in function within flash to get all the mc's paths/names in a swf file in an array? I want to build a function to see how many frames these mc's are and calculate the total movie length.
Thanks in advance,
Tijs
Array Of Movieclips.
I want to create an array of MC, about 10 of them, and have buttons that go Next and Prev. Then have them appear in the stage at a specified location, but only the array that is click on, that way all 10 arrays aren't showing up at once. From there, I want to be able to click on the duplicated MC and get the "focus" or whatever the word is so that I can apply transformations via the keyboard (see FLA for example). The FLA has a couple errors which I can't figure out, depth and removing MC. I'll work on the printing, saving and loading later.
So, what would I have to learn to do all that?
I don't mind if someone posts exact AS or a link explaining how.
I have a book, but it's very basic and none of the tutorials, at least that I found, taught any of this, besides what I already know.http://tivaelydoc.110mb.com/shimmy.fla
Array And Movieclips
hi
sorry this might be a dumb question but can i do this:
this.createEmptyMovieClip(pack1_mc.CardArray[i][2], this.getNextHighestDepth());
pack1_mc.CardArray[0][2].loadMovie(pack1_mc.CardArray[0][1]);
so i'm loading the jpg into One_mc
the array is
var pack1_mc.CardArray= new Array(["One", "ImageOne.jpg","One_mc"]);
thanks
jc
Can't See My Movieclips In Array
hi,
i'm trying to align 3 rows and 3 columns of MovieClips created in actionscript 3. i'm creating them in an array and adding event listeners and drawing sprites in them to check that they are created. while the traces seem to indicate they're there, i can't see anything or detect any mouse moves.
what's wrong with this code? thanks!!
Code:
//------------------------------------------code segment
import flash.display.MovieClip;
// stage is 800x600
// create sprites to show me where stuff is
var gr2:Sprite = new Sprite();
addChild(gr2);
trace("gr2 parent = " + gr2.parent.name);
var gr:Sprite = new Sprite();
//loop to create 9 movieclips in 3 rows and 3 columns
var picArray:Array = new Array();
for (var i:uint = 0; i<9; i++) {
//create movieclip
picArray[i] = new MovieClip();
picArray[i].width = 136;
picArray[i].height = 76;
picArray[i].x = 390.4 + mod(i,3) *136;
picArray[i].y = 272 + Math.floor(i/3)*76;
//tell me where i put the movieclip
trace("Creating picArray[" + i + "] at ("+picArray[i].x + " , " + picArray[i].y);
// draw sprite so i can see it on screen
gr.graphics.lineStyle( );
gr.graphics.beginFill(0xFF0000);
gr.graphics.drawCircle(0,0,90);
// add array movie clip as child and add sprite as child of movieclip
picArray[i].addChild(gr);
addChild(picArray[i]);
trace("Num children = " + picArray[i].parent.numChildren);
trace("parent: = " + picArray[i].parent.name);
// add listener so i can detect mouse moves
picArray[i].addEventListener(MouseEvent.MOUSE_MOVE, identifyPic);
//draw a sprite that is a child of the main timeline, not a movieclip
gr2.graphics.lineStyle( );
gr2.graphics.beginFill(Math.random()*0xFFFFFF);
gr2.graphics.drawCircle(65,35,90);
gr2.x = i*20 +100;
}
trace("picArray = " + picArray);
function identifyPic(evt:MouseEvent):void
{
trace("Mouse Move: target = " + evt.target.name);
}
// modulo function
function mod(a:Number, b:Number):Number {
if (b==0) {
return 0;
}
b = Math.abs(b);
a = Math.abs(a);
if (b>a) {
return a;
}
return a - Math.floor(a / b) * b;
}
Listing Movieclips In An Array
Is it possible to generate a list of all movie clips in a swf so it can be used in an array?
Any help much appreciated
thanks
Sean
>>Making An Array With Movieclips<<
Hello,
I used the search option and browsed the tutorials but I couldn't find an answer and I hope somebody here can tell it to me...
I'm developing a game:
-A helicopter (moved by keyboard) has to find the capitals of Europe. So you get every time a command (like: Go to London) and you have to fly there and I used collision detection to detect the city's with the helicopter. So if you fly over london you get a new command (like go to Paris).. The problem I have is: How do I make an array with moviclips (all the city's) in it? And how can I make: after the helicopter identifies the city, it has to choose again from the array (and so on... about 40 city's).. The movieclips used must not come again (If you had once London you don't get it again..).
Thank you all for reading this and helping me.. (I'm a little bit familiar with actionscripting so please make it clear ;p)
Greetz Codemaster
Creating An Array Of Movieclips
Hi everybody, I'm new here.
I hope I can have some help as well give some too
Here is my problem: I have to build a map of blocks, and I choose to create this map making a number of movieclips.
I already initialized an array named ARMAP, where I filled a 20x20 grid with "b1100" that is the name of the object that I have in library.
This is the code I made to generate such blocks, but it's not working...
Maybe it's completely wrong
code: for (i=0; i<createmapwidth; i++) {
for (j=0; j<createmapheight; j++) {
mapblockclipname = armap[i add j];
_root.createEmptyMovieClip(mapblockclipname, 0);
mapblockclipname.attachMovie(armap[i*j], mapblockclipname, 0);
setProperty(mapblockclipname, _x, random(600));
setProperty(mapblockclipname, _y, random(450));
}
}
Don't bother about the RANDOM function: actually I only would see these damn instances appearing on the screen, then I'll think on how to position them
Simptom: I have a group of objects on the frame and the RANDOM function is moving this one... boh.
[F8] Play Array Of Movieclips
I should know this but, suppose I have an array of movie clips
var nav_array:Array = new Array(3);
nav_array[0] = "clip1";
nav_array[1] = "clip2";
nav_array[2] = "clip3";
and I try to get one to play
nav_array[1].play();
no dice
I'm sure this is simple, please to help
Tween An Array Of MovieClips
Hey guys,
The title is pretty self-explanatory. The code below is obviously wrong, but maybe it can help you understand what I'm trying to do.
var i:int; i=1;
var clip_array:Array = new Array("0", "1", "2" , "3")
var m_Tween = Tween;
button.addEventListener(MouseEvent.CLICK , movieScale )
function movieScale (mevt:MouseEvent) :void {
[/indent][/indent]m_tween = new Tween( "movie_clip" + clip_array[i], "scaleX" , Regular.easeOut , 1 , .4 , 5)
i++;
}
The error i get is:
ReferenceError: Error #1056: Cannot create property scaleX on String.
at fl.transitions::Tween/setPosition()
at fl.transitions::Tween/set position()
at fl.transitions::Tween$iinit()
at mikennedy_fla::nav_bar_2/movieScale()
Looping Though An Array Of Movieclips
Is there a way that I can pass an array of movieclips to my class?
i.e. I have any number of movie clips that I need to pass to a class. a_mc, b_mc, c_mc, etc
Is there a way to send these as an array so I can loop through them?
Thanks!
Array Of MovieClips Not Working?
Hello everybody!
I'm afraid this might be dumb, but neither forum search nor google could help me :/
I want to periodically update several elements (custom classes extending MovieClip). This works:
ActionScript Code:
class Test {
var plot : Plot;
var plots : Array;
function Test() {
plot = new Plot();
setInterval(this, "updatePlots", 200);
}
function updatePlots() {
plot.addPoint();
}
}
But if I put the Plot into an array and try to access it from the array in updatePlots, nothing happens (the addPoint method of the plot doesn't get called):
ActionScript Code:
class Test {
var plot : Plot;
var plots : Array;
function Test() {
plot = new Plot();
plots[0] = plot;
setInterval(this, "updatePlots", 200);
}
function updatePlots() {
plots[0].addPoint();
}
}
Any ideas?
Thanks a lot in advance,
-grayFalcon
Manipulating With MovieClips In Array
Hello,
I want to dynamicly add images from XML to movieClips and then add event listeners to these movieClips. What is the best solution? Could you please help?
XMl loads correctly, it also add 2 movieclips on stage, but it throws errors when I try to add event listeners to movieClips. How could I do that? I want to go to different frames on release of some movieClips. How can I please recognise each movieClip and manipulate with that movieClip ? (resizing,...)
I try this part of my code:
Code:
var imgURL:URLRequest;
var imgLoader:Loader;
var arrayMC:Array=new Array();
var i:int;
function loadImg():void{
for(i=0;i<xmlData.room.length();i++){
var img:MovieClip=new MovieClip();
imgLoader=new Loader();
imgURL = new URLRequest(xmlData.room[i].img.toString());
imgLoader.contentLoaderInfo.addEventListener(Event.INIT, onComplete);
imgLoader.load(imgURL);
}
}
function onComplete (evt:Event):void{
arrayMC.push(evt.target.content);
addChild(arrayMC[numChildren-2]);
}
Storing MovieClips In An Array And Using Them That Way.
Being a PHP user I am having a real hard time understanding some basic object concepts in ActionScript. Actually...I am having a hard time understanding ActionScript at all...expect many posts.
in PHP I can do this:
PHP Code:
<?php
$object_ids = array(1, 2, 3);
$objects = array();
foreach($object_ids as $id){
$objects[] = new objectClass($id);
}
foreach($objects as $object){
echo $object->some_variable.'<br>';
//or just do something with them, whatever that is.
}
?>
Everything else aside, what I want to do is put MovieClip objects into an array and be able to loop through it to change values or run functions or something. The things I have tried just don't do anything. What I am doing is duplicating a MovieClip and I want to store all these MovieClips into an array to better organize and modify them. I know there must be a way to do this. Please help if you can, I appreciate all positive comments. Thanks.
Displaying An Array Of Movieclips
hello
I am trying to create an array of several movieclips (they are actually just one frame graphics) that will display only one movieclip at any given time depending on a counter value.
I setup an array with movie clip names in quotes
var ChlogoAr:Array = new array("sixties","fifties","forties");
The only way i know how to make this work is to palce all the movieclips on the stage, but outside the document area, then change the ._y value of the one I want displayed
ie.
ChlogoAr[2]._y = 40;
but actually, that doesnt work. Is there a way to accomplish this? Ideally, I would want to setup a placement holder and then display whichever movieclip that matched up with the counter. thank you for any advice.
Manipulating With MovieClips In Array
Hello,
I want to dynamicly add images from XML to movieClips and then add event listeners to these movieClips. What is the best solution? Could you please help?
XMl loads correctly, it also add 2 movieclips on stage, but it throws errors when I try to add event listeners to movieClips. How could I do that? I want to go to different frames on release of some movieClips. How can I please recognise each movieClip and manipulate with that movieClip ? (resizing,...)
I attached part of my code
Attach Code
var imgURL:URLRequest;
var imgLoader:Loader;
var arrayMC:Array=new Array();
var i:int;
function loadImg():void{
for(i=0;i<xmlData.room.length();i++){
var img:MovieClip=new MovieClip();
imgLoader=new Loader();
imgURL = new URLRequest(xmlData.room[i].img.toString());
imgLoader.contentLoaderInfo.addEventListener(Event.INIT, onComplete);
imgLoader.load(imgURL);
}
}
function onComplete (evt:Event):void{
arrayMC.push(evt.target.content);
addChild(arrayMC[numChildren-2]);
}
Array Of MovieClips Undefined?
Code:
on (press) {
numdots = _root.dot_num.text;
_root.TEST.text = numdots;
dotArray = new Array();
for (i = 0; i < numdots; i++) {
duplicateMovieClip(_root.dots_seed, "dots_seed"+i, i);
dotArray[i] = eval("dots_seed"+i);
dotArray[i]._x = random(800);
dotArray[i]._y = random(600);
// why undefined, even after eval?
trace(dotArray[i]);
}
_root.dots_seed._visible = false;
}
I'm not sure why the above code isn't working. I've used it correctly before.
_root.TEST is just a Dynamic TextField to make sure I'm retrieving and passing the number correctly, which works.
trace(dotArray[i]); comes out undefined. I'm really at a loss over this one because I have the exact same code in another file, except on a frame in the timeline instead of inside a MovieClip's on (press) -- could that be it? -- and eval and trace work. Any of your help and time would be appreciated, Thanks.
Can't Remove Movieclips In An Array
I have made 4 arrays and filled the with movieclips using the array.push(movieclip) method. I have then made a function that is supposed to remove everything in those arrays. This is the code for it:
ActionScript Code:
function removestuff() {
removeMovieClip(p1s);
removeMovieClip(p2s);
removeMovieClip(p3s);
removeMovieClip(p4s);
for (s=0; s<=exs.length; s++) {
removeMovieClip(exs[s]);
}
for (s=0; s<=bullets.length; s++) {
removeMovieClip(bullets[s]);
}
for (s=0; s<=bombs.length; s++) {
removeMovieClip(bombs[s]);
}
for (s=0; s<=stars.length; s++) {
removeMovieClip(stars[s]);
}
}
But when I call this function it does nothing but remove p1s, p2s, p3s and p4s. Also when I type trace(s) in one of the for loops, it outputs 0 for some reason. Any ideas as to what I'm doing wrong?
Help With Understanding Array Of Movieclips
I'm new to AS3 and I need some wisdom.
I hope to have 4 movieclips in my library and buttons on the stage that act as a next/previous user interface. How do I set up my array to know the movicelip names and how do I get my buttons to select the next or previous movieclip in the array? I'm also trying to figure out how to keep the buttons disabled while the selected movieclip is playing.
My uneducated guess is that I need to create the array with all the movieclip names in it. Then put some addChild and removeChild code in when the buttons are clicked. Does this sound right?
I know there are a lot of questions here so I appreciate any help you all can provide, even if it's just addressing one question.
Array To Store Movieclips
Hi,
I'm looking for a way of storing movieclips (that have already been imported into the library) in a single array, but I can't find a way of doing it.
Thanks in advance,
Rcms
Event For Array Of Movieclips
I have an array of movieclips-and I want to set an onclick action to each of them (the same action) is there a shorter way to do it than array[0].onClick=array[1].onClick=...=function(){}?
maybe some kind of loop?
Array Of MovieClips Objects
I'm trying to make a few movie clips a certain type of object-and then putting it into an array. This code is not working properly what am I doing wrong?
function objLine33 ()
{
}
Line33=[];
Line33.push(new objLine33(Line33A));
Line33.push(new objLine33(Line33B));
Line33.push(new objLine33(Line33C));
Line33.push(new objLine33(Line33D));
Line33.push(new objLine33(Line33E));
* all the lines are actual movieclips
and then when I'm trying to see if a user clicked on one of the items I wrote:
else if (this==objLine33) //but it doesn't recognize it
thank you
Array Referrencing Of Movieclips
Is there a smarter way of doing this?
I was simply writing a shortcut to have a set of movie clips labelled n1 to n15 move in relation to another. I decided to make an array and have it set equal to an eval () referrencing the movieclips in a for loop.
basically this...
Code:
menuholder=new Array();
menuholder[0]._y=0;
for(i=1;i<=15;i++){
menuholder[i]=eval("_parent.n"+i);
menuholder[i]._y=menuholder[i-1]._y+25;
}
This code works fine with all the movieclips EXCEPT for the movieclips that have named nested movieclips within it.
I feel like there is some unspoken rule when dealing with referencing mc's within arrays...but I don't know what it is. Can anyone shed some light on this matter??? Is there a better way of doing this without having to write a separate line of code for EACH movieclip???
thanks in advance!
Different MovieClips In Array To Alpha 0
I have attached six different movieClips to the stage from library and when I click different buttons I want them to disappear - easy enough the long way but I would like to have them in an Array with a variable name. The problem, I understand the principals of Arrays but cannot get it to work. I have searched through the forum looked in flash help and googled but still can't figure out solution.
Please help.
Here is the code
Code:
var shadArray:Array = new Array ("dS1", "eS1", "sS1", "iS1", "gS1", "nS1");
D.onRelease = function() {
if(this._xscale < 130) {
holder1._visible = true;
movegrow(D, E, S, I, G, N);
showlinks(holder1);
D.onRollOut = false;
D.onRollOver = false;
shadArray._alpha = 0;
trace(shadArray);
}
else if(this._xscale>140) {
hidelinks(holder1);
small(D, E, S, I, G, N);
if(holder1._alpha < 2) {
holder1._visible = false;
}
D.onRollOver = function() {
big(D, E, S, I, G, N);
}
D.onRollOut = function() {
small(D, E, S, I, G, N);
}
}
}
Thanks
Assigning Functions To Movieclips In An Array
I'm creating a menu from mcs loaded from the library, I want to assign an onRelease function to each of the menu items which i'm storing in a temporary array when created... basically this: -
Code:
//loop and attach menu items for the number of items in layLength
for(var i=0, j=0; i < layLength; i++){
var temp = container.attachMovie("menuItemMC", "menuItemMCxxx" + i, i);
temp.img = as2obj.boat.img[i].attributes.file; //some xml data
tempArray.push(temp);
y++;
}
//Assign onRelease events to each menu item loaded
for(g in tempArray){
tempArray[g].onRelease = function() {
trace("I am associated with " + tempArray[g].img);
}
}
the problem is the functions assigned to the created movieclips will just default to the current value of 'g' I.e. when trace is triggered it will trace the tempArray value of whatever g is currently, I want it to remember the value at the time the function is assigned to the movie.
Sorry for the poor explanation, my english is bad... I'm british :S
Thanks
Dan
Array Of Movieclips - Accessing Their Properties
Hi,
I am trying to access the properties of an array of movieclips, using the for/in control loop. Right now, my code gets all the movieclips from the main timeline's array:
if(typeof(this[theObj]) == "movieclip"){
// yadda yadda...
}
But what I actually want is to get the movieclips from an array which I create in code:
var objArray:Array = new Array([bubble1, bubble2, bubble3]);
for (var index in objArray){
// access properties of bubble1, bubble2, etc...
}
However, I can't seem to actually use the properties of the movieclips in the array. How can I get to these clips through the array?
Attached is my Flash MX 2003 formatted file, with code in the first frame.
Thank you for your help!
rickpen
Array With Movieclips/buttons Isn't Working For Me...
Hello, I have a problem with adding in arrays with movieclips. This is my code, I have 1 background("bg") so far in the arrays, but I will have some soon. This is my code:
Code:
movespeed = 7;
grass = new Array("_root.bg0.grass0", "_root.bg0.grass1");
bg = new Array("_root.bg0");
_root.guy.onEnterFrame = function() {
if (Key.isDown(37)) {
bg[0]._x += movespeed;
}
if (Key.isDown(38)) {
bg[0]._y += movespeed;
}
if (Key.isDown(39)) {
bg[0]._x -= movespeed;
}
if (Key.isDown(40)) {
bg[0]._y -= movespeed;
}
if (grass.hitTest(this)) {
if (this._x<grass._x) {
bg[0]._x += movespeed;
}
if (this._x<grass._x && this._y<grass._y) {
bg[0]._x += movespeed;
bg[0]._y += movespeed;
}
}
};
This is it so far, but I have one background("bg") and two grass fields so far("grass"). I can't get them to work properly.
Quote:
NOTE:This is a scrolling background, so don't get confused with the movement, oh...and I am using Flash MX 2004 PRO!
Attach MovieClips To A Points Array
I have a points array, and I know how to attach one movie clip to all the points in the array.
The Problem: I want to attach a different movieclip to each point in my array?
any ideas would be greatly appreciated.
current code I'm working with:
Code:
for (i=0; i < pointsArray.length; i++){
attachedObj = myScene.attachMovie("star_mc", "star_mc"+i, i);
}
Take Array Of Of Movieclips And Set Functionality In A Class
Hello, I am trying to do is setup an array of Movie Clips that are associated to the class (they are actually buttons). I want to be able to loop through them one by one and set the movieclips differenct events...i.e. onRelease, onRollover, etc. I assumed I could do something like this within a class.
Code:
public function init():Void{
aSections = new Array();
//create array of links
aSections.push({ID:1, sectionName:"section 1", buttonID:"section1"});
aSections.push({ID:2, sectionName:"section 2", buttonID:"section2"});
aSections.push({ID:3, sectionName:"section 3", buttonID:"section3"});
aSections.push({ID:4, sectionName:"section 4", buttonID:"section4"});
aSections.push({ID:5, sectionName:"section 5", buttonID:"section5"});
aSections.push({ID:6, sectionName:"section 6", buttonID:"section6"});
aSections.push({ID:7, sectionName:"section 7", buttonID:"section7"});
trace("array length is:"+ aSections.length);
//set links
for (var i:Number = 0; i < aSections.length; i++){
this.setLink(aSections[i].buttonID, aSections[i].ID);
}
public function setLink(sectionName:MovieClip, sectionID:Number):Void{
trace("setting Button " + sectionName + " ID to:" + sectionID);
[sectionName]onRelease = function(){
this.selectedButton(sectionID);
}
}
public function selectedButton(sectionID:Number):Void{
if(sectionID != this.__selectedSection){
trace("new section Clicked, Now: "+ sectionID);
setNewSection(sectionID);
}
}
When I try this it sets the all buttons to the last item, at which point once it is click once none of the buttons work anymore. Also, the button is a movie clip with _up, _over, _down states. Does anyone know the correct way to do this?
thanks in advance for any input
Array Function Parameters And MovieClips
Hi. I cannot figure this one out.What I have is an array with some positions in it. Then I'm trying to create a function to utilize those positions. Like so.
ActionScript Code:
var myArray:Array = new Array
myArray = [ 135, 354,567,398]
helpme = function(target_Mc:movieClip, myArray:Array){
if (target_Mc._x is < myArray.index){
target_Mc._x ++
}
What i'm trying to do is say index 0 is 135. So the movieClips x was less than the 135 move.
this.onEnterFrame = function(){
helpme(ball1,0)
I have had this works in if statement like so
ActionScript Code:
if(ball._x < myArray[0]){
ball._x ++
}
I just for the life of me cannot turn it into a function
How To Create Movieclips From Array Elements ?
Hi there,
I am trying to create movieclips for each element of an array.
Basically I have an array of colors, and I want to create a button for each element that will consist of a circle in that color.
So far I have it creating the circles but they are all on top of each other and the name for each movieclip is undefined.
(I can tell they are all being created, because the first 3 are pink and the last is black but the alpha is low and you can see the pink through the black.)
How can I create each one with a unique name?
Below is what I have so far.
Any help would be greatly appreciated
Cheers!
var lightPinkArr:Array = ["0xFF9966", "0xFFA477", "0xFFB08A", "0x000000"];
crcposx = 0;
crcdepth = 0;
for (i = 0; i < lightPinkArr.length; i++) {
trace ("color:" + lightPinkArr[i]);
crcdepth = crcdepth + 10;
trace("depth:"+crcdepth);
var name_str:String;
name_str = lightPinkArr[i];
crclmc = name_str;
trace("crclmc :" +blah);
this.createEmptyMovieClip("crclmc", crcdepth);
crclmc._x = crcposx + 20;
crclmc._y = 20;
trace(crclmc._x);
trace(crclmc._y);
drawCircle(crclmc, 10, lightPinkArr[i], 50);
crcposx = crclmc._x;
}
function drawCircle(target_mc:MovieClip, radius:Number, fillColor:Number, fillAlpha:Number):Void {
var x:Number = radius;
var y:Number = radius;
with (target_mc) {
beginFill(fillColor, fillAlpha);
moveTo(x + radius, y);
curveTo(radius + x, Math.tan(Math.PI / 8) * radius + y, Math.sin(Math.PI / 4) * radius + x, Math.sin(Math.PI / 4) * radius + y);
curveTo(Math.tan(Math.PI / 8) * radius + x, radius + y, x, radius + y);
curveTo(-Math.tan(Math.PI / 8) * radius + x, radius+ y, -Math.sin(Math.PI / 4) * radius + x, Math.sin(Math.PI / 4) * radius + y);
curveTo(-radius + x, Math.tan(Math.PI / 8) * radius + y, -radius + x, y);
curveTo(-radius + x, -Math.tan(Math.PI / 8) * radius + y, -Math.sin(Math.PI / 4) * radius + x, -Math.sin(Math.PI / 4) * radius + y);
curveTo(-Math.tan(Math.PI / 8) * radius + x, -radius + y, x, -radius + y);
curveTo(Math.tan(Math.PI / 8) * radius + x, -radius + y, Math.sin(Math.PI / 4) * radius + x, -Math.sin(Math.PI / 4) * radius + y);
curveTo(radius + x, -Math.tan(Math.PI / 8) * radius + y, radius + x, y);
endFill();
}
}
Attaching Movieclips Using Data From An Array
Hi all,
I am working on a site that is in dual langauges, I have a list of pages (home, contact, photos, etc) for which I have made movieclips for named "ENhome", "DEhome", "ENcontact", "DEcontact" where the first two letters identify the language and the following part represents the page.
What I would really like to do is be able to take my page from an array of values already stored, and then append the language identifer to the front, and then call
whatever = new [lang + page]();
or something like that....
anybody got any ideas if something like this is possible....?
Thanks
Adding MovieClips To An Array Via For Loop
I have 91 seperate movieclips that make up a maze. I need them to put them in an array, so that I can use the hitTestObject to see if the guy hits the maze. Right now I have the following code, but it doesn't seem to be working.
Code:
var mazeArray:Array = new Array();
for(var i:Number = 1; i<=91; i++)
{
var c:MovieClip = this.getChildByName("maze"+i) as MovieClip;
mazeArray[i] = c;
}
Thanks!
Pushing Multiple Movieclips In An Array
my problem is simple... i have a lot of movieclips in the library, all of then are exported and have similar class names (class1, class2,...). to insert those movieclips in the array i use:
array.push(new class1());
but i dont want to make that for every single movieclip.
i even tried using a for function with a string to generate the of the movieclip but it was hopeless from start. (knew that strings wouldnt work, it was just a desperate guess).
So... is there anyway to do it?
Attach Scrollbar To An Array Of Movieclips
Hi,
I am using an xml feed. I parsed it out and placed some text,images,buttons in different movieclips and added the movieclips to an array.
Now I want to display this array/list of arrays with a scrollbar. Don't have an idea how to do it. Searched for various components but didn't find anything useful. Searched the forums here but still no luck. http://www.actionscript.org/forums/i...s/confused.gif
The answer may turn out to be trivial but I am a novice and I really need help regarding this.
Thanks a lot in advance.
Loading An Array Of Jpgs Into Movieclips
in this code, I am trying to load a bunch of .jpg images into existing movieclips that are named gridClip.mc1,gridClip.mc2...gridClip.mc14.
The names of the jpgs to load are already in the array "imageArray[ ]".
The problem is that of a syntax error in the line:
var "gridClip.mc"+(kount+1):MovieClipLoader = new MovieClipLoader();
Ordinarily you'd have something like "myVar:MovieClipLoader = new MovieClipLoader();" but I need the var to change to reflect the clip that the image is being loaded into... gridClip.mc1, gridClip.mc2 etc.
What I want to achieve is a "progress report" that displays something like: x images out of y images have been loaded.
Any ideas on a simpler way of doing this than what I am currently trying?
Attach Code
for (kount=0; kount<numImages; ++kount) {
tempDir="Loading image "+kount+" of "+numImages+" images";
//loadMovie("thumbImages/oil/"+imageArray[kount], "gridClip.mc"+(kount+1));
var mclListener:Object = new Object();
var "gridClip.mc"+(kount+1):MovieClipLoader = new MovieClipLoader();
"gridClip.mc"+(kount+1).addListener(mclListener);
"gridClip.mc"+(kount+1).loadClip("thumbImages/oil/"+imageArray[kount],"gridClip.mc"+(kount+1));
}
An Array Defining Properties Of Movieclips?
This is probably impossible and to me it certainly seems like it anyway.
i have an array called myarray and a movieclip containing a square.
my array contains user specified items about X, Y, Width, Height and Alpha.
Is there anyway to use one line of code e.g. myMovie.allProperties = myArray[0];? without having to go through each property in turn?
Assigning Functions To Movieclips In Array
I'm creating a menu from mcs loaded from the library, I want to assign an onRelease function to each of the menu items which i'm storing in a temporary array when created... basically this: -
Code:
//loop and attach menu items for the number of items in layLength
for(var i=0, j=0; i < layLength; i++){
var temp = container.attachMovie("menuItemMC", "menuItemMCxxx" + i, i);
temp.img = as2obj.boat.img[i].attributes.file; //some xml data
tempArray.push(temp);
y++;
}
//Assign onRelease events to each menu item loaded
for(g in tempArray){
tempArray[g].onRelease = function() {
trace("I am associated with " + tempArray[g].img);
}
}
the problem is the functions assigned to the created movieclips will just default to the current value of 'g' I.e. when trace is triggered it will trace the tempArray value of whatever g is currently, I want it to remember the value at the time the function is assigned to the movie.
Sorry for the poor explanation, my english is bad... I'm british :S
Thanks
Dan
MovieClips In Array With Event Listeners.
Hey guys, everyone's been real helpful the few times i've been here so I figured i'd run my question here.
I have an array with about 18 movieclips.
I added mouse click event listeners to each one through a for loop
Code:
for(var i:int=0; i<covers.length; i++) {
covers[i].addEventListener(MouseEvent.CLICK, highlight);
}
That works fine, but when i click cover[i] (which ever one it may be) I need it to tell me which one was clicked. I needs to return the array id number, not like an x or y property of the MC.
I could add the events manually per movieclip, but i'd rather keep it grouped in an array as it's likely that there will be many more added in the future.
Thanks in advance!
|