I am trying to make a flash game for a website. In the game, there is a large interactive map which I created. The map is supposed to scroll just by moving the mouse.
As a placeholder for the map, an ex-coworker created a gradient background, which moves along with the mouse. Here is the AS.
[INDENT]// Width and height of image
var w = Stage.width * 2;
var h = Stage.height * 2;
// Mock up graphic that will be the image
var image_mc = this.createEmptyMovieClip (“image_mc”, 0);
image_mc.beginGradientFill (‘radial’, [0xFF0000, 0x0000FF], [100, 100], [0, 255], {matrixType:“box”, x:0, y:0, w:w, h:h, r:0});
image_mc.lineTo(w,0);
image_mc.lineTo (w, h);
image_mc.lineTo (0, h);
image_mc.lineTo (0, 0);
image_mc.endFill ();
/** Below is important */
image_mc.onMouseMove = move;
function move ()
{
var xpercent = _xmouse / Stage.width;
var ypercent = _ymouse / Stage.height;
this._x = (Stage.width - this._width) * xpercent;
this._y = (Stage.height - this._height) * ypercent;
updateAfterEvent ();
}
[/INDENT]And this works fine. But when I take out the gradient and add the map which is a movie clip, it does not move along with the mouse. Here is the new AS (I added what is in red)
[INDENT]// Width and height of image
var w = Stage.width * 2;
var h = Stage.height * 2;
[COLOR=red]// Added map[/COLOR]
[COLOR=red]var image_mc = this.createEmptyMovieClip (“image_mc”, 0);[/COLOR]
[COLOR=red]image_mc.loadMovie(“WVSU_campus_map.swf.”)[/COLOR]
/** Below is important */
image_mc.onMouseMove = move;
function move ()
{
var xpercent = _xmouse / Stage.width;
var ypercent = _ymouse / Stage.height;
this._x = (Stage.width - this._width) * xpercent;
this._y = (Stage.height - this._height) * ypercent;
updateAfterEvent ();
}
[/INDENT]
The map movie clip is there in the background, but it does not move the way the gradient did.
Does anyone know how to make the MC move and pan along with the mouse? Even if it is a completely different code?!
TIA!