Flash Gallery | Flash Templates | Flash Menu | Flash Design | Flash Audio & Video

flash page flip

Actionscript 3.0 video tutorials

+ Reply to Thread
Results 1 to 1 of 1

Thread: Kinematics with Actionscript 3.0-example 2

  1. #1
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,609
    Rep Power
    9

    Kinematics with Actionscript 3.0-example 2

    flash templates

    We saw in the last article as a segment move with the motion applied to Actionscript 3.0.

    I know, is pretty boring and simple but it is necessary to first understand the basics of what we will see in the future.


    Now it is time to move on and then see how to move a pair of segments by trigonometry laws.

    We will see that the rotation of the first leg means that the second segment remains stuck at the end of the first.

    Not only that, we will see that the second segment will move a motion in relation to first.


    Using two instances of the same MovieClip we saw in the first example and two instances of the component Slider.








    The code I used:


    Code:
    import fl.controls.SliderDirection;
    import fl.events.SliderEvent;
    
    slider_1.direction=SliderDirection.VERTICAL;
    slider_1.x=500;
    slider_1.y=350;
    slider_1.rotation=270;
    slider_1.minimum=0;
    slider_1.maximum=180;
    slider_1.value=90;
    segment_1_mc.rotation=slider_1.value;
    slider_1.addEventListener(SliderEvent.THUMB_DRAG,onChange);
    
    slider_2.direction=SliderDirection.VERTICAL;
    slider_2.x=530;
    slider_2.y=slider_1.y;
    slider_2.rotation=270;
    slider_2.minimum=0;
    slider_2.maximum=180;
    slider_2.value=90;
    segment_2_mc.rotation=slider_2.value;
    slider_2.addEventListener(SliderEvent.THUMB_DRAG,onChange);
    
    function onChange(evt:SliderEvent):void
    {
    	segment_1_mc.rotation=slider_1.value;
    	segment_2_mc.rotation=slider_2.value;
    	
    	var radians:Number=segment_1_mc.rotation*Math.PI/180;
    	segment_2_mc.x=segment_1_mc.x+Math.cos(radians)*170;
    	segment_2_mc.y=segment_1_mc.y+Math.sin(radians)*170;
    }
    
    var evt:SliderEvent;
    onChange(evt);

    Compared to the first example, there is a simple law of trigonometry.

    PS: 170 is the distance between the two anchors of the segments.


    Source files:

    >
    Attached Files

+ Reply to Thread

Similar Threads

  1. Kinematics with Actionscript 3.0-example 1
    By Flep in forum Tutorials
    Replies: 0
    Last Post: 17-10-08, 02:15

Tags for this Thread

Bookmarks

Posting Permissions

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