Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-20-2012, 07:02 AM   PM User | #1
tpeck
Regular Coder

 
tpeck's Avatar
 
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
tpeck is on a distinguished road
actionscript for image slider

This actionscript for a flash image slider works reasonably well, but I am wondering if it can be slowed down. At the moment it positively races the image across the screen on load. Which part controls the speed?:

Code:
mouseX = _xmouse;
menuX = menu._x;
if (mouseX>480) {
	diff = (mouseX-480)/15;
}
if (mouseX<420) {
	diff = (420-mouseX)/15;
}
if (mouseX<=450 && menuX<=850) {
	setProperty("menu", _x, menuX+diff);
}
if (mouseX>=450 && menuX>=-600) {
	setProperty("menu", _x, menuX-diff);
}
if (menu._x>=850) {
	menu._x = 850;
} else if (menu._x<=-600) {
	menu._x = -600;
}
gotoAndPlay(2);
Also, can it be made to slide the image back and forth perpetually until a hover?

Here's a demo of how it is at present;

http://aapress.com.au/demo/slider.html
__________________
The difference between genius and stupidity is that genius has its limits. (Albert Einstein)
tpeck is offline   Reply With Quote
Old 06-20-2012, 01:31 PM   PM User | #2
adaminaudio
New Coder

 
Join Date: Jan 2012
Location: Columbus, Ohio, U.S.A
Posts: 41
Thanks: 0
Thanked 8 Times in 8 Posts
adaminaudio is an unknown quantity at this point
have you tried messing with the Frames Per Second (fps) setting?

It should be in your properties toolbar somewhere. It could be in the high 30's or something and that could be part of the reason it is going so rapidly.

As far as a perpetual thing. You could use an EnterFrame event and keep looking for a mouse hover or you can place all your images in a container (like a sprite), add a mouseover listener and then use a boolean or something to stop it. Not terribly difficult and a few ways to do it, it just takes some expirementation.

I hope I've helped.

-Adam
adaminaudio is offline   Reply With Quote
Old 06-20-2012, 02:26 PM   PM User | #3
tpeck
Regular Coder

 
tpeck's Avatar
 
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
tpeck is on a distinguished road
Thanks Adam. The fps was 24 but if I make it any lower it becomes jerky. So perversely I made it 30 which solved the jerkiness.

...then I changed the divisor in lines 4 and 7 from 15 to 200.

Just a shot in the dark, but it worked.

I don't really know how to do the perpetual back and forth thing using your suggestions, but thanks anyway. I'll play around with it.
__________________
The difference between genius and stupidity is that genius has its limits. (Albert Einstein)
tpeck is offline   Reply With Quote
Old 06-20-2012, 04:04 PM   PM User | #4
adaminaudio
New Coder

 
Join Date: Jan 2012
Location: Columbus, Ohio, U.S.A
Posts: 41
Thanks: 0
Thanked 8 Times in 8 Posts
adaminaudio is an unknown quantity at this point
yeah, sorry. It's highly possible that I'm confused (it happens )

but for example -->

//you have your imagecontainer or whatever, add a boolean and some listeners..
Code:
var currentlyHovering:Boolean = false;

imageContainer.addEventListener(MouseEvent.MOUSE_OVER, function(){
               currentlyHovering = true;
});

imageContainer.addEventListener(MouseEvent.MOUSE_OUT, function(){
               currentlyHovering = false;
});

//and you can have an enter frame event on the app...
this.stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);


function onEnterFrame(event:Event):void
{
            while(!currentlyHovering)
             {
                  //do your thing and call your perpetual hover code
                  perpetuallyHover();

              }

}
something like that maybe, I'm just going off the top of my head here and trying to help out is all.

Again, all apologies if I'm not fully understanding what you're trying to do.

-Adam
adaminaudio is offline   Reply With Quote
Old 06-21-2012, 10:59 AM   PM User | #5
tpeck
Regular Coder

 
tpeck's Avatar
 
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
tpeck is on a distinguished road
Always grateful for a reply!

I added this to the timeline:

Code:
onClipEvent(load) {
        speed = 5;
}
onClipEvent(enterFrame) {
        this._x += speed;
        if ( this._x > 850 ) this._x = 0;
}
It makes it scroll to the left and when it gets all the way, it instantly flicks back to the far right and starts again.

So how might I make it get to far left and then scroll nicely back to far right and start again?
__________________
The difference between genius and stupidity is that genius has its limits. (Albert Einstein)
tpeck is offline   Reply With Quote
Old 06-22-2012, 01:19 AM   PM User | #6
adaminaudio
New Coder

 
Join Date: Jan 2012
Location: Columbus, Ohio, U.S.A
Posts: 41
Thanks: 0
Thanked 8 Times in 8 Posts
adaminaudio is an unknown quantity at this point
hi,

I'm just kinda guessing on this one, post your .fla if you have it. but have you tried playing around with a negative speed at all?
Code:
onClipEvent(enterFrame) {
        
        
        if ( this._x > 850 ){
              speed = -5;
           }

        else if(this._x <=0){
            speed = 5;
        }
    this._x += speed;


}
again, just taking a stab hoping to keep your post alive in case anybody has more efficient solutions for you.
adaminaudio is offline   Reply With Quote
Old 06-22-2012, 02:11 AM   PM User | #7
tpeck
Regular Coder

 
tpeck's Avatar
 
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
tpeck is on a distinguished road
Thanks adaminaudio.

I could be putting it in the wrong place too.

http://aapress.com.au/PRD/USM1.fla
__________________
The difference between genius and stupidity is that genius has its limits. (Albert Einstein)
tpeck is offline   Reply With Quote
Old 06-22-2012, 03:49 AM   PM User | #8
adaminaudio
New Coder

 
Join Date: Jan 2012
Location: Columbus, Ohio, U.S.A
Posts: 41
Thanks: 0
Thanked 8 Times in 8 Posts
adaminaudio is an unknown quantity at this point
hi Tpeck,

take this post if you can and bring it to the guys on Actionscript.org and put it in the AS2 forums.

I'm not as well versed in AS2 as I am AS3 and they've got some swedes over there that've been doing this for years and will probably have your solution up to you in no time (and may give you a few AS2 pointers that I certainly don't know about).

I thought I had more time to look at this but I won't be able to get to it for awhile. They have guys over there that are on all night lol
adaminaudio is offline   Reply With Quote
Old 06-24-2012, 03:50 PM   PM User | #9
m4rksade
New to the CF scene

 
Join Date: Jun 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
m4rksade is an unknown quantity at this point
DWI Lawyer Brooklyn
m4rksade is offline   Reply With Quote
Old 06-28-2012, 06:41 AM   PM User | #10
CasandraHancox
New to the CF scene

 
Join Date: Jun 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
CasandraHancox is an unknown quantity at this point
you have your imagecontainer or whatever, add a boolean and some listeners..
CasandraHancox is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 06:23 PM.


Advertisement
Log in to turn off these ads.