Attachmovie (and path) trouble

I have that code in an empty movie clip :

  onClipEvent (load) {\r\rx = new Array ;\r\ry = new Array ;\r\rz = new Array ;\r\rx = [50,100,100,50 ]  ;\r\ry = [50,50,100,100 ]  ;\r\rz = [50,50,100,100 ]  ;\r\r\r\rfor(i = 1;i<5;i++) {\r\r        attachMovie("viewer", "t"+i, i);\r\r        var mc = this["t"+i];\r\r        mc._x = x[i-1];\r\r        mc._y = y[i-1];\r\r        mc.z = z[i-1] ;\r\r        }\r\r}

In the movie I attach :

  onClipEvent (enterFrame) {\r\rpers = (z+_root.d)/_root.d ;\r\r}

The problem is that z doesn’t get to the clips I’m attaching. I thought that doing mc.z would be enough to use z in the attached movie, but it doesn’t seem to work (trace (z) returns nothing).\r\rThanks.\r\rpom 0]

x = new Array ;\ry = new Array ;\rz = new Array ;\rx = [50,100,100,50 ] ;\ry = [50,50,100,100 ] ;\rz = [50,50,100,100 ] ;\r I am Not Supra (joke joke, jubba…), but it looks to me as if you have a reset of z to a new array on every load event of your empty clip?!\r\rWhy not just:\rx = [50,100,100,50 ] ;\ry = [50,50,100,100 ] ;\rz = [50,50,100,100 ] ;\r(no need for that extra declaration…)?\r\rva dormir!..

Hey, you’re the one who needs to go to sleep ! I don’t reset z on load, at least I don’t think I am, since the clip containing the first bit of code only loads at the beginning of the movie. (suppressing the declaration doesn’t do anything)\r\rYou’re right though, I should go to sleep :frowning: \r\rpom 0]

Told you I’m not supra…good night!\rA demain. Va te moquer un peu de notre ami dans le Random/Question post :wink:

ok, a little code clean-up tip for you:\ryou don’t have to declare a new array like this:\raHello = new Array();\rwhen you do this:\raHello = [];\ror this:\raHello = [“this”,“initializes”,“an”,“array”];\rthe array is initialized.\ryou can save a lot of lines by just initializing an array with the square brackets!!\r:) \rjeremy

Still it doesn’t work…\rpom 0]

ily,\r\ronClipEvent() events don’t get passed when you attach. however, onClipEvents on a movie inside an attached movie do.\r\ra good workaround is to put an empty clip in “viewer” that contains the onClipEvent events pathed to _parent. ie:

 \r\ronClipEvent (enterFrame) {\r\r   _parent.pers = (_parent.z+_root.d)/_root.d ;\r\r}

\rotherwise everything looks good. the z’s were passed just fine when i cut and paste your code. perhaps there was an error in the trace action?\r\rcheers.

<<onClipEvent() events don’t get passed when you attach. however, onClipEvents on a movie inside an attached movie do>>\r\rHow do you find out stuff like this, trial and error, or is that stated s’where?\rGood to know anyway!

You need a bunch of books… Flash 5.0 Developer’s Guide has a really good run through from a medium flasher level’s perspective. Flash Action script Game design does a really good number on movie clips as well.

anything on a movie is instance specific. thus one button can be used over and over. it’s a feature, but it can catch you if you don’t watch for it.\r\rthe exception to this rule is with duplicateMovieClip(). then the onClipEvents carry over. incidentally, movies which have been attached to a clip are not duplicated. i guess they fall into the same catagory as variables and properties, which are also not duplicated.\r\ri would recommend a good internet connection over a book any day. i don’t own any flash books. although i must admit, i’ve been sorely tempted to buy moock’s book. i understand brandon hall is writing a book geared towards flash mx and oop. i’ll be sorely tempted to buy that book as well.\r

which one should i buy, i figure since im just starting out amybe i should buy a book since ive done all of the tutoials that i can find but im still dont understand that much…

What does that mean,

onClipEvent() events don’t get passed when you attach
I’m not sure I understand. But your advice took me back on the right tracks. Thanks !!\r\rpom 0]

What Supra means is that actions which are associated to the outside of a movie clip, are not in the library, so by using the “attach” feature, drawing a movie clip into the swf from the library, there is no action script associated with it. If you were to take a movie clip, associate a/s with it, and then place that inside ANOTHER movie clip, then when you attached the container clip, the movieclip inside it would have the a/s associated with it.\r\rhmm… that sounds really confusing.

Oh I see… It’s actually very clear. Thanks Upu. \rNevertheless, the trouble came from a wrong path :frowning: \rpom 0]