Solved

Help in adding: window.open Javascript into Actionscript on a Flash Button

Posted on 2006-11-14
13
333 Views
Last Modified: 2012-06-27
Hi,

I need help in getting a Flash button to open, resize and modify a new browser window.

I've been advised that this is possible in this thread: http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_22059013.html

I just don't know all the steps I need to take in Flash to accomplish this.

I tried doing the following but it hasn't worked.

Created new Flash file called button_popup.fla
Created a button and called it popup_button
Right clicked on popup_button and went into Actions
In Actions I added the following:
--------------------------------------------------------------------------------
button.onRelease = function() {
      getURL("JavaScript:window.open('http://www.javascript-coder.com','mywindow','location=1,status=1,scrollbars=1,width=100,height=100');");
}
--------------------------------------------------------------------------------
When I used the Check syntax I got the following error:
--------------------------------------------------------------------------------
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Statement must appear within on handler
     button.onRelease = function() {

Total ActionScript Errors: 1        Reported Errors: 1
--------------------------------------------------------------------------------

So, can someone advise me what I need to do to get a very basic button to open a new browser window on a particular page will resize and remove toolbar, scrollbar and everything else other than the min & close button?

Thanks
0
Comment
Question by:Tezdread
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 1

Author Comment

by:Tezdread
ID: 17941356
just noticed that on the above it only says button not popup_button but I get the same error on popup_button and I used onRelease because I saw that somewhere else but would rather have onClick but couldn't find that?
0
 
LVL 8

Expert Comment

by:Ben McNelly
ID: 17941523
I have made an Flash document explaining this.

- http://j3one.com/EE/flash/popup.html

Also here is the FLA so you can see the how to implement this example

- http://j3one.com/EE/flash/popup.fla
0
 
LVL 1

Author Comment

by:Tezdread
ID: 17941910
ah...sorry I should have mentioned (in this thread) that I can't use Javascript within the HTML page only in the Actionscript...This I was lead to believe is possible??

In the last thread I explained that I can't use any Javascript in the HTML so i posted this one to get help in getting the JS to work in an SWF file onle but it's looking more and more likely that it's not going to be possible??

 
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 7

Expert Comment

by:muxxter
ID: 17950324
Hi Tezdread.

What's happening is, since you're adding the Actionscript to the actions pane of the button (not the layer), you need to use different syntax when assigning onRelease events. Also, I believe in your initial question, you called the button "popup_button".
Try this:

on(release) {
     getURL("JavaScript:window.open('http://www.javascript-coder.com','mywindow','location=1,status=1,scrollbars=1,width=100,height=100');");
}
...

Cheers
Gav
0
 
LVL 1

Author Comment

by:Tezdread
ID: 17950906
Thanks Gav,

Not sure I'm doing the right thing because I copied the code you posted but when I click the button nothing happens?

I created a new flash file called popupButton.fla
Created a small oblong then converted this to a symbol / button called popup_button
Then right clicked this button and selected Actions
In the blank actions window, I copied the code you posted
Then I published the fla file and opened the HTML file that was outputted

Like I say, nothing happens?
0
 
LVL 7

Accepted Solution

by:
muxxter earned 140 total points
ID: 17951089
Hmm.
Add a trace statement:

on(release) {
    trace("HERE");
     //getURL("JavaScript:window.open('http://www.javascript-coder.com','mywindow','location=1,status=1,scrollbars=1,width=100,height=100');");
}

Then try just previewing the fla from Flash (ctrl+enter) and clicking on the button. It should at least show the trace.

Gav
0
 
LVL 1

Author Comment

by:Tezdread
ID: 17955275
Gave when I do that I get a new window (not the size speified) popup with text saying Here?
0
 
LVL 1

Author Comment

by:Tezdread
ID: 17955328
also after taking a look at the HTML Code in the page that Flash generates, it puts the Javascript in there which as I keep explaining isn't going to work........?

I'm sorry but if I can't get an SWF button/file to open a new browser window without having to have Javascript in the HTML it's a waste of time, and points. The whole point was to get around having Javascript in the HTML page....
0
 
LVL 7

Expert Comment

by:muxxter
ID: 17957404
Yep, the new window that pops up is actually Flash's output panel. Any trace(<text>) you call will print <text> to it.

The HTML page that Flash produces when you publish the fla is just a wrapper. You can delete everything except the <object> tag, and it'll still work.

Anyways, from that trace statement, I now know that the button's release event is being broadcast and it is calling the code inside the on() handler. So let's start with something simple:

on (release) {
    getURL("javascript:var myWin = window.open('http://www.javascript-coder.com'); myWin.focus(); void(0);");
}

Let me know how that goes.
Gav
0
 
LVL 7

Expert Comment

by:muxxter
ID: 17957409
Ooh Tezdred, I found a nice tutorial on kipura.com that I think would be quite helpful:

http://www.kirupa.com/developer/mx/centered_popup.htm

Later
0
 
LVL 11

Expert Comment

by:ch2
ID: 17994976
< Javascript is disabled and not allowed

You can't even with Flash. It's disallowed since the server traces it as javascript. No way.

0
 
LVL 11

Expert Comment

by:ch2
ID: 17994985
The only way is creating a Flash pop-up window.

Good luck!
0
 
LVL 11

Expert Comment

by:ch2
ID: 17995007
If the script don't run even in your local computer, change the allowScriptAccess param.

<param name="allowScriptAccess" value="always" />
<embed allowScriptAccess="always" />

maybe you guess how they disable the scripts.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question