Web Analytics Made Easy -
StatCounter Need professional code hint ;) - CodingForum

Announcement

Collapse
No announcement yet.

Need professional code hint ;)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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);
    }
    }

    Comment


    • #3
      If you are looping it each frame you should use this code
      Code:
       addEventListener(Event.ENTER_FRAME, loop)

      Comment

      Working...
      X