Hey I’m doing something for my work, i know its actually quite easy for a vet but I’m just a beginner here. The point of the script is to have an interactive map for a building that when you click on the location it highlights and stays on the screen for x amount of time along with some text about the location. I have completed all of the following and I’m now trying to refine it some more. At this moment I only have 3 diff. locations to click, its all a mock anyway because they haven’t handed off to me the real assets. I have it right now that when you click a location, the highlights from the other locations disappear, leaving only your current selection highlighted. However in order to do this I have to go through and systematically turn the other off in the code, not that bad with 3 but there could be 20 locations on the real map, I honestly don’t know. Anyway I looking for a cleaner way to do this, and have it be simpler. Please take a look and let me know what you think.
stop();
var the_bar;
var mediascape;
var basecamp;
var timer:Timer = new Timer(1000, 10);
var myFormat:TextFormat = new TextFormat();
var myTextField:TextField = new TextField();
var hit;
the_bar.addEventListener(MouseEvent.CLICK, bar_Click);
mediascape.addEventListener(MouseEvent.CLICK, mediascape_Click);
basecamp.addEventListener(MouseEvent.CLICK, basecamp_Click);
mediascape.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
mediascape.addEventListener(MouseEvent.MOUSE_OUT, mouseOut);
the_bar.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
the_bar.addEventListener(MouseEvent.MOUSE_OUT, mouseOut);
basecamp.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
basecamp.addEventListener(MouseEvent.MOUSE_OUT, mouseOut);
timer.addEventListener(TimerEvent.TIMER, stopper);
stage.addEventListener(MouseEvent.CLICK, continuer);
hit = false;
myFormat.size = 24;
//myFormat.font = "";
//myFormat.color = ;
myTextField.width = 340;
myTextField.x = 685;
myTextField.y = 85;
myTextField.multiline = myTextField.wordWrap = true;
myTextField.defaultTextFormat = myFormat;
function mouseOver(e:MouseEvent) {
e.target.gotoAndStop(2);
}
function mouseOut(e:MouseEvent) {
e.target.gotoAndStop(1);
}
function bar_Click (evt:MouseEvent):void {
hit = true;
the_bar.gotoAndStop(2);
mediascape.gotoAndStop(1);
basecamp.gotoAndStop(1);
addChild(myTextField);
myTextField.text = "some text here about the bar!";
if (hit == true){
the_bar.removeEventListener(MouseEvent.MOUSE_OUT, mouseOut);
}
}
function mediascape_Click (evt:MouseEvent):void {
hit = true;
mediascape.gotoAndStop(2);
the_bar.gotoAndStop(1);
basecamp.gotoAndStop(1);
addChild(myTextField);
myTextField.text = "some text here about the mediascape!";
if (hit == true){
mediascape.removeEventListener(MouseEvent.MOUSE_OUT, mouseOut);
}
}
function basecamp_Click (evt:MouseEvent):void {
hit = true;
basecamp.gotoAndStop(2);
the_bar.gotoAndStop(1);
mediascape.gotoAndStop(1);
addChild(myTextField);
myTextField.text = "some text here about the basecamp!";
if (hit == true){
basecamp.removeEventListener(MouseEvent.MOUSE_OUT, mouseOut);
}
}
function stopper(event:TimerEvent):void {
trace(timer.currentCount);
if (timer.currentCount == 10){
timer.stop();
hit = false;
myTextField.text = "";
mediascape.gotoAndStop(1);
the_bar.gotoAndStop(1);
basecamp.gotoAndStop(1);
}
}
function continuer(event:MouseEvent):void {
timer.reset();
timer.start();
}