Skip to main content
October 22, 2007
Answered

Problem with attachMovie popup windows

  • October 22, 2007
  • 8 replies
  • 759 views
I'm attempting to create popup windows within my flash document using the attachMovie command. The windows are triggered by text buttons on the stage. Should be pretty simple and it is until I try to remove the clip to close it.

I used this code on my button to attach the popup window:

on (press) {
this.attachMovie("popup","window",1);
window._x = 50;
window._y = 50;
}


To remove it I have a button within the MC "popup" with this script attached:

on (press) {
this.removeMovieclip("window");
}

The MC does not dissapear though. Could this have something to do with levels? I'm confused, it seems that it should be simple.

Any feedback would be welcome.
This topic has been closed for replies.
Correct answer kglad
try: this._parent instead of this.

8 replies

October 23, 2007
How would you code that? I assume you would add a line of code in each button calling out which file to load. Would you use loadVars in the window and then control what loads in the button somehow?

I just tried loadVars to see if I could make it work. the HTML isn't loading for some reason but the code is recognized, it pops up an error when I click on the button when I test the movie.

myData = new LoadVars();
myData.onLoad = function() {
popup_txt.html = true;
popup_txt.htmlText = this.myVariable;

};
myData.load("theslidehtml.txt");

The HTML is formatted as a very simple text page although I haven't gone through to check if all the tags are supported. Can you think of anything that would have kept it from loading.
kglad
Community Expert
Community Expert
October 23, 2007
you can use the same popup and assign its text or htmlText property to different strings depending upon which button is pressed.
October 23, 2007
figured out the problem. I hate it when little piddly things take up so much time and then you realize what happened and feel dumb.

The mispelling of removeMovieClip() must have come from the transfer to the forum as it was spelled correctly in the actionscript.

Also using "this" as the object works just fine.

So, what you ask, was the problem? The close button I used inside the popup MC was set to export to actionscript in the library. Turning this off makes the script work flawlessly.

Thanks for your help, it made me think about it just long enough to figure out that one little glitch.

Now: can anyone point out what blunders I should watch out for in attempting to load simple HTML into this window I've made? I have several buttons which will load essentially the same window. Do I need to duplicate it or can I call this same MC for each button and set the loader or dynamic text box inside it to load different files for each depending on which button is clicked?
October 23, 2007
I'm not following you. I should remove the instance name from within removeMovieclip? i.e.:

on (press) {
this.removeMovieclip();
}

or:

on (press) {
this._parent.removeMovieclip("window");
}

This does nothing as well.
I'm afraid I'm missing what you are trying to say. could you right out the code as you would input it for both the button to call the movieclip as well as the close button within the movieclip?

Thanks.
kglad
Community Expert
Community Expert
October 22, 2007
oops. that should be removeMovieClip().
October 22, 2007
I tried it as well as all the combinations of the two. Changing "this" in both makes the popup not appear. Changing it only in the close button does nothing, the movieclip still stays on the stage.
kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
October 22, 2007
try: this._parent instead of this.
kglad
Community Expert
Community Expert
October 22, 2007
no, but it might be related to "this" in your two buttons. are those movieclip buttons or are they true buttons located on different timelines? if yes, that's the problem.
October 22, 2007
They are true buttons. How would you change the "this"? I assumed that the instance name of the button should go there but in trying it it didn't seem to help.