Wednesday 11 May 2011

Guide Tween In Flash

To start with i created a curvy line which meets at the end so its a loop. I then, on a new layer, created a new shape to follow this loop. With this shape i went on to convert it into a movie clip and changed the instance name to target. I then created a classic motion tween on a new layer and then dragged my layer with my loop on , onto this layer. After that i dragged my shape over part of the loop until it latched on then i added a key frame on frame 35, then 70, then 100. I then moved the shape onto a different part of the loop on each of these new keyframes and then added a classic tween to the frames in-between.

After this the shape would follow this loop constantly. I then clicked on my shape and added some action script.


movieClip_1.addEventListener(MouseEvent.CLICK, fl_ClickToHide);

function fl_ClickToHide(event:MouseEvent):void
{
trace("HIT")
}

this script above would make it so when you click this shape which is continuously moving around this loop, something could happen but io would need more action script to make that something happen.



Second Lesson

The action script below is to add a scoreing system to a game in flash. Everytime the objes=cct is clicked, the score will increase by 1 point.


var score:Number =0


target.addEventListener(MouseEvent.CLICK, fl_ClickToHide);


function fl_ClickToHide(event:MouseEvent):void
{
score+=1
scoreText.text="SCORE "+String(score)

trace("SCORE")
}


The only problem was that the score would not appear until the object was clicked. To fix this i had to add the line ' scoreText.text="SCORE "+String(score) ' which was used previously and copy it under the variable

No comments:

Post a Comment