Solved

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

Posted on 2006-11-14
13
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

730 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