-
[F8] looking for general advice
hello, hows it going?
I am creating a small flash based product preview panel on my site.
To help my description heres an image of how it'll look:
http://willarbuckle.com/junk/shopeg.jpg
the left and right arrows when clicked will cycle to the next image/product. I'd want this to be a smooth eased tweened motion.
I could of course animated this and add in lots of unefficient bitty code here and there. This would also get very annoying when adding new products.
All I'm after is any pointers anyone has that can start me off. anyone know of any tuts that could help? and just generally, how should I go about this?
Thanks guys,
-Will
-
Senior Member
One way to do it would be to have an array with movieclip linkage names in it. Pressing right increments your array pointer, and left decrements it. The new moviclip is placed just offstage to the right (or left) (using attachMovieClip) and then setup two actionscript tweens, one for the onscreen clip moving offstage, and one for the offstage clip moving onstage. Then removeMovieClip on the offstage movie.
Some old examples of the AS tween class can be found here:
http://www.kirupa.com/developer/actionscript/tween.htm
Hope that gets you going in the right direction.
-
hey, thanks for the tip!
Got a little further on with things now:
http://willarbuckle.com/junk/shop.html
But there's a problem. Items, by which i mean the red squares, should always come to a rest, central on the panel. When the arrows are clicked in succession before the items come to a rest the centralisation is thrown off.
This is because the code is telling the movieclip to move by 130 pixels when the arrows are clicked. So if the movieclip hasnt managed to move the full 130 pixels before the user clicks again.... we get the MC not moving far enough.
Here's the code I have:
import mx.transitions.Tween;
import mx.transitions.easing.*;
var nProducts:Number = 6;
var counter:Number = 1;
if (counter == 1){
mcPrevButton._visible = false;
} else {
mcPrevButton._visible = true;
}
if (counter == nProducts){
mcNextButton._visible = false;
} else {
mcNextButton._visible = true;
}
mcNextButton.onRelease = function():Void{
var prodMovement:Tween = new Tween(mcProducts, "_x", Elastic.easeOut, mcProducts._x, mcProducts._x+130, 90, false);
counter++;
if (counter == 1){
mcPrevButton._visible = false;
} else {
mcPrevButton._visible = true;
}
if (counter == nProducts){
mcNextButton._visible = false;
} else {
mcNextButton._visible = true;
}
};
mcPrevButton.onRelease = function():Void{
var prodMovement:Tween = new Tween(mcProducts, "_x", Elastic.easeOut, mcProducts._x, mcProducts._x-130, 90, false);
counter--;
if (counter == 1){
mcPrevButton._visible = false;
} else {
mcPrevButton._visible = true;
}
if (counter == nProducts){
mcNextButton._visible = false;
} else {
mcNextButton._visible = true;
}
};
If anyone wants to have a look at the flash doc:
http://willarbuckle.com/junk/shop.fla
Any help would be much appreciated, thanks guys.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|