PDA

View Full Version : moving to top of page


chacko
11-28-2001, 11:51 AM
hai all

i have created a flash page which is very big ;-). you must scroll down to see the entire page(contains lot of text). my problem is that i want to put a button at the bottom of the page which if clicked move the focus to top of the page.

can anyone help me in this regard ??

Chacko

jimburton
11-29-2001, 09:37 AM
You could try using the Selection object and setFocus on an input field, although I've not tried to jump around the page myself in this way.

I think there's a tutorial on setFocus if you want to have a look...

chacko
11-29-2001, 01:27 PM
thanks jim

i will try that

Any other suggestions ???

Chacko

Jesse
11-30-2001, 05:16 AM
Why not just use an HTML anchor at the top of the page?

Taldos
11-30-2001, 02:48 PM
if u are already using a scroll bar why not just reset the value of the scroll back to it's original position. that would bring you back to the top of the page.

le me know if that makes sense

thanx and be well

chacko
12-01-2001, 06:51 AM
hai

thanks for u r replies

Jesse, how can i make a HTML Anchor to the top of page from the bottom of the flash page.?

Taldos, the scroll bar is not which i created in flash. its of the browser. any other way ?

can u help!!!!!!!!

Chacko

Taldos
12-01-2001, 02:15 PM
if that is the case then your code has to be done in html as you are telling the window itself to reset the focus. don't konw much about html, perhpas someone else could help you out there

pigghost
12-01-2001, 04:38 PM
Hi chacko...put this on your button...

on (release) {
getURL ("javascript:window.scrollTo(0,0)");
}


...I've played around with this some, and it seems to work in most browser/OS combinations with PC (not sure about MAC, though)

...the two parameters in window.scrollTo(x,y) are the x/y coordinates of the window..."0,0" takes you to the upper left....by changing the "y" you can jump around to different positions on the Flash page much like an HTML anchor...

Hope this helps...

-pigghost-

EDIT: For some reason I keep getting a space between "java" and "script"...that shouldn't be there...it's one word....:)

Taldos
12-01-2001, 07:23 PM
hey i have a question concernig such a use of java script from flash. can you use that same method for any other java piece of code and does your flash have to be published in html or can it be an swf file??

tg
12-01-2001, 08:38 PM
if you use this in a projector.exe, when you use the action getURL, your projector will open up your browser with no page loaded and the javascript in the location bar (at least with ie/pc).

you can also wrap pighosts code like this


Movieclip.prototype.scrollTo=function(ypos){
getURL("javascript:window.scrollTo(0,"+ypos+");");
}


then use it like this anywhere.

on(release){
codemc.scrollTo(0);
}


here (http://carl.homeip.net/~tim/test/date_and_scroll.html) is an example with source.

pigghost
12-01-2001, 11:25 PM
Hi tg....quick question...

I've been using prototypes for a brief period of time now and I love em, but I'm definitely still in the learning stage....

I was just curious in this situation why you would opt to use a prototype over say...just a regular function...I mean in this situation I'm not real clear on what the advantage would be...with having the additional "codemc"....

I was just curious what your thoughts were on this....

Thanks...

-pigghost-

Taldos
12-01-2001, 11:47 PM
what is a protype and how come this is the first time i hear about it?? does it have to do with flash and if so what r it's purposes. advantages disadvantages. and should I invest time in learning it.?? let me know

tg
12-02-2001, 03:16 AM
well pigghost, there is no real advantage to using a prototype in this situation really, i only did it here to point out the posibility, if you go to [proto]type, you will see quite a few javascript functions wapped into prototypes(alert box, statusbar,openwindow...).
however, if you have some javascript code you use often in many different project, why not wrap it in a prototype, place it in an external as library file (to include with any project) and then just use the method of the object instead of rewriting the javascript function over and over again. (really though, wrapping javascript functions is a little bit overkill - they are simple enough to write staight out).

taldos, ya, i think you might be interested in prototypes. basically what they do is allow you to write you own customized methods to any as object (like movieclip, array, color...). in this case, once i write a movieclip prototype called scrolltotop, all movieclips in my movie have that method to use whenever. like i said above tho, in this situation is it overkill. however if you do a search here in the forums and in the library for 'prototype' you will see many examples of good helpful prototypes that are really helpful to have and use. many of the string functions in flash are notoriously slow, many have been rewritten as prototype and have increased the execution of the function (split has been rewritten to work as much as 10x faster).

if i havn't touched on all of the points, pros, or cons of prototypes, please feel free to add you comments here, i think this could be a good discussion-learning opportunity(hehe corporate lingo slippin in).

personally you don't really need them, you can build a great function library to work with, i just like the way prototypes keep things object oriented

pigghost
12-02-2001, 05:58 AM
Thanks tg...yeah, I kind of thought it was a bit of an "overkill"...but I figured you had your reasons...:)

...and the external as file makes a lot of sense...I'll keep that in mind...thanks again...

Taldos...here's a link for a little tutorial on OOP(Object Oriented Programming) by Branden Hall of FlashCoders...you may find it useful...

http://chattyfig.figleaf.com/ff2k/sanfran2001/#

-pigghost-

chacko
12-02-2001, 08:44 AM
thanks buddies

i tried geturl("javascript: window.scrollTo(0,0););

it worked .. thanks a lot ... :D

but still i have some doubts..... ;-) as am new in flash

1,

i have about 40 frames in my animation. now i want to make a change in the picture and text which i have in all the 40 frames, postion of which are same in the frames. how can i change the whole text and picture easily ??.. or should i change the picture and text in each frame seperately ? :eek:

2,
how can i play a flash file inside another flash file, in a particular position in the file. ?


thanks for u r help

Chacko

Billy T
12-03-2001, 02:06 AM
Originally posted by chacko

1,

i have about 40 frames in my animation. now i want to make a change in the picture and text which i have in all the 40 frames, postion of which are same in the frames. how can i change the whole text and picture easily ??.. or should i change the picture and text in each frame seperately ? :eek:

If they are symbols then you can simply go into the symbol and change it. If they are not symbols you will have to change them for each keyframe

Originally posted by chacko

2,
how can i play a flash file inside another flash file, in a particular position in the file. ?


use loadmovie and load the external swf into a target movie clip instance in your main scene

cheers

chacko
12-03-2001, 06:00 AM
thanks billy

thanks for u r help

Chacko