Forum Moderators: open

Message Too Old, No Replies

Flash buttons to scroll an Iframe?

Currently using gifs

         

Mikeboy

12:13 am on Feb 9, 2004 (gmt 0)

10+ Year Member



I'm currently using the following to scroll the content in my fixed size Iframe.


<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

winstun

4:24 pm on Feb 9, 2004 (gmt 0)

10+ Year Member



G'day!

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

Mikeboy

4:49 pm on Feb 9, 2004 (gmt 0)

10+ Year Member



Thanks a lot Winstun, that's great.

I'll have a go, I'll be back if I get stuck!

Mikeboy

2:53 pm on Feb 10, 2004 (gmt 0)

10+ Year Member



Ok I've been trying this all morning with no luck!

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

winstun

6:20 pm on Feb 10, 2004 (gmt 0)

10+ Year Member



G'day,

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;");
}

When this is done you should have an mc with 3 layers, from top to bottom - 1. actionscript, 2.invisible button, 3.button graphics.

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

Mikeboy

10:09 pm on Feb 10, 2004 (gmt 0)

10+ Year Member



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]

winstun

4:13 pm on Feb 11, 2004 (gmt 0)

10+ Year Member



I checked out your .fla and it looks good.

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

Mikeboy

6:07 pm on Feb 11, 2004 (gmt 0)

10+ Year Member



Winstun , that's it!

I just removed the 'return true' bit and it works great

Thank you so much for your time!

Mike :):)

Mikeboy

6:21 pm on Feb 11, 2004 (gmt 0)

10+ Year Member



edit,

Works perfect now:)

Thanks again mate!

winstun

9:31 pm on Feb 11, 2004 (gmt 0)

10+ Year Member



Thanks a lot, Mikeboy!

Glad I could help out.

Cheers,
winstun