Solved

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

Posted on 2006-11-14
13
300 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 7

Expert Comment

by:muxxter
Comment Utility
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
Comment Utility
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
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 1

Author Comment

by:Tezdread
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
< 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
Comment Utility
The only way is creating a Flash pop-up window.

Good luck!
0
 
LVL 11

Expert Comment

by:ch2
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now