A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Is this the right way to do this??

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    2

    Is this the right way to do this??

    Hi,

    New to programming in flash, very new. Trying to make a header image that has a set of images at the bottom that scroll off to the left then come back around at the right and keep scrolling through. Kind of like the "Our picks of the week" here:

    http://www.barnesandnoble.com/

    Here is what I have sketched out so far:

    var timer=0;
    var picPause=0;
    var picSpacing=10;
    var Narrators = new Array();

    function MovePic(e:Event):void {

    if (picPause==0) {
    timer++;
    }


    if (timer==1&&picPause==0) {

    if(ABOOK.x<=-105){
    ABOOK.x = 550;
    } else {
    ABOOK.x-=2;
    }

    trace(ABOOK.x);
    timer=0;
    }
    }

    function ShowDetails(e:Event):void {
    picPause=1;
    }

    function MovePicCont(e:Event):void {
    picPause=0;
    }

    ABOOK.addEventListener(Event.ENTER_FRAME, MovePic);
    ABOOK.addEventListener(MouseEvent.ROLL_OVER, ShowDetails);
    ABOOK.addEventListener(MouseEvent.ROLL_OUT, MovePicCont);



    The code works, it moves a movieclip from left to right and pauses on mouse over. But it seems like there has to be a better way. Any advice and input would be appreciated.

  2. #2
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    Your question is subjective. There are fortunately, or maybe unfortunately, dozens of ways to complete the same task and it becomes a matter of preference, performance, and task that chooses the way you accomplish something. If your slider works then absolutely it's the right way to do it. But of course there are other ways.

    Instead of using the enter frame event you could use Tweener (external library : look this one up) and run a timer event and possibly delays. Tweener is a tweening engine that will give you cooler effects than move/don't move and that may be what you want. Or, since yours constantly is moving and then stopping you could allow it to rotate based on mouse position on the stage and slow or stop during a certain portion of the middle. That way is done often and feels more organic but requires some math and a little more code.

    However, as I've said. If it works and you're happy with the way it looks then it's a good way to do it; especially when you're just starting.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  3. #3
    Junior Member
    Join Date
    Nov 2010
    Posts
    2
    Thanks for the reply mneil. I briefly checked into the tweening libraries like GTween v2.01, I will revisit them. Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center