Skip to main content
Inspiring
Mar 21, 2014 5:49 PM UTC
Answered

Help making a MovieClip to be a popup

Hi guys

I have a a scene in the stage as the background with a text saying to press anywhere...

When someone clicks on it, a MC will appear asking something...

My question is... how can I make this MC to be a pop up instead of being on the stage?

This is what I have, so far:

private var initialScreen:Loader;

private var pos:TextField;

private var pos_holder:Sprite;

private var fmat:TextFormat;

..............................................

initialScreen = new Loader();

initialScreen.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);

initialScreen.load(new URLRequest("1.jpg"));

fmat = new TextFormat();

fmat.font = "Times New Roman";

fmat.size = 105;

fmat.color = "0x0000FF";

 

pos = new TextField();

pos.defaultTextFormat = fmat;

pos.autoSize = TextFieldAutoSize.CENTER;

pos.text = "Click anywhere";

pos_holder = new Sprite();

pos_holder.addChild(pos);

private function onComplete(e:Event):void {

initialScreen.width = stage.stageWidth;

initialScreen.height = (stage.stageHeight * 1.5);

initialScreen.x = 0;

initialScreen.y = ((stage.stageHeight/2) - stage.stageHeight);

addChild(initialScreen);

pos_holder.width = stage.stageWidth * 0.8; // 80% width relative to stage

pos_holder.scaleY = titulo_holder.scaleX; // To keep aspectratio

pos_holder.x = stage.stageWidth / 2.2;

pos_holder.y = (stage.stageHeight * 0.2);

stage.addChild(titulo_holder);

initialScreen.addEventListener(MouseEvent.CLICK, popup);

}

private function popup (e:MouseEvent):void {

var question1:MovieClip = new MovieClip();

question1.graphics.beginFill(0xFF0000);

question1.graphics.drawRect(0, 0, 100, 80);

question1.graphics.endFill();

question1.x = (stage.stageWidth * 0.40);

question1.y = (stage.stageHeight * 0.70);

addChild(question1);

 

                    }

**** I haven´t finish making the MC yet, since it will have a couple of buttons and a text... but I need it to be like a popup and now it just appears on the background

Thanks!!!

This topic is closed to new replies. Start a new post to keep the conversation going.
Ned Murphy
Ned MurphyCorrect answer
Legend
Mar 21, 2014 6:17 PM UTC

One way is to make the movieclip invisible/visible as needed.  It still lives on the stage but you only see it when you tell it to be visible.

Another way would be to assign a Class name to the mc in the library, and then when you want to make it show you create an instance of it, much the same way you do withthe pos textfield.  When you want it to go away you remove it.

4 replies

Ned Murphy
Ned MurphyCorrect answer
Legend
Mar 21, 2014 6:17 PM UTC

One way is to make the movieclip invisible/visible as needed.  It still lives on the stage but you only see it when you tell it to be visible.

Another way would be to assign a Class name to the mc in the library, and then when you want to make it show you create an instance of it, much the same way you do withthe pos textfield.  When you want it to go away you remove it.

Translate
SirMarleyAuthor
Inspiring
Mar 21, 2014 7:05 PM UTC

Great!!!!

Is there a way to have this MC with like a 3d border or something to make it look like a real pop up?

Translate
SirMarleyAuthor
Inspiring
Mar 21, 2014 8:00 PM UTC

I have something "like" what I was looking for:

.graphics.lineStyle(4, 0x666666, 1, false); and I make the color of the MC white (FFFFFF)

  If you have anything with a better outcome, let me know, please.

Thanks!!!

Translate