?
Solved

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

Posted on 2006-11-14
13
Medium Priority
?
352 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 420 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses

741 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