Skip to main content
Inspiring
June 28, 2008
Question

creating functions for movie-clips(serious problem)

  • June 28, 2008
  • 30 replies
  • 2426 views
Hello,
This is I think my third thread on these forums and in my previous threads I had always got some help.Well, now I have another serious problem, can you help me?
I am unable to create a function that can control movie clips. Let me explain:-
I have 10 movie clips on the stage and I have assigned them that whenever they crash to an object, they will go to a random position. Writing this code ten times for each movie clip would be very tedious, so, I thought about creating a function, but, it doesn't work. Here's the function, can you correct it?

var object:movieClip;
function position(object) {
var testnum1:Number;
testnum1 = random(290)+36;
_root.object._y = -77.6;
_root.object._x = testnum1;
}
position(nameofmovieclip)

PLEASE HELP IS REQUIRED!!!!
Thanking All,
Chinmaya
This topic has been closed for replies.

30 replies

Participating Frequently
June 29, 2008
Best wishes to your game. :)
Inspiring
June 29, 2008
Great! Its Working Now!
Here, take a look:

http://img179.imageshack.us/my.php?image=wasteseperationgamecompqg6.swf

At last, my mini game is complete, thank you (now I'll think about adding different scores for different objects.(which is quite easy),
Chinmaya
Participating Frequently
June 29, 2008
_parent.gotoAndPlay(...);
Participating Frequently
June 28, 2008
What a kind and interesting game!

How did you work it out?
Inspiring
June 29, 2008
I worked out the game using character movement script, hitTests and that falling code, all these combined created the basic working. I have recently added a timer also(of 60 seconds).
I just have 1 last question!
Is there any way of accessing variables from a previous scene.
For eg. if I want to use or change a variable names "countdown" from scene 2 in scene 3.
The problem is that I have said in Scene 2 that if countdown is lower or equal to 0, then gotoAndStop at scene 3. Now my play again button at scene 3 doesn't work and keeps taking me back to scene 3.(I wish to go to scene 1)
This is the last question (100%),
Thanks,
Chinmaya
Participating Frequently
June 28, 2008
Oh I know. I was in a wrong page.
It is in the stage or not, just check y<maxy
Inspiring
June 28, 2008
Participating Frequently
June 28, 2008
Thank you.

I can see many many balls falling from the sky.
And where is your robot? How to ctrl your robot..?
Inspiring
June 28, 2008
lol.. If you fixed there is no need for uploading your source code. :)
Of course I dont understand what was the error but nvm.. The most important is that you fixed. xD

__smileHair.. For the robot, go to the given page, click once (with mouse) on the flash file (to activate it) and then use the keyboard keys... If you catch the falling item (car) you have to go your robot to the correct disposal! :P

Inspiring
June 28, 2008
Well....
I have got it to work!!!!!!!!!!!!!!!!!!
How?
Well you see...
I put the code for controlling the robot and this function on seperate frames each under their own onEnterFrame functions. Now I put both in the same frame, and now it works. I dont know how, but it does. Thank you everyobody(mostly _smilehare) for trying to find a solution for me.
I'll try to upload the .fla, terablade2001, but I am not sure I can do it right now.
Thank you smilehare and terablade,
Chinmaya
Participating Frequently
June 28, 2008
How can I play the game... need help..
Participating Frequently
June 28, 2008
You're welcome.

I can't find any problems in it. It seems perfect..