loaded swf not work correctly
i've created a maze game ( the idea is drawing a line to connect between 2 movie clips within the maze wall )
this is the code of the game :
stop();
import flash.display.Sprite;
import flash.events.MouseEvent;
//Are we drawing or not?
var drawing:Boolean;
var isStart = false;
var drawingSprite:Sprite = new Sprite();
addChild(drawingSprite);
drawingSprite.graphics.lineStyle(3,0x000000);
drawing = false;//to start with
stage.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing);
stage.addEventListener(MouseEvent.MOUSE_MOVE, draw);
stage.addEventListener(MouseEvent.MOUSE_UP, stopDrawing);
function startDrawing(event:MouseEvent):void{
drawingSprite.graphics.moveTo( mouseX, mouseY);
drawing = true;
}
function draw(event:MouseEvent){
if(drawing){
drawingSprite.graphics.lineTo(mouseX,mouseY);
}
}
function stopDrawing(event:MouseEvent){
drawing = false;
}
//Adds an event listener onto the stage with the mouse move event.
stage.addEventListener(MouseEvent.MOUSE_MOVE, detectHits);
function detectHits(event:MouseEvent) {
//If the mouse touches the edges of the maze, return back to the
//first scene, and remove the mouse move event listener from the
//stage.
if (wall_mc.hitTestPoint(mouseX,mouseY,true)) {
if (isStart == true) {
drawingSprite.graphics.clear();
gotoAndPlay(3);
isStart = false ;
stage.removeEventListener(MouseEvent.MOUSE_MOVE, detectHits);
}
}
//If the mouse touches the brush point, go to the third scene and
//remove the mouse move event listener from the stage.
else if (hit_mc.hitTestPoint(mouseX,mouseY,true)) {
if (isStart == true) {
drawingSprite.graphics.clear();
gotoAndPlay(2);
isStart = false ;
stage.removeEventListener(MouseEvent.MOUSE_MOVE, detectHits);
}
}
}
mc_start.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseClickHandler);
function fl_MouseClickHandler(event:MouseEvent):void
{
isStart = true ;
}
works fine and published as swf
when i try to load this game to another fla
its never work correctly yes the swf loaded and the game start fine
but when i start to draw the line into the maze and without touch any wall it moves to the ( u lost ) frame
