Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Need professional code hint ;)

    OK, so I have an idea of making some cool 3D video transition, with one video on frame 1, and other on frame 2... There will be five of them, so I need my code to work.
    Using all kinds of tutorials I came up with this code:
    import caurina.transitions.*;


    stop();

    spin.addEventListener(MouseEvent.CLICK, cl);
    var isTurning:Boolean = false;
    function cl(e:Event):void
    {
    if(!isTurning)
    {
    Tweener.addTween(con, {rotationY:con.rotationY+180,
    time:1, onComplete:function(){isTurning = false;}});
    isTurning = true;

    }

    }

    addEventListener(Event., loop);
    function loop(e:Event):void
    {
    if(con.rotationY > 90 && con.rotationY < 270)
    {
    gotoAndStop("drugi");
    }
    else
    {
    con.addChild(con.vid);
    }
    }

    in highlited part is where I got stuck... Which event should I use?

    So, I want to click on button, video spins and goes to frame named "drugi", where another video is...

  • #2
    New Coder
    Join Date
    Aug 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if you're only wanting to call the function when you press the button, an event listener shouldn't be needed.... That is if you button is calling code when it is pressed.

    If you simply remove the eventListener, and the e:Event it should work. The following code will call the function when loop(); is called. So if you wish to execute the loop function from the button code, place loop(); in the call.

    Code:
    loop();
    Note the function isn't required to run from an eventListener.

    Code:
    function loop():void
    {
    if(con.rotationY > 90 && con.rotationY < 270)
    {
    gotoAndStop("drugi");
    }
    else
    {
    con.addChild(con.vid);
    }
    }

  • #3
    New Coder
    Join Date
    Aug 2011
    Location
    Gold Coast, Australia
    Posts
    16
    Thanks
    1
    Thanked 1 Time in 1 Post
    If you are looping it each frame you should use this code
    Code:
     addEventListener(Event.ENTER_FRAME, loop)


  •  

    Posting Permissions

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