Forum Moderators: open
<a href="javascript:;" onmouseover="scroll_iframe('scr1', 10, 'v'); window.status='Hover here to scroll down.'; return true" onmouseout="stopScroll(); window.status=''; return true">
<img src="Images/tri-dn.gif" width="12" height="12" alt="" border="0"></a>
Is there any way to get a Flash button to do the same thing?
Thanks a lot
Mike
You could call the javascript via ActionScript from within Flash.
yourButton.onRollOver = function() {
getURL("JAVASCRIPT: scroll_iframe('scr1', 10, 'v');window.status='Hover here to scroll down.'; return true;");
}
yourButton.onRollOut = function() {
getURL("JAVASCRIPT: stopScroll(); window.status=''; return true;");
}
Replace "yourButton" with the name of your button.
* Note: the above is placed on a new Layer, but in the same frame as your button mc.
** You can also place this on the button itself by subsituting "yourButton" with "this".
Hope this helps,
winstun
I have the following actionscript on the actual button itself. The whole movie conists of just two buttons, so it's all on one layer.
this.onrollOver = function() {getURL ("javascript:scroll_iframe('scr1', 10, 'v');window.status='Hover here to scroll down.'; return true;");
}
this.onrollOut = function() {getURL ("JAVASCRIPT: stopScroll(); window.status=''; return true;");
}
When I check the syntax it says
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Statement must appear within on handler
this.onrollOver = function() {getURL ("javascript:scroll_iframe('scr1', 10, 'v');window.status='Hover here to scroll down.'; return true;");
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 3: Statement must appear within on handler
this.onrollOut = function() {getURL ("JAVASCRIPT: stopScroll(); window.status=''; return true;");
Total ActionScript Errors: 2 Reported Errors: 2
I am confuzzled.
Thanks
When using the "this" identifier the code must be placed inside the movie clip that it is referencing, hence the "this".
So if you want to keep the code where it is then you must change "this" to the name of your button mc.
Here is my usual way of creating a button:
I usually have a movie clip containing all the mouse-states ( rollOver, etc ) with frame labels ("static", "over", "out", "press", etc)indicating the changes in animation.
Then create a new mc and place the mc described above inside and name it "btn1_ani" in the Properties Inspector.
Create a new layer above it and create a fill area that is the shape of the mc on the lower layer.
Convert this to a movie clip. With that mc selected name it "btn1" and set the alpha to 0 in the Properties Inspector.
Create a new layer, you should have 3 now.
On the first frame go into your Actions Panel and paste the following.
btn1.onRollOver = function() {
/*
if your button has any graphical changes with mouse-states place code here
eg. btn1_ani.gotoAndPlay("over");
*/
getURL("JAVASCRIPT: scroll_iframe('scr1',10, 'v');window.status='Hover here to scroll down.'; return true;");
}
btn1.onRollOut = function() {
/*
same as above function. ie. btn1_ani.gotoAndPlay("out"); */
getURL("JAVASCRIPT: stopScroll(); window.status=''; return true;");
}
Go to Scene1 and open your library ( F11) and drag the mc that was just worked on to the Stage.
Name it "myButton" ( or similar ) and there you go.
** Note: All movie clips must have a name if they are to be referenced at any time.
Hope this was of some help to you.
winstun
Thanks again for your help. I really really appreciate it!
I feel that I am almost there. When I put the mouse over the button from within flash it pops up a new window with the javascript in the address bar...
However, when I try and use it in the actual main page I get a javascript error!
Error : 'return' statement outside of function .
I have uploaded the button/mc to
<snip>
I have got the mc with a mc, and the 3 layers , and button states like you said. I dont know what I have done wrong!
If you wouldn't mind taking a quick look it would be fantastic.
Thanks winstun
[edited by: korkus2000 at 4:15 pm (utc) on Feb. 11, 2004]
[edit reason] No code reviews please [/edit]
When you were testing it out did you embed the .swf into the web page with the javascript function placed between the < head > tags?
The .swf will think it's an actual link if the javascript function can't be located.
I just re-read your last post and maybe try to remove the "return true;" part of the getURL string.
I'll try to test more later today when I get more time.
In the mean time, g'luck.
Cheers,
winstun