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

Creating Pop up Window from Flash with Actionscript 3

New Here ,
May 05, 2011 May 05, 2011

Copy link to clipboard

Copied

Hello!

Im still new at this but would appreciate some help with this.

I have created a Flash banner with Actionscript 3.

Within the banner I would like to make an animated button that when clicked will open

another swf file within a pop up window with specified dimensions.

I have found java codes that work with Actionscript 2,

and also with Flash player 5 and lower.

But my banner uses effects that require me to export the clip no lower than Flash player 10.

Can I still create a pop up window with specific dimensions?

Thank you very much in advance for your help!!!

Kindest regards,

Coz

TOPICS
ActionScript

Views

17.5K

Translate

Translate

Report

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
Mentor ,
May 05, 2011 May 05, 2011

Copy link to clipboard

Copied

If you'r going to show another swf within your swf, then just create a new movieclip and load the swf inside that and keep the depth to the highest level to show the popup.

Votes

Translate

Translate

Report

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
New Here ,
May 05, 2011 May 05, 2011

Copy link to clipboard

Copied

First, thank you for your help!

Actually, the plan is..

The header is an SWF.. within this clip I made a button..

When clicking on this button, a separate window must open with containing an swf file that is much bigger than the header.

For this separate swf file, I have already embedded it within an HTML page. But I want this HTML page to open with the dimensions

900 x 800 exactly.

I hope I explained this well enough.. Any ideas?

Votes

Translate

Translate

Report

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 ,
May 05, 2011 May 05, 2011

Copy link to clipboard

Copied

In as2 or as3 you can use ExternalInterface.call() function to call javascript function of your html wrapper  and in that javascript function you can write code for opening your externl html popup window using window.open

Votes

Translate

Translate

Report

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
New Here ,
May 05, 2011 May 05, 2011

Copy link to clipboard

Copied

Hi there, Thank you also for your help! I think you basically said the same as the other answer. But I dont think I have enough background

to understand completely what was said..

What I do understand is I can use an Externalinterface.call() command (first time I heard of that) to call a javascript function to open that external html

file containing the swf.   Is this correct?

I think I will need to use AS3 because it will need to be exported in no less than flashplayer 10.

I have found some java codes on line that might work to open the external html, like this one...

var jscommand:String = "window.open('http://www.adobe.com','win','height=200,width=300,toolbar=no,scrollbars=yes');"; var url:URLRequest = new URLRequest("javascript:" + jscommand + " void(0);"); navigateToURL(url, "_self"); 




though I am not sure if it is good.

And when I am done with all the coding, I can just add it with the actionscript tab?

Votes

Translate

Translate

Report

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
Mentor ,
May 05, 2011 May 05, 2011

Copy link to clipboard

Copied

<a href="javascript:NewWindow('index_scorm.html?yup=1','asdasd','900','800','no','center');">

The above is the html code, Just implement with the button click using the external interface.

Votes

Translate

Translate

Report

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
New Here ,
May 05, 2011 May 05, 2011

Copy link to clipboard

Copied

OK sounds good, I will go try this now.. Sorry, but I am afraid I will mess this up.

I am very very new at this. I can add this code to the button no problem.

You kind of lost me with the external interface though. is this the only code I will need?

Votes

Translate

Translate

Report

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
New Here ,
May 05, 2011 May 05, 2011

Copy link to clipboard

Copied

Hi relaxatraja,

I just tried using your code. I like that you gave me that. Im sure I did NOT use it well. I got an error in flash that reads...

(1100: syntax error XML does not have matching begin or end tags.)

So I think I forgot alot..

-------

May I attach this code to the button using the actionscript tab?

(really new at this)..

Votes

Translate

Translate

Report

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 ,
May 05, 2011 May 05, 2011

Copy link to clipboard

Copied

This should open a 900 x 800 window with the URL:

        function click(e:MouseEvent):void {
            ExternalInterface.call("window.open", "http://www.adobe.com/", "win", "width=900,height=800");
        }

