A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Need code help (beginner)

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    4

    Need code help (beginner)

    Hi.
    I'm working on a slideshow with four buttons.

    I have used this guide (http://www.youtube.com/watch?v=S43WP...eature=related)

    Everything is working and I'm done with that guide. Now I want to put in a timer that automatically changes picture every 4rd second. I have done special properties for each and every button.



    I have mad every picture 10 frame from each others and named the labels to one, two, three and four

    this is the code I'm using:
    Code:
    stop();
     
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import flash.utils.Timer;
     
     
    var oneTween:Tween = new Tween(content_mc,"x", Regular.easeOut,content_mc.x, 0, 1, true);
     
    one.buttonMode= true;
    two.buttonMode= true;
    three.buttonMode= true;
    four.buttonMode= true;
     
    one.addEventListener (MouseEvent.ROLL_OVER, overMe);
    one.addEventListener (MouseEvent.ROLL_OUT, outMe);
     
    two.addEventListener (MouseEvent.ROLL_OVER, overMe);
    two.addEventListener (MouseEvent.ROLL_OUT, outMe);
     
    three.addEventListener (MouseEvent.ROLL_OVER, overMe);
    three.addEventListener (MouseEvent.ROLL_OUT, outMe);
     
    four.addEventListener (MouseEvent.ROLL_OVER, overMe);
    four.addEventListener (MouseEvent.ROLL_OUT, outMe);
     
    function overMe (event:MouseEvent):void
    {
        event.target.gotoAndPlay("Over");
    }
    function outMe (event:MouseEvent):void
    {
        event.target.gotoAndPlay("Out");
    }
     
     
    //button one
    one.addEventListener(MouseEvent.CLICK, clickOne);
     
    function clickOne(e:MouseEvent):void
    {
        gotoAndStop("one")
        two.buttonMode = true;
        two.gotoAndPlay("Gone");
        two.addEventListener (MouseEvent.ROLL_OVER, overMe);
        two.addEventListener (MouseEvent.ROLL_OUT, outMe);
       
        three.buttonMode = true;
        three.gotoAndPlay("Gone");
        three.addEventListener (MouseEvent.ROLL_OVER, overMe);
        three.addEventListener (MouseEvent.ROLL_OUT, outMe);
       
        four.buttonMode = true;
        four.gotoAndPlay("Gone");
        four.addEventListener (MouseEvent.ROLL_OVER, overMe);
        four.addEventListener (MouseEvent.ROLL_OUT, outMe);
       
        one.buttonMode = true;
        one.gotoAndPlay("Click");
        one.addEventListener (MouseEvent.ROLL_OVER, overMe);
        one.addEventListener (MouseEvent.ROLL_OUT, outMe);
    }
     
    //button Two
     
    two.addEventListener(MouseEvent.CLICK, clickTwo);
     
    function clickTwo(e:MouseEvent):void
    {
        gotoAndStop("two")
        one.buttonMode = true;
        one.gotoAndPlay("Gone");
        one.addEventListener (MouseEvent.ROLL_OVER, overMe);
        one.addEventListener (MouseEvent.ROLL_OUT, outMe);
       
        three.buttonMode = true;
        three.gotoAndPlay("Gone");
        three.addEventListener (MouseEvent.ROLL_OVER, overMe);
        three.addEventListener (MouseEvent.ROLL_OUT, outMe);
       
        two.buttonMode = false;
        two.gotoAndPlay("Click");
        two.addEventListener (MouseEvent.ROLL_OVER, overMe);
        two.addEventListener (MouseEvent.ROLL_OUT, outMe);
       
        four.buttonMode = true;
        four.gotoAndPlay("Gone");
        four.addEventListener (MouseEvent.ROLL_OVER, overMe);
        four.addEventListener (MouseEvent.ROLL_OUT, outMe);
    }
     
    //button three
    three.addEventListener(MouseEvent.CLICK, clickThree);
     
    function clickThree(e:MouseEvent):void
    {
        gotoAndStop("three")
        one.buttonMode = true;
        one.gotoAndPlay("Gone");
        one.addEventListener (MouseEvent.ROLL_OVER, overMe);
        one.addEventListener (MouseEvent.ROLL_OUT, outMe);
       
        three.buttonMode = false;
        three.gotoAndPlay("Click");
        three.addEventListener (MouseEvent.ROLL_OVER, overMe);
        three.addEventListener (MouseEvent.ROLL_OUT, outMe);
       
        two.buttonMode = true;
        two.gotoAndPlay("Gone");
        two.addEventListener (MouseEvent.ROLL_OVER, overMe);
        two.addEventListener (MouseEvent.ROLL_OUT, outMe);
       
        four.buttonMode = true;
        four.gotoAndPlay("Gone");
        four.addEventListener (MouseEvent.ROLL_OVER, overMe);
        four.addEventListener (MouseEvent.ROLL_OUT, outMe);
       
    }
     
    //button four
    four.addEventListener(MouseEvent.CLICK, clickFour);
     
    function clickFour(e:MouseEvent):void
    {
        gotoAndStop("four")
        one.buttonMode = true;
        one.gotoAndPlay("Gone");
        one.addEventListener (MouseEvent.ROLL_OVER, overMe);
        one.addEventListener (MouseEvent.ROLL_OUT, outMe);
       
        three.buttonMode = false;
        three.gotoAndPlay("Gone");
        three.addEventListener (MouseEvent.ROLL_OVER, overMe);
        three.addEventListener (MouseEvent.ROLL_OUT, outMe);
       
       
        two.buttonMode = true;
        two.gotoAndPlay("Gone");
        two.addEventListener (MouseEvent.ROLL_OVER, overMe);
        two.addEventListener (MouseEvent.ROLL_OUT, outMe);
       
        four.buttonMode = false;
        four.gotoAndPlay("Click");
        four.addEventListener (MouseEvent.ROLL_OVER, overMe);
        four.addEventListener (MouseEvent.ROLL_OUT, outMe);
       
    }
    Can someone tell me how to put in the timer? Please explain carefully because I am very inexperienced using ActionScript 3.

    If someone can help me I would be very thankful!

    Greetings
    Gustaf

  2. #2
    Member
    Join Date
    Jul 2011
    Posts
    51
    Post a sample of your work.

    What is in those frames, one, two , three .... ?



    FFA

  3. #3
    Junior Member
    Join Date
    Oct 2011
    Posts
    4
    Here is a sample of my work. There are different pictures that slides when your'e navigating with the buttons.

    http://www.2shared.com/file/TBTlYVC8/Test1needhelp.html


  4. #4
    Member
    Join Date
    Jul 2011
    Posts
    51
    I am using CS3 CS4


    FFA

  5. #5
    Junior Member
    Join Date
    Oct 2011
    Posts
    4
    http://www.2shared.com/file/Qc_82dz9/Test1.html

    there you have a CS4 document

  6. #6
    Junior Member
    Join Date
    Oct 2011
    Posts
    4
    Do you know any solution for my problem?

    I know how to get the timer to play but everything becomes out of step when you start to navigate with the buttons...

    Greetings
    GurraW

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