-
edit var from main time line in a movie clip
I'm creating a balloon game where the user is supposed to hit balloons with a needle in order to make them disappear. (have a look at the swf-file).
In the main time line I have created the variable 'lifes' with a value of 4. My intention is that every time the user miss a balloon, he loses a life.
The balloons is a looped movieclip, and I would assume that the best solution would be to put something like this:
life = life-1;
in the end of the balloon movieclip, but the variable does not seem to exist inside the movieclip. I cant even trace it...
Here is links to my .swf and my .fla
.swf
http://www.irritasjon.com/unsw/flash..._blaster_5.swf
.fla
http://www.irritasjon.com/unsw/flash..._blaster_5.fla
-
Hey,
In AS3 you're actually supposed to do everything in the main timeline or document class.
one example:
Code:
//document class
balloon.lifes -= 1;
balloon.someFunction();
this would mean that you can store global variables on the main timeline or in your document class, and access your class/movieclip variables externally.
Dan
-
Try this code:
MovieClip(root).life--;
in your movieclip time line.
-
Originally Posted by dan_hin
Hey,
In AS3 you're actually supposed to do everything in the main timeline or document class.
one example:
Code:
//document class
balloon.lifes -= 1;
balloon.someFunction();
this would mean that you can store global variables on the main timeline or in your document class, and access your class/movieclip variables externally.
Dan
Hmm.. Sorry, I'm new to actionscript. I dont see how this can help me. Could you please explain a little bit more?
-
I still cant make this work....
-
I tried to download your fla, but the link was broken.
Keeping all you AS on the main time line is not a bad idea.
You could check which frame your balloon mc is on by altering the following script to suit your script:
if(balloon_mc.currentFrame == 19 //or whatever the last frame is){
life--;
}
Hope this helps.
-
Originally Posted by friedegg3
I tried to download your fla, but the link was broken.
Keeping all you AS on the main time line is not a bad idea.
You could check which frame your balloon mc is on by altering the following script to suit your script:
if(balloon_mc.currentFrame == 19 //or whatever the last frame is){
life--;
}
Hope this helps.
oh sorry about the faulty links. I have placed it here: http://home.no/baboon/flash/
Should be working.
I tried to use the code in your post. It worked well with a movieclip, but I'm having trouble as the balloons flying by are array/children-balloons..
hmm..
-
and one more thing. I would like the balloons to appear more and more often as a way of making the game more difficult, but I cant manage to do it. I would assume there is an easy solution. Just adding something to the loop somewhere...
-
I’ve downloaded your fla and have some comments:
First your script is unorganized. For example: You have script for the mountains on lines 5, 6 and 8, then again on line 20 and 21, and again on line 46. I like to keep my script ‘tidy’, so that if I have a problem with the mountains, I don’t have to scroll through lines of unrelated script to find the one or two lines I’m looking for. If you spend a few minutes rearranging the script, you might be able to see what problems you have.
You have the balloon mcs as animated movie clips. I would have the balloons rise using action script.
There is a missing bracket or parentheses somewhere (or maybe reversed). I was only able to glance through quickly but something just doesn’t look/work right. I'm getting output errors.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|