Useful Code for Digital Media Class 2009-2010:
HTML
Standard format
<!DOCTYPE HTML Public "-//W3C//DTD HTML 4.01//EN"
"http://w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>
Title goes here.
</title>
</head>
<body>
Here is where the content goes.
</body>
</html>
Some Useful Tags
<br>
<hr>
<hr width="55%">
<h1>HI</h1>
<h6>BYE</h6>
<body bgcolor="#FFD700">
<body background="image.gif">
<font color="#DC143C"> Some Words </font>
© 2009, Company Name
<a href="http://www.google.com" target="blank"> Click here</a> for google.
<strong>Bold</strong>
<em>Italic</em>
<p style="text-align:right;">right</p>
<p style="text-align:center;">center</p>
<p style="text-align:left;">left</p>
<img src="img.jpg" alt="A picture of me">
<div style="text-align: center;"> <img src="image.jpg" alt="A picture of me"> </div>
<a href="http://www.google.com" target="blank"><img src="image.jpg" alt="Picture of me"> </a>
<p style="font-size: 400%; text-align: right;"> More Words!! </p>
Action Script
Frame Stop
stop ();
Button Play
on (release){
gotoAndPlay(2);
}
External Link
on (release) {
getURL("http://www.google.com");
window= "_blank";
}
Simple Hovercraft Control
onClipEvent (enterFrame) {
var speed = 5;
if (Key.isDown(Key.RIGHT))
_x += speed;
if (Key.isDown(Key.LEFT))
_x -= speed;
if (Key.isDown(Key.UP))
_y -= speed;
if (Key.isDown(Key.DOWN))
_y += speed;
}
Barrier Code
Don't forget to assign an instance name for the barrier.
if (hitTest(_level0.wall)==true) {
_x=_x-2;
}
Complex Car Control
onClipEvent (load)
{
var speed = new Number(0);
_root.createEmptyMovieClip("drawing", 1);
this.swapDepths(_root.drawing);
_root.clearBtn.swapDepths(this);
hi = Math.sin(_rotation * 1.745329E-002) * 10;
ip = Math.cos(_rotation * 1.745329E-002) * 10;
iks = _x - ip;
ips = _y - hi;
iks2 = _x + ip;
ips2 = _y + hi;
}
onClipEvent (enterFrame)
{
if (Key.isDown(38) & !Key.isDown(17))
{
speed = speed + 1.500000E+000;
} // end if
if (Key.isDown(40) & !Key.isDown(17))
{
speed = speed - 7.500000E-001;
} // end if
if (Key.isDown(17))
{
speed = speed - speed / 10;
if (Key.isDown(39))
{
setProperty("", _rotation, _rotation + speed / 2);
} // end if
if (Key.isDown(37))
{
setProperty("", _rotation, _rotation - speed / 2);
} // end if
} // end if
if (Key.isDown(39))
{
if (speed < 5 && speed >= 0)
{
setProperty("", _rotation, _rotation + 2 * speed);
}
else if (speed < 0)
{
setProperty("", _rotation, _rotation + 7.500000E+000 * speed / 15);
}
else
{
setProperty("", _rotation, _rotation + 7.500000E+000);
} // end else if
speed = speed * 9.500000E-001;
} // end if
if (Key.isDown(37))
{
if (speed < 5 && speed >= 0)
{
setProperty("", _rotation, _rotation - 2 * speed);
}
else if (speed < 0)
{
setProperty("", _rotation, _rotation - 7.500000E+000 * speed / 15);
}
else
{
setProperty("", _rotation, _rotation - 7.500000E+000);
} // end else if
speed = speed * 9.500000E-001;
} // end if
if (Math.abs(speed) > 20)
{
speed = 20;
} // end if
if (speed < -10)
{
speed = -10;
} // end if
speed = speed * 9.800000E-001;
g = Math.sin(_rotation * 1.745329E-002) * speed;
m = Math.cos(_rotation * 1.745329E-002) * -speed;
setProperty("", _x, _x + g);
setProperty("", _y, _y + m);
hi = Math.sin(_rotation * 1.745329E-002) * 10;
ip = Math.cos(_rotation * 1.745329E-002) * 10;
_root.k1 = hi;
_root.k2 = ip;
if (Key.isDown(17))
{
_root.drawing.lineStyle(3, 14540253, 100);
}
else
{
_root.drawing.lineStyle(3, 15658734, 100);
} // end else if
//delete remaining forward slashes below to leave tire tracks
//_root.drawing.moveTo(iks, ips);
//_root.drawing.lineTo(_x - ip, _y - hi);
//_root.drawing.moveTo(iks2, ips2);
//_root.drawing.lineTo(_x + ip, _y + hi);
//iks = _x - ip;
//ips = _y - hi;
//iks2 = _x + ip;
//ips2 = _y + hi;
}