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

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
LVL 1
TezdreadAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
muxxterConnect With a Mentor Commented:
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
 
TezdreadAuthor Commented:
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
 
Ben McNellyCommented:
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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
TezdreadAuthor Commented:
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
 
muxxterCommented:
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
 
TezdreadAuthor Commented:
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
 
TezdreadAuthor Commented:
Gave when I do that I get a new window (not the size speified) popup with text saying Here?
0
 
TezdreadAuthor Commented:
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
 
muxxterCommented:
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
 
muxxterCommented:
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
 
ch2Commented:
< 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
 
ch2Commented:
The only way is creating a Flash pop-up window.

Good luck!
0
 
ch2Commented:
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
All Courses

From novice to tech pro — start learning today.