Procedure:
step 1: Open flash 8
step 2: Select flash document
step 3: select 1st layer, 1st frame on that document and write source code on Actions Frame
step 4: To check output press ctrl+enter(test movie)
SourceCode:
this.createEmptyMovieClip("clock", 3);
clock._x = 150;
clock._y = 150;
clock.createEmptyMovieClip("circle", 1);
clock.circle.lineStyle(4, 0x000066, 100);
clock.circle.moveTo(100, 0);
circleRadius = 100;
for (a=0; a<361; a++) {
radAngle = a*Math.PI/180;
xCoord = Math.cos(radAngle)*circleRadius;
yCoord = Math.sin(radAngle)*circleRadius;
clock.circle.lineTo(xCoord, yCoord);
}
clock.circle.lineStyle(3, 0x000000, 100);
clock.circle.moveTo(100, 0);
circleRadius = 100;
smallerCircleRadius = 90;
for (h=0; h<12; h++) {
hourAngle = h*30;
radHourAngle = hourAngle*Math.PI/180;
xCoord1 = Math.cos(radHourAngle)*circleRadius;
yCoord1 = Math.sin(radHourAngle)*circleRadius;
xCoord2 = Math.cos(radHourAngle)*smallerCircleRadius;
yCoord2 = Math.sin(radHourAngle)*smallerCircleRadius;
clock.circle.moveTo(xCoord1, yCoord1);
clock.circle.lineTo(xCoord2, yCoord2);
}
clock.circle.lineStyle(1, 0x000000, 100);
clock.circle.moveTo(100, 0);
circleRadius = 99;
smallerCircleRadius = 91;
for (m=0; m<60; m++) {
minuteAngle = m*6;
radMinuteAngle = minuteAngle*Math.PI/180;
xCoord1 = Math.cos(radMinuteAngle)*circleRadius;
yCoord1 = Math.sin(radMinuteAngle)*circleRadius;
xCoord2 = Math.cos(radMinuteAngle)*smallerCircleRadius;
yCoord2 = Math.sin(radMinuteAngle)*smallerCircleRadius;
clock.circle.moveTo(xCoord1, yCoord1);
clock.circle.lineTo(xCoord2, yCoord2);
}
clock.createEmptyMovieClip("hoursHand", 20);
clock.hoursHand.lineStyle(9, 0x0000FF, 100);
clock.hoursHand.moveTo(0, 0);
clock.hoursHand.lineTo(0, -50);
clock.createEmptyMovieClip("minutesHand", 30);
clock.minutesHand.lineStyle(5, 0x000000, 100);
clock.minutesHand.moveTo(0, 0);
clock.minutesHand.lineTo(0, -81);
clock.createEmptyMovieClip("secondsHand", 40);
clock.secondsHand.lineStyle(0, 0xFF0000, 100);
clock.secondsHand.moveTo(0, 0);
clock.secondsHand.lineTo(0, -90);
clock.onEnterFrame = function () {
clockDate = new Date();
seconds = clockDate.getSeconds();
this.secondsHand._rotation = seconds * 6;
minutes = clockDate.getMinutes();
this.minutesHand._rotation = minutes * 6;
hours = clockDate.getHours();
this.hoursHand._rotation = (hours * 30) + (minutes/2);
}
step 1: Open flash 8
step 2: Select flash document
step 3: select 1st layer, 1st frame on that document and write source code on Actions Frame
step 4: To check output press ctrl+enter(test movie)
SourceCode:
this.createEmptyMovieClip("clock", 3);
clock._x = 150;
clock._y = 150;
clock.createEmptyMovieClip("circle", 1);
clock.circle.lineStyle(4, 0x000066, 100);
clock.circle.moveTo(100, 0);
circleRadius = 100;
for (a=0; a<361; a++) {
radAngle = a*Math.PI/180;
xCoord = Math.cos(radAngle)*circleRadius;
yCoord = Math.sin(radAngle)*circleRadius;
clock.circle.lineTo(xCoord, yCoord);
}
clock.circle.lineStyle(3, 0x000000, 100);
clock.circle.moveTo(100, 0);
circleRadius = 100;
smallerCircleRadius = 90;
for (h=0; h<12; h++) {
hourAngle = h*30;
radHourAngle = hourAngle*Math.PI/180;
xCoord1 = Math.cos(radHourAngle)*circleRadius;
yCoord1 = Math.sin(radHourAngle)*circleRadius;
xCoord2 = Math.cos(radHourAngle)*smallerCircleRadius;
yCoord2 = Math.sin(radHourAngle)*smallerCircleRadius;
clock.circle.moveTo(xCoord1, yCoord1);
clock.circle.lineTo(xCoord2, yCoord2);
}
clock.circle.lineStyle(1, 0x000000, 100);
clock.circle.moveTo(100, 0);
circleRadius = 99;
smallerCircleRadius = 91;
for (m=0; m<60; m++) {
minuteAngle = m*6;
radMinuteAngle = minuteAngle*Math.PI/180;
xCoord1 = Math.cos(radMinuteAngle)*circleRadius;
yCoord1 = Math.sin(radMinuteAngle)*circleRadius;
xCoord2 = Math.cos(radMinuteAngle)*smallerCircleRadius;
yCoord2 = Math.sin(radMinuteAngle)*smallerCircleRadius;
clock.circle.moveTo(xCoord1, yCoord1);
clock.circle.lineTo(xCoord2, yCoord2);
}
clock.createEmptyMovieClip("hoursHand", 20);
clock.hoursHand.lineStyle(9, 0x0000FF, 100);
clock.hoursHand.moveTo(0, 0);
clock.hoursHand.lineTo(0, -50);
clock.createEmptyMovieClip("minutesHand", 30);
clock.minutesHand.lineStyle(5, 0x000000, 100);
clock.minutesHand.moveTo(0, 0);
clock.minutesHand.lineTo(0, -81);
clock.createEmptyMovieClip("secondsHand", 40);
clock.secondsHand.lineStyle(0, 0xFF0000, 100);
clock.secondsHand.moveTo(0, 0);
clock.secondsHand.lineTo(0, -90);
clock.onEnterFrame = function () {
clockDate = new Date();
seconds = clockDate.getSeconds();
this.secondsHand._rotation = seconds * 6;
minutes = clockDate.getMinutes();
this.minutesHand._rotation = minutes * 6;
hours = clockDate.getHours();
this.hoursHand._rotation = (hours * 30) + (minutes/2);
}
No comments:
Post a Comment