Connecting Tech Pros Worldwide Forums | Help | Site Map

Magic persistent Flash Button

karlectomy's Avatar
Member
 
Join Date: Sep 2007
Location: Vermont
Posts: 64
#1: Sep 19 '07
My button won't leave the stage.

I'm programming in AS2.0 using Flash MX2004

I attach the button "again" to the stage and its release function is gameOn where I remove the movie clip.

For some reason, It won't leave the stage...

I've tried to look at everything but maybe I'm missing something.
any help would be greatly appreciated.

Expand|Select|Wrap|Line Numbers
  1. function gameOn()
  2. {
  3.         again.removeMovieClip();
  4. }
  5.  
  6. function gameOver()
  7. {
  8.         attachMovie("again", "again", 201);
  9.     again._xscale = 120;
  10.     again._yscale = 60;
  11.     again._x = 280;
  12.     again._y = 300;
  13.     again.onRelease = gameOn;
  14. }

xNephilimx's Avatar
Expert
 
Join Date: Jun 2007
Location: Buenos Aires, Argentina
Posts: 200
#2: Sep 20 '07

re: Magic persistent Flash Button


Hi karlectomy!
That is no wroking because that's not the correct sintax to the removeMovieClip method.

The correct sintax is the following:
Expand|Select|Wrap|Line Numbers
  1. someMC.removeMovieClip(targetMC);
  2.  
What this does is removing the targetMC that's inside someMC.
If your movieclip "again" is on the root I reccomend to to declare a global variable (that is, outside any function) calld home for example, and making it equal to this (I mean, the "this" pseudo-object), so the variable home, will always be the local root, even inside functions.
Then you can use this as follows:

Expand|Select|Wrap|Line Numbers
  1. var home:MovieClip = this;
  2.  
  3. function gameOn():Void {
  4.     home.removeMovieClip(again);
  5. }
  6.  
Best regards,
The_Nephilim

Quote:

Originally Posted by karlectomy

My button won't leave the stage.

I'm programming in AS2.0 using Flash MX2004

I attach the button "again" to the stage and its release function is gameOn where I remove the movie clip.

For some reason, It won't leave the stage...

I've tried to look at e
verything but maybe I'm missing something.
any help would be greatly appreciated.

Expand|Select|Wrap|Line Numbers
  1. function gameOn()
  2. {
  3.         again.removeMovieClip();
  4. }
  5.  
  6. function gameOver()
  7. {
  8.         attachMovie("again", "again", 201);
  9.     again._xscale = 120;
  10.     again._yscale = 60;
  11.     again._x = 280;
  12.     again._y = 300;
  13.     again.onRelease = gameOn;
  14. }

karlectomy's Avatar
Member
 
Join Date: Sep 2007
Location: Vermont
Posts: 64
#3: Sep 21 '07

re: Magic persistent Flash Button


Thank you very much,

I see what you're saying.

can I attach and remove movie clips from the stage?
xNephilimx's Avatar
Expert
 
Join Date: Jun 2007
Location: Buenos Aires, Argentina
Posts: 200
#4: Sep 22 '07

re: Magic persistent Flash Button


You're welcome!

What do you mean? Dynamically attaching a movieclip to the stage?

Quote:

Originally Posted by karlectomy

Thank you very much,

I see what you're saying.

can I attach and remove movie clips from the stage?

karlectomy's Avatar
Member
 
Join Date: Sep 2007
Location: Vermont
Posts: 64
#5: Sep 22 '07

re: Magic persistent Flash Button


More specifically is this correct?

Expand|Select|Wrap|Line Numbers
  1.  
  2. stage.attachMovie("again","again",201);
  3.  
  4. again.onRelease = stage.removeMovieClip(again);
  5.  
  6.  
xNephilimx's Avatar
Expert
 
Join Date: Jun 2007
Location: Buenos Aires, Argentina
Posts: 200
#6: Sep 24 '07

re: Magic persistent Flash Button


The sintax is correct, but you can't use Stage to do that, the Stage object only contains information about the movie, it is not a reference to the _root.

If you want to attach it to the root you can do as follows:
Expand|Select|Wrap|Line Numbers
  1. var home:MovieClip = this;
  2.  
  3. home.attachMovie("again","again",201);
  4.  
  5. again.onRelease = stage.removeMovieClip(again);
  6.  
  7.  
Best regards,
The_Nephilim

Quote:

Originally Posted by karlectomy

More specifically is this correct?

Expand|Select|Wrap|Line Numbers
  1.  
  2. stage.attachMovie("again","again",201);
  3.  
  4. again.onRelease = stage.removeMovieClip(again);
  5.  
  6.  

karlectomy's Avatar
Member
 
Join Date: Sep 2007
Location: Vermont
Posts: 64
#7: Sep 24 '07

re: Magic persistent Flash Button


Neph,

Thanks for your help. finally it's gone!! YAYAYAYA

Quote:

Originally Posted by xNephilimx

The sintax is correct, but you can't use Stage to do that, the Stage object only contains information about the movie, it is not a reference to the _root.

If you want to attach it to the root you can do as follows:

Expand|Select|Wrap|Line Numbers
  1. var home:MovieClip = this;
  2.  
  3. home.attachMovie("again","again",201);
  4.  
  5. again.onRelease = stage.removeMovieClip(again);
  6.  
  7.  
Best regards,
The_Nephilim

xNephilimx's Avatar
Expert
 
Join Date: Jun 2007
Location: Buenos Aires, Argentina
Posts: 200
#8: Sep 24 '07

re: Magic persistent Flash Button


LOL!
Glad it worked!! You're welcome!

Best regards!
The_Nephilim

Quote:

Originally Posted by karlectomy

Neph,

Thanks for your help. finally it's gone!! YAYAYAYA

Reply