ST3VO
asked on
Add close button to loader AS3
Hi all,
I am creating a loader (window) at runtime in AS3 but I need to add an X (close button) on the top-right corner.
Can anyone help please.
Please see code below.
Thanks
ST3VO
I am creating a loader (window) at runtime in AS3 but I need to add an X (close button) on the top-right corner.
Can anyone help please.
Please see code below.
Thanks
ST3VO
var myMapWindow:Sprite = new Sprite();
var myText:TextArea = new TextArea();
addChild(myMapWindow);
myMapWindow.addChild(myText);
myMapWindow.visible=false;
mapbtn.addEventListener(MouseEvent.CLICK, clickHandlermapbtn);
function clickHandlermapbtn(eo:MouseEvent):void {
myText.editable = false;
myText.height = 480;
myText.width = 645;
myText.move(125,110);
myText.setStyle("fontFamily", "Arial");
myText.htmlText = "<b>Reference Number:</b> "+ nuTitle + "<br><br>" +
"<b>Description:</b> " + nuDescription + "<br><br>" +
"<img src='_map/map1.jpg'><br><br>" +
"<b>Location:</b> " + nuLocation + "<br><br>" +
"<b>PostCode:</b> " + nuPostcode + "<br><br>" +
"<b>Contact Location:</b> " + nuCompanyLocation;
myMapWindow.visible=true;
}
ASKER
Sorry, you might have misunderstood me.
The loader creates a window and a textarea right now.
I need a close button created too.
Know what I'm trying to do?
The loader creates a window and a textarea right now.
I need a close button created too.
Know what I'm trying to do?
ok...
so it looks like 'myMapWindow' is the container for the controls?
so it looks like 'myMapWindow' is the container for the controls?
var btnClose:Sprite = new ButtonFromLibrary();
btnClose.addEventListener(MouseEvent.MOUSE_UP btnCloseHandler)
function btnCloseHandler(e:MouseEvent):void{
trace(e.target + " clicked")
removeChild(myMapWindow);// this may need to be removeChild(e.target.parent);
}
myMapWindow.addChild(btnClose);
myMapWindow.x = 200;
myMapWindow.y = 5;
ASKER
Hmm...
I get errors on line 2
btnClose.addEventListener( MouseEvent .MOUSE_UP btnCloseHandler)
error is:
1084: Syntax error: expecting rightparen before btnCloseHandler.
I get errors on line 2
btnClose.addEventListener(
error is:
1084: Syntax error: expecting rightparen before btnCloseHandler.
//comma needed between MouseEvent.MOUSE_UP and btnCloseHandler
btnClose.addEventListener( MouseEvent .MOUSE_UP, btnCloseHandler)
btnClose.addEventListener(
ASKER
Another error:
1180: Call to a possibly undefined method ButtonFromLibrary.
1180: Call to a possibly undefined method ButtonFromLibrary.
sorry... i made an assumtion here, i should have explained
You obviously need a graphical button so create something that looks like a close button, convert to symbol which adds to the library.
This example a Sprite exists in the library called 'ButtonFromLibrary'
Name yours what ever you like and change this code accordingly
You obviously need a graphical button so create something that looks like a close button, convert to symbol which adds to the library.
This example a Sprite exists in the library called 'ButtonFromLibrary'
Name yours what ever you like and change this code accordingly
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I still have problems here:
I'm getting:
1151: A conflict exists with definition nuTitle in namespace internal.
1151: A conflict exists with definition nuDescription in namespace internal.
1151: A conflict exists with definition nuLocation in namespace internal.
1151: A conflict exists with definition nuPostcode in namespace internal.
1151: A conflict exists with definition nuCompanyLocation in namespace internal.
////////
Problems here:
////// vars in html code
var nuTitle:String = "nuTitle";
var nuDescription:String = "nuDescription";
var nuLocation:String = "nuLocation";
var nuPostcode:String = "nuPostcode";
var nuCompanyLocation:String = "nuCompanyLocation";
////// vars in html code
I'm getting:
1151: A conflict exists with definition nuTitle in namespace internal.
1151: A conflict exists with definition nuDescription in namespace internal.
1151: A conflict exists with definition nuLocation in namespace internal.
1151: A conflict exists with definition nuPostcode in namespace internal.
1151: A conflict exists with definition nuCompanyLocation in namespace internal.
////////
Problems here:
////// vars in html code
var nuTitle:String = "nuTitle";
var nuDescription:String = "nuDescription";
var nuLocation:String = "nuLocation";
var nuPostcode:String = "nuPostcode";
var nuCompanyLocation:String = "nuCompanyLocation";
////// vars in html code
ASKER
This code works (see attached code):
It just needs to close button added.
Thanks again
st3vo
It just needs to close button added.
Thanks again
st3vo
import flash.display.Sprite;
import fl.controls.TextArea;*/
////////////////////////////////////////
/*var myMapWindow:Sprite = new Sprite();
var myText:TextArea = new TextArea();
addChild(myMapWindow);
myMapWindow.addChild(myText);
myMapWindow.visible=false;
mapbtn.addEventListener(MouseEvent.CLICK, clickHandlermapbtn);
function clickHandlermapbtn(eo:MouseEvent):void
{
myText.editable = false;
myText.height = 480;
myText.width = 645;
myText.move(125,110);
//myText.setStyle("textFormat", myFormat);
//myText.setTextFormat(myFormat);
// myText.embedFonts = true;//test
myText.setStyle("fontFamily", "Arial");
var nuTitle:String = "nuTitle";
var nuDescription:String = "nuDescription";
var nuLocation:String = "nuLocation";
var nuPostcode:String = "nuPostcode";
var nuCompanyLocation:String = "nuCompanyLocation";
myText.htmlText = "<b>Reference Number:</b> "+ nuTitle + "<br><br>" +
"<b>Description:</b> " + nuDescription + "<br><br>" +
"<img src='_map/map1.jpg'><br><br>" +
"<b>Location:</b> " + nuLocation + "<br><br>" +
"<b>PostCode:</b> " + nuPostcode + "<br><br>" +
"<b>Contact Location:</b> " + nuCompanyLocation;
myMapWindow.visible=true;
}
ASKER
Errors sorted Thanks :o)
var myMapWindow:Sprite = new Sprite();
var myText:TextArea = new TextArea();
addChild(myMapWindow);
myMapWindow.addChild(myTex
myMapWindow.visible=false;
mapbtn.addEventListener(Mo
function clickHandlermapbtn(eo:Mous
myText.editable = false;
myText.height = 480;
myText.width = 645;
myText.move(125,110);
myText.setStyle("fontFamil
myText.htmlText = "<b>Reference Number:</b> "+ nuTitle + "<br><br>" +
"<b>Description:</b> " + nuDescription + "<br><br>" +
"<img src='_map/map1.jpg'><br><b
"<b>Location:</b> " + nuLocation + "<br><br>" +
"<b>PostCode:</b> " + nuPostcode + "<br><br>" +
"<b>Contact Location:</b> " + nuCompanyLocation;
//myMapWindow.visible=true
closeWin();
}
function closeWin():void{ removeChild(myMapWindow) }