Combined Code
movieClip 2 {
frame 1 {
function camControl() {
rp.x = _x;
rp.y = _y;
var v5 = camH * (_yscale * 0.01);
var v6 = camW * (_xscale * 0.01);
var v3 = sH / v5;
var v4 = sW / v6;
_x2 = (v6 / 2) * v4;
_y2 = (v5 / 2) * v3;
_xscale2 = v4 * 100;
_yscale2 = v3 * 100;
_rotation2 = -_rotation;
_parent.filters = this.filters;
_parent.transform.colorTransform = this.transform.colorTransform;
}
function reset() {
_parent._xscale = 100;
_parent._yscale = 100;
_parent._x = 0;
_parent._y = 0;
_parent._rotation = 0;
_parent._visible = true;
}
function set_x2(value) {
var v2 = {'x': rp.x, 'y': rp.y};
_parent.localToGlobal(v2);
_parent._x += value - v2.x;
}
function get_x2() {
var v2 = {'x': rp.x, 'y': rp.y};
_parent.localToGlobal(v2);
return v2.x;
}
function set_y2(value) {
var v2 = {'x': rp.x, 'y': rp.y};
_parent.localToGlobal(v2);
_parent._y += value - v2.y;
}
function get_y2() {
var v2 = {'x': rp.x, 'y': rp.y};
_parent.localToGlobal(v2);
return v2.y;
}
function get_xscale2() {
return _parent._xscale;
}
function set_xscale2(value) {
setProperty2('_xscale', value);
}
function get_yscale2() {
return _parent._yscale;
}
function set_yscale2(value) {
setProperty2('_yscale', value);
}
function get_rotation2() {
return parent.rotation;
}
function set_rotation2(value) {
setProperty2('_rotation', value);
}
function setProperty2(prop, n) {
var v3 = {'x': rp.x, 'y': rp.y};
_parent.localToGlobal(v3);
_parent[prop] = n;
var v2 = {'x': rp.x, 'y': rp.y};
_parent.localToGlobal(v2);
_parent._x -= v2.x - v3.x;
_parent._y -= v2.y - v3.y;
}
_visible = false;
addProperty('_x2', get_x2, set_x2);
addProperty('_y2', get_y2, set_y2);
addProperty('_xscale2', get_xscale2, set_xscale2);
addProperty('_yscale2', get_yscale2, set_yscale2);
addProperty('_rotation2', get_rotation2, set_rotation2);
var oldScaleMode = stage.scaleMode;
stage.scaleMode = 'exactFit';
var sW = Stage.width;
var sH = Stage.height;
stage.scaleMode = oldScaleMode;
var bounds_obj = this.getBounds(this);
var camH = Math.abs(bounds_obj.yMax - bounds_obj.yMin);
var camW = Math.abs(bounds_obj.xMax - bounds_obj.xMin);
var rp = {'x': this._x, 'y': this._y};
onEnterFrame = function () {
camControl();
};
this.onUnload = reset;
}
}
instance of movieClip 2 {
onClipEvent (enterFrame) {
_y = _y + (_root.char._y - _y) / 4;
_x = _x + (_root.char._x - _x) / 4;
}
}
movieClip 6 {
}
movieClip 7 {
}
movieClip 9 {
}
instance of movieClip 9 {
onClipEvent (enterFrame) {
if (_root.char.hitTest(this)) {
charX = 166.5;
_root.char._x = 166.5;
charY = 253.9;
_root.char._y = 253.9;
}
}
}
movieClip 12 {
}
movieClip 13 {
}
movieClip 15 {
}
movieClip 16 {
}
movieClip 18 {
}
movieClip 19 {
}
movieClip 21 {
}
movieClip 22 {
}
movieClip 24 {
}
movieClip 27 {
}
instance char of movieClip 27 {
onClipEvent (load) {
var ground = _root.ground;
var grav = 0;
var gravity = 2;
var speed = 7;
var maxJump = -12;
var touchingGround = false;
}
onClipEvent (enterFrame) {
_y = _y + grav;
grav += gravity;
while (ground.hitTest(_x, _y, true)) {
_y = _y - gravity;
grav = 0;
}
if (ground.hitTest(_x, _y + 5, true)) {
touchingGround = true;
} else {
touchingGround = false;
}
if (Key.isDown(39)) {
_x = _x + speed;
}
if (Key.isDown(37)) {
_x = _x - speed;
}
if (Key.isDown(38) && touchingGround) {
grav = maxJump;
}
if (ground.hitTest(_x + _width / 2, _y - _height / 2, true)) {
_x = _x - speed;
}
if (ground.hitTest(_x - _width / 2, _y - _height / 2, true)) {
_x = _x + speed;
}
if (ground.hitTest(_x, _y - height, true)) {
grav = 3;
}
}
}