(You don't need Javascript in the HTML with this )

Votes

Translate

Translate

Report

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
Mentor ,
May 05, 2011 May 05, 2011

Copy link to clipboard

Copied

Open your html version that you used to embed your flash:

Add this script within the head tag:

<SCRIPT LANGUAGE=JavaScript>
        function openNewWindow(URLtoOpen, windowName, windowFeatures) {
          newWindow=window.open(URLtoOpen, windowName, windowFeatures);
        }
</SCRIPT>

Open flash and write the below code for the button:

test.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

function fl_MouseClickHandler(event:MouseEvent):void
{
    var url:URLRequest = new  URLRequest("javascript:openNewWindow('http://www.macromedia.com','thewin','height=400,width=400,toolbar=no,scrollbars=yes')");
    navigateToURL(url,"_self");
}

Tested it! works!

Votes

Translate

Translate

Report

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
New Here ,
May 05, 2011 May 05, 2011

Copy link to clipboard

Copied

Ok did it..

I took first code, and placed it within the html page with my swf file in it. (between the head tags) .. just copied and pasted.

then I took the second code, copied it and pasted it within the flash button.

What I got was this error...

1120: Access of undefined property test.

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

did I forget something?

Votes

Translate

Translate

Report

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
Mentor ,
May 05, 2011 May 05, 2011

Copy link to clipboard

Copied

Test is the name of my sample movieclip, give your movieclip instance name

Votes

Translate

Translate

Report

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
New Here ,
May 05, 2011 May 05, 2011

Copy link to clipboard

Copied

Im doing my best. whew.. not easy! 

I think you mean in place of (test) I have to replace that with the name of the instance of the button itself right?

So this is what I have now...

manual_btn.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

function fl_MouseClickHandler(event:MouseEvent):void

{

    var url:URLRequest = new  URLRequest("javascript:openNewWindow('http://www.macromedia.com','thewin','height=400,width=400,toolbar=no,s crollbars=yes')");

    navigateToURL(url,"_self");

}

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

The header I made is called (Header_actionscript3_extrabtn). There is an animated button in this header that when clicked will open a pop up

window with an on-line users manual. That users manual is the swf file that is embedded in the html file which is called (OnlineManual-test.html).

The actual button to click has an instance name of (manual_btn) for manula button.

- so I put this new code with the instance name like you said in the button.

I still get an error 1120: access of undefined property manual_btn.

I am sure the buttons instance name is manual_btn.

Im lost...   any ideas?

Votes

Translate

Translate

Report

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 ,
May 05, 2011 May 05, 2011

Copy link to clipboard

Copied

OK brother.

Because may b you are using tween to animate the button.

And I think you have given the instance name to manual_btn on the end keyframe of tween on timline

you should give same instance name to  the start keyframe of tween also.

Votes

Translate

Translate

Report

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
New Here ,
May 06, 2011 May 06, 2011

Copy link to clipboard

Copied

Hello fellow brother!

thank you for your time and for being cool about this. Yes, the movie clip that I am using as a button is tweened.

So I made sure to include all of it from the beginning to the end.

When I use your code:

m1.addEventListener("click", openNew);

function openNew(e:Event) {

    ExternalInterface.call("openWin");

}

<script language="javascript">

function openWin(){

     window.open('popup.htm','Popup','width=1004,height=657,scrollbars=no, resizable=no,status=no');

}

</script>

---------------------------and I change the instance name of the button to 'm1', thats good right?

this code is now the action for the movieclip.

when I click on it, I receive this error:

1084: syntax error: expecting right brace before semicolon.

Any ideas?

(thanks in advance..)

Coz

Votes

Translate

Translate

Report

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 ,
May 06, 2011 May 06, 2011

Copy link to clipboard

Copied

Dear

This code needs to be in your fla

m1.addEventListener("click", openNew);

function openNew(e:Event) {

    ExternalInterface.call("openWin");

}

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

And this is not the part of fla below code needs to be in which you swf is embeded

<script language="javascript">

function openWin(){

     window.open('popup.htm','Popup','width=1004,height=657,scrollbars=no, resizable=no,status=no');

}

</script>

popup.htm is the html page you want to open on click

And I think relaxatraja example code should also work (i didnt test that) just give the instance name to the button on start and end frame of tween

Votes

Translate

Translate

Report

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
New Here ,
May 06, 2011 May 06, 2011

Copy link to clipboard

Copied

Hi,

Im lucky you are there! Thanks!

Ok, let me see if I  understand ok?

This code:

m1.addEventListener("click", openNew);

function openNew(e:Event) {

    ExternalInterface.call("openWin");

}

------------------------  will be the action of the movieclip to be clicked...

And the movieclip to be clicked has an instance name m1  .. is that good?

this code:

<script language="javascript">

function openWin(){

     window.open('popup.htm','Popup','width=1004,height=657,scrollbars=no, resizable=no,status=no');

}

</script>

-------------------------------- goes with the other swf file that is embedded in the html page I made.

So I need to name the html page (popup.htm).

and place this code between the head tags?

Is this all correct?

Votes

Translate

Translate

Report

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 ,
May 06, 2011 May 06, 2011

Copy link to clipboard

Copied

first one is right

but second one is not

this code

<script language="javascript">

function openWin(){

     window.open('popup.htm','Popup','width=1004,height=657,scrollbars=no, resizable=no,status=no');

}

</script>

needs to in your html page head tag . HTML Page which holds the swf file having button to click to open popup.

U can giv me your mail id so that i can send u running sample. if its still not working.

popup.html and the embeded swf in popup html does not contain any of my code.

Votes

Translate

Translate

Report

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
New Here ,
May 06, 2011 May 06, 2011

Copy link to clipboard

Copied

Hi there,

Ok, I tried it,.. made an html to hold the swf with the button.

I put the java code between the head tags.

Made sure all files are in the same location..

nothing happens..

Here is my mail address

coz@familycards.nl

I would love to view your example files so I can duplicate it exactly and hopefully

finally I can get this to work!!!

I will be waiting ok?

Thank you very much!!

Coz

Votes

Translate

Translate

Report

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 ,
May 06, 2011 May 06, 2011

Copy link to clipboard

Copied

I send u the packet. Its a sample to get u the idea. swf are not the size u want but from this sample u can get the idea of code and the flow. Pls let me know your response

Votes

Translate

Translate

Report

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
New Here ,
May 06, 2011 May 06, 2011

Copy link to clipboard

Copied

You are the best!!!!!

I really appreciate your patients..

Im waiting for the files and I will study them as soon as they come in!

Then I will write you back as soon as I am done ok?

Talk with you soon!!

thanks..

Coz

Votes

Translate

Translate

Report

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
Mentor ,
May 06, 2011 May 06, 2011

Copy link to clipboard

Copied

If it possible send your files to the following id:relaxatraja@aol.com

Votes

Translate

Translate

Report

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 ,
May 06, 2011 May 06, 2011

Copy link to clipboard

Copied

done. is your job done!

Votes

Translate

Translate

Report

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
New Here ,
May 06, 2011 May 06, 2011

Copy link to clipboard

Copied

Hi Anil,

I just wrote you directly,.. the button example you sent me is not responding..

any ideas?

tested with safari and firefox..

Votes

Translate

Translate

Report

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 ,
May 06, 2011 May 06, 2011

Copy link to clipboard

Copied

Surprised!,

Please check

          1. popup blocker in your browswers

          2. flash player version in your browsers

ok send me your files. but make sure they are not in cs5. coz I have cs4

Votes

Translate

Translate

Report

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