Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

Scroll Clip with mouseX Value

This is a discussion on Scroll Clip with mouseX Value within the advanced Actionscript 3.0 forums, part of the Flash CS3 eng category; Hi! I've written a class to scroll up a clip based on mouse position.. maybe someone will find it ...


Go Back   Forum Flash CS3 Flash CS4 > English Forums > Flash CS3 eng > advanced Actionscript 3.0

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 08-08-07, 02:21
tem's Avatar
tem tem is offline
Moderator
 
Join Date: Jan 1970
Posts: 488
Rep Power: 39
tem is on a distinguished road
Scroll Clip with mouseX Value

Hi!
I've written a class to scroll up a clip based on mouse position..
maybe someone will find it helpfull..

I'm not a math genius so maybe you can have the same result with less code...

u can find files here:
http://www.thetconcept.com/flepstudio/Sposta_Mouse.zip
(for now they're not in english I'll translate them as soon as I can.. anyway here you can find a quick translation of what are doing the main methods)

on my TimeLine I've got a Clip called clip_mc of 929 px width..


the class I've written:
Code:
package
{
    import flash.display.MovieClip;
    import flash.events.*;
    //sposta mouse= move mouse
    public class Sposta_Mouse extends MovieClip
    {
 
        private var xmouse:Number=0;
        private var xClip:Number=0;
        private var speed:Number;
        private var widthmovie:Number=550;
        private var windthClip:Number=929;
        private var scrollspeed :Number=10;
        private var velocita:Number;
 
 
        public function Sposta_Mouse()
        {
            init();
        }
 
        private function init():void
        {
            stage.frameRate=31;
            initListeners();
        }
        private function initListeners():void
        {
            clip_mc.addEventListener(Event.ENTER_FRAME, sposta);
 
        }
            //move
        private function sposta(event:Event):void
        {
            xmouse = mouseX - (widthmovie / 2);
            // Setto la speed:
            speed = (xmouse) / scrollspeed;
            // se la speed è negativa la rendo positiva..
            if (speed < 0) {
            speed = -(speed);
            }
 
            areaSensibile();
            rallentoScrollEccessivo();
            scrollOpposti();
            stopScroll();
 
            // let's move the clip!
            clip_mc.x=xClip;
        }
    //sensible area
        private function areaSensibile():void
        {
            //se il mouse non è tra questi due punti non sposto
            if (mouseY > 246) {
            speed=0;
            }
 
            if (mouseY < 90) {
            speed=0;
            }
        }
        //here I decrease the excess of scroll witch wasn't cool
        private function rallentoScrollEccessivo():void
        {
 
            if (speed > (xClip*2)) {
            speed = speed/3;
            }
        }
        //here the scroll is inverted..
        private function scrollOpposti():void
        {
 
            //if mouse goes left scroll goes right isn't it?
            if (xmouse < 0) {
            xClip = xClip + speed;
            }
            // e viceversa aka che te lo dico affà
            if (xmouse > 0) {
            xClip = xClip - speed;
            }
        }    
 
        private function stopScroll():void
        {
            // here I'm checking the left end of the Clip
            if (xClip > 0) {
            xClip = 0;
            }
            // here the right end
            if (xClip < -(windthClip - widthmovie)) {
            xClip = -(windthClip - widthmovie);
            }
        }    
 
 
    }
 
}
few words 'bout:
Code:
//here I decrease the excess of scroll witch wasn't cool
 
private function rallentoScrollEccessivo():void
        {
 
            if (speed > (xClip*2)) {
            speed = speed/3;
            }
        }
maybe it hasn't much sense but without it if I go from an are wich is not active to an extremity of the movie(active) the scroll is excessive..
if you find something better please let me know..

See Ya! :)
(ps. any blast or advice to improve it is welcome!!)
Attached Files
File Type: zip Sposta_Mouse.zip (9.9 KB, 51 views)


Last edited by tem; 08-08-07 at 02:33..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2 (permalink)  
Old 25-08-07, 04:07
Junior Member
 
Join Date: Aug 2007
Posts: 3
Rep Power: 0
playtrip is on a distinguished road
hello!

I have een searching the web for ours to find something like this:D thx
but i want the movieclip to start from the center of the stage then go to left when a drag my mouse to the right the other way then i drag my mouse to the left.

can u help me with this?

greetings/playtrip
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #3 (permalink)  
Old 25-08-07, 07:23
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,486
Rep Power: 6
Flep is on a distinguished road
Hi :)
sorry, i don't get you... the clip already starts from the center.
And if you move mouse on the right, clip goes on the left and so on :confused:
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #4 (permalink)  
Old 25-08-07, 11:37
Junior Member
 
Join Date: Aug 2007
Posts: 3
Rep Power: 0
playtrip is on a distinguished road
allright!
yes it does:D but the clip_mc starts to the left of the stage nomather where i put it.. i just wanted to center everything up..
think of it like you have just 1 box in the center of the stage.

sorry for my bad english:D
hope you understand!

grettings
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #5 (permalink)  
Old 25-08-07, 11:49
tem's Avatar
tem tem is offline
Moderator
 
Join Date: Jan 1970
Posts: 488
Rep Power: 39
tem is on a distinguished road
you can get what u want changin' this values:

Code:
 private function stopScroll():void
        {
            // here I'm checking the left end of the Clip
            //instead of 0 here it starts at 150
            if (xClip > 150) {
            xClip = 150;
            }
            // here the right end
            if (xClip < -(windthClip - widthmovie)) {
            xClip = -(windthClip - widthmovie);
            }
        }
istead of 150 u can put your values..
let me know if it's all right!! :)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Flash Multi Gallery
  #6 (permalink)  
Old 26-08-07, 00:57
Junior Member
 
Join Date: Aug 2007
Posts: 3
Rep Power: 0
playtrip is on a distinguished road
yes it works:D
with a couple of adjustments..
thx you sir!

but it was this part of the script a was a little confused.

// spostiamo il clip!
clip_mc.x=xClip

but i changed it to this and then i was able to center it.

clip_mc.x=xClip+widthmovie / 2-xClip/2;

probebly i dificult way to to it but Hey! it works:D

c ya!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #7 (permalink)  
Old 28-11-08, 14:37
Junior Member
 
Join Date: Nov 2008
Posts: 1
Rep Power: 0
tako is on a distinguished road
Re: Scroll Clip with mouseX Value

hello

its very good bat i van to replay the movieclip when the movieclip is in the end. i van to put a 360 degree photo.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
Classe Scroll Clip in base al valore mouseX tem Utilità degli utenti di FlepStudio 7 29-08-08 15:16
Scroll Panel plutoste AIUTO utilità free 0 28-04-08 17:40
Scroll Particolare fantamieru Flash CS3 generale 0 06-04-08 12:06
xml gallery - scroll motown advanced Actionscript 3.0 1 09-02-08 14:28
un po' geometri e mousex e mousey nootropic.kint Actionscript 3.0 base 6 13-11-07 22:57


All times are GMT. The time now is 22:58.


Powered by vBulletin versione 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC4
Forum SiteMap


FlepStudio
by Filippo Lughi
P.IVA 03605860406