Groups | Blog | Home
all groups > flash actionscript > june 2004 >

flash actionscript : Why am I not accessing MovieClip methods?


JPI
6/4/2004 11:23:00 PM
I have an array full of Strings:
foodToUse = ["berries", "cake", "crab"];

I want to display their corresponding movieClips (who's linkages are set to
"berries, "cake", and "crab") using the array

for (var i = 0; i<3; i++)
{
tmpString = foodToUse;
attachMovie(tmpString, tmpString+i, i, {_x: _root.x, _y: 400});
_root[tmpString+i].gotoAndPlay(2); //doesn't work! Only plays
frame 1.
_root.x = _root.x + 200;
//change x value so they don't overlap.
}

Now this works, however, the Movieclips all play frame 1 instead of frame 2.
Any help would be awesome.

B
6/5/2004 1:03:27 AM
I tested your code and it's working like I expected. Three movie clips display and animate as expected. You don't even need the gotoAndPlay to play the movie clips.

Brenda

JPI
6/5/2004 1:09:00 AM
Yes they do in fact display, and they play. If you'll read my post, that is
not my problem. I need to access the movieClip's properties and methods. The
code instructs the clips to gotoAndPlay frame 2. The result of that code is
that they play, but from frame 1 only.
I tried using _root[tmpString+i]._y = 500, and the clips _y value did not
change.

Again, they play fine, you are correct, but only they play from frame 1, not
frame 2. Any other suggestions?
gorlins
6/5/2004 1:32:54 AM
Brenda's right, your code runs perfectly. Check to make sure you have the
right publishing settings (Flash 7, AS 2.0) and make sure you have stop();
commands on frame 2 or thereafter in each of the movie clips, otherwise it will
loop back to the beginning and look like it's starting on frame 1. I used only
the following code with three movie clips, each with an empty frame 1 with a
stop() and a circle in frame 2 with a stop, and running your code shows all
three circles -- so it's fine. Your problem is somewhere else.

foodToUse = ["berries", "cake", "crab"];
x = 0;
for (var i = 0; i<3; i++)
{
tmpString = foodToUse[i];
attachMovie(tmpString, tmpString+i, i, {_x: _root.x, _y: 400});
_root[tmpString+i].gotoAndPlay(2);
_root[tmpString+i]._y=0;
_root.x = _root.x + 200;
}
JPI
6/5/2004 3:21:09 AM
Thanks people, I do have stop(); 's in the Clips on frames 1 and 2, so it must be somewhere else, maybe I can post the code here after the weekend if the problem persists..
AddThis Social Bookmark Button