Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

create pop-up window with close button

Participant ,
Oct 26, 2012 Oct 26, 2012

hi , i want to create a popup window with close button and it`s be great if there is minimize and dragable .

i search around google but i only find some popup window with JavaScript code and load URL

what i want :

1- there is button like more info

2- i want when i click it a window (layout) appear , i want to load (show) some content like : text , images , movieclips from my library

3-i need a close button that remove (close) my window

i try to not use AS3 and use Frame and graphic Technics to create popup window but it make me so confused, and i think it`s better to use some load and unload movieclip script or something's like that

anyone can help ?  thanks so much

TOPICS
ActionScript
6.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 27, 2012 Oct 27, 2012

just like ned mentioned, you made rectangle local to fl_clickToGoToAndPlayFromFrame_2.  to make rectangle available outside that function call, use:

var rectangle:MovieClip

enter_mc.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_2);

function fl_ClickToGoToAndPlayFromFrame_2(event:MouseEvent):void

{

rectangle= new my_rectangle();

addChild(rectangle);

}

removebt.addEventListener(MouseEvent.CLICK, sos);

function sos(event:MouseEvent):void

{

    removeChild(rectangle); 

}

Translate
Community Expert ,
Oct 26, 2012 Oct 26, 2012

you'll need to create that yourself or search for an as3 window component that does what you want.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 26, 2012 Oct 26, 2012

any tips or guide about whats the best way ?

can you help any script to load an Movieclip ??   

i just need script to load movieclip and another for unload it

any free component ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 26, 2012 Oct 26, 2012

use google to search for a free component.

to add a movieclip that's in your library, use the "new" constructor:

var mc:MovieClip = new MC();  // where MC is the class of a library movieclip.

addChild(mc);

//

to remove it:

removeChild(mc);

mc=null;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 27, 2012 Oct 27, 2012

thanks Kglad , the add movie clip work  well with your script but i get an error when try to use remove child

can you help me ?

this is my script :

enter_mc.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_2);

function fl_ClickToGoToAndPlayFromFrame_2(event:MouseEvent):void

{

var rectangle:MovieClip = new my_rectangle();

addChild(rectangle);

}

removebt.addEventListener(MouseEvent.CLICK, sos);

function sos(event:MouseEvent):void

{

    removeChild(rectangle); 

}

i have 2 button :

1-enter_mc  for addchild

2-removebt for removechild

and my movie clip name & class : my_rectangle

after test this error show and nothing work :

Scene 1, Layer 'Layer 2', Frame 1, Line 161120: Access of undefined property rectangle.

and maybe it will be important :  my removebt (Close button ) is placed in my my_rectangle movie clip

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 27, 2012 Oct 27, 2012

You need to declare the rectangle variable outside of the function if you want to access it in different functions.  Otherwise its scope is limited to within the fl_ClickToGoToAndPlayFromFrame_2 function

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 27, 2012 Oct 27, 2012

just like ned mentioned, you made rectangle local to fl_clickToGoToAndPlayFromFrame_2.  to make rectangle available outside that function call, use:

var rectangle:MovieClip

enter_mc.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_2);

function fl_ClickToGoToAndPlayFromFrame_2(event:MouseEvent):void

{

rectangle= new my_rectangle();

addChild(rectangle);

}

removebt.addEventListener(MouseEvent.CLICK, sos);

function sos(event:MouseEvent):void

{

    removeChild(rectangle); 

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 27, 2012 Oct 27, 2012

thanks Dear Ned and Kglad .

All things work perfect now Only one Problem

i need removebt button in my movie clip to work as Exit (close) button for my popup window

when i put removebt in my main stage everything work nice but when i move my button to my_rectangle movieclip the 1120: Access of undefined property rectangle error comes again and all things failed ....

i try to add some : this.   , parent.  , root. to script but no sucess ...

i`m so sorry can you help me for Complete my Request please

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 27, 2012 Oct 27, 2012

where's the code for your button?  the timeline that contains my_rectangle (after it's added)?  if yes:

var rectangle:MovieClip

enter_mc.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_2);

function fl_ClickToGoToAndPlayFromFrame_2(event:MouseEvent):void

{

rectangle= new my_rectangle();

rectangle.removebt.addEventListener(MouseEvent.CLICK, sos);

addChild(rectangle);

}

function sos(event:MouseEvent):void

{

    removeChild(rectangle); 

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 28, 2012 Oct 28, 2012

Dear Kglad thanks for replay again , unfortunatly with new script new problems comes ...

var rectangle:MovieClip

enter_mc.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_2);

function fl_ClickToGoToAndPlayFromFrame_2(event:MouseEvent):void

{

rectangle= new my_rectangle();

rectangle.removebt.addEventListener(MouseEvent.CLICK, sos);

addChild(rectangle);

}

the RED line in scripts make errors after compile ....

I have 2 button

1- in my main scene ( enter_mc ) 

2- exit button that put in the my_rectangle movieclip and i want to use Removechild to simulate close window

blow i have the code that works well when i move removebt button to main scene frames and all my script is in main scene frame ....

------------------------------------------------------------------------------------------------------------------

var rectangle:MovieClip

enter_mc.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_2);

function fl_ClickToGoToAndPlayFromFrame_2(event:MouseEvent):void

{

rectangle= new my_rectangle();

addChild(rectangle);

}

removebt.addEventListener(MouseEvent.CLICK, sos);

function sos(event:MouseEvent):void

{

    removeChild(rectangle);

}

----------------------------------------------------------------------------

but the problem comes when i move it to my_rectangle movieclip to work as close icon button the problem comes

i Try what you recommended and put the code in my movie clip but still get error

wwe.jpg

i put a link if for my bad english you cant get my reason exactly

download link

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 28, 2012 Oct 28, 2012

when you add removebt to your rectangle movieclip, you have to assign it an instance name (in the properties panel) of removebt.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 28, 2012 Oct 28, 2012

yes removebt have instance name .

i try to add some other function like :

removebt.addEventListener(MouseEvent.CLICK, sos);

function sos(event:MouseEvent):void

{

   

gotoAndPlay (2);            <<

}

and it run without any problem ...

the problem comes when i put

    removeChild(rectangle);

and Move my Removebt button to my rectangle movieclip ....

i cant figure it out why this happend

maybe if Compiler Errors Give me some more info about this error i could but now ///

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 28, 2012 Oct 28, 2012

does removebt exist on frame 1 of rectangle?  if not, add it there and use the code i suggested.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 29, 2012 Oct 29, 2012

thanks so much

finally it works ...

i put all my script in main scene this time too

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 29, 2012 Oct 29, 2012
LATEST

great.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines