Hello all! I’ve searched the forums but apparently I’m not searching for the right thing so I’ll describe what I want to do and someone more smart than I (shouldn’t take much) can tell me what I SHOULD be looking for…
I’ve got 3 buttons on the bottom of a 640x400 canvas. As the user places the mouse over each button, I want a 340x200 text box to come up in the middle of the screen (or slightly below middle) to display text. I was able to achieve this by using the “over” frame of the button’s design properties but the windows become visible when I place my mouse cursor over the middle of the screen where the windows appear when the mouse is over the actual button.
Help!
Hundreds of ways of doing this, hopefully this will help you understand an AS approach.
Place 3 buttons on your stage and name then btn1, btn2, btn3. Then paste this code into your main timeline
function showText (e:String) {
_root.createTextField ("myText",this.getNextHighestDepth (),(640 - 200) / 2,(400 - 30) / 2,200,30);
var my_fmt:TextFormat = new TextFormat ();
my_fmt.bold = true;
my_fmt.font = "Arial";
my_fmt.color = 0xFF9900;
myText.wordWrap = true;
myText.multiline = true;
myText.border = true;
myText.type = "dynamic";
myText.autoSize = false;
myText.setNewTextFormat (my_fmt);
myText.text = e;
}
btn1.onRollOver = function () {
showText ("Button 1 text");
};
btn2.onRollOver = function () {
showText ("Button 2 text");
};
btn3.onRollOver = function () {
showText ("Button 3 text");
};
btn1.onRollOut = function () {
myText.removeTextField ();
};
btn2.onRollOut = function () {
myText.removeTextField ();
};
btn3.onRollOut = function () {
myText.removeTextField ();
};
That’s freaking awesome! Only thing I needed to do was change the autosize to true and it works great!
2 more questions…
-
Can the box be filled with #333333 or #666666?
-
Can line breaks be inserted into each text section? ie…
Comments? Questions? Contact us at [EMAIL="jibberjabber@somewhere.net"]jibberjabber@somewhere.net[/EMAIL]
You can also contact us at 800-123-4567
Sure. Just use the background color property and use html text
function showText (e:String) {
_root.createTextField ("myText",this.getNextHighestDepth (),(640 - 200) / 2,(400 - 30) / 2,200,30);
myText.background = true;
myText.backgroundColor = 0x666666;
var my_fmt:TextFormat = new TextFormat ();
my_fmt.bold = true;
my_fmt.font = "Arial";
my_fmt.color = 0xFF9900;
myText.wordWrap = true;
myText.multiline = true;
myText.border = true;
myText.type = "dynamic";
myText.autoSize = true;
myText.html = true;
myText.setNewTextFormat (my_fmt);
myText.htmlText = e;
}
btn1.onRollOver = function () {
showText ("Button 1 text <br> something else here");
};
btn2.onRollOver = function () {
showText ("Button 2 text");
};
btn3.onRollOver = function () {
showText ("Button 3 text");
};
btn1.onRollOut = function () {
myText.removeTextField ();
};
btn2.onRollOut = function () {
myText.removeTextField ();
};
btn3.onRollOut = function () {
myText.removeTextField ();
};
Should do the trick.
Very nice. The background worked great but I think that it doesn’t recognize the <br> as code rather than just text. It just shows the <br> tag in the text.
btw, thanks for all the help man!
Great tutorial and help. Is there a way to Pass the text as a Variable to a web page with getURL call? Attempting to pass the myText a string in ASP. Thanks
I wouldn’t use getURL, I would use Load Vars(). Then send as a form value to ASP.
myData = new Load Vars();
myData.myText = _root.myText.text;
myData.send("yourasp.asp",myData, "POST");
Then is your asp just do something like
<% myText = Request.Form("myText") %>
That’s not tested or anything but it’s the basic idea.
Forgive me as I’m still trying to catch up to you all in knowledge and experience;
Here’s what I have. Flash working but not passing to ASP;
stop();
function showText (e:String) {
_root.createTextField (“myText”,this.getNextHighestDepth (),(400 - 40) / 2,(100 - 30) / 2,200,30);
var my_fmt:TextFormat = new TextFormat ();
my_fmt.bold = true;
my_fmt.font = “Arial”;
my_fmt.color = 0xFF9900;
myText.wordWrap = true;
myText.multiline = true;
myText.border = false;
myText.type = “dynamic”;
myText.autoSize = false;
myText.setNewTextFormat (my_fmt);
myText.text = e;
}
btn1.onPress = function () {
showText (“Part1”);
};
btn2.onPress = function () {
showText (“Part2”);
};
btn3.onPress = function () {
showText (“Part3”);
};
send_btn.onRelease = function() {
myData = new Load Vars();
myData.myText = _root.myText.text;
myData.send(“cart.asp”,myData, “POST”);
Ha, I’m sorry no space between LoadVars();
stop();
function showText(e:String) {
_root.createTextField("myText",this.getNextHighestDepth(),(400-40)/2,(100-30)/2,200,30);
var my_fmt:TextFormat = new TextFormat();
my_fmt.bold = true;
my_fmt.font = "Arial";
my_fmt.color = 0xFF9900;
myText.wordWrap = true;
myText.multiline = true;
myText.border = false;
myText.type = "dynamic";
myText.autoSize = false;
myText.setNewTextFormat(my_fmt);
myText.text = e;
}
btn1.onPress = function() {
showText("Part1");
};
btn2.onPress = function() {
showText("Part2");
};
btn3.onPress = function() {
showText("Part3");
};
send_btn.onRelease = function() {
myData = new LoadVars();
myData.myText = _root.myText.text;
myData.send("cart.asp",myData,"POST");
};
That should work.
OK. Thanks for the LoadVars Fix… I’m understanding more of these functions, but still can’t seem to send any of the Vars successfully. I have tried the following ASP scripts with the following results;
Flash Code “POST”:
send_btn.onRelease = function() {
myData = new LoadVars();
myData.myText = _root.myText.text;
myData.send(“cart.asp”,myData,“POST”);
};
ASP Code:
<% showText = Request.Form(“myText”) %>
Browser Yields Blank Page With URL Reading;
http://www.websitename.com/cart.asp
Flash Code “GET”:
send_btn.onRelease = function() {
myData = new LoadVars();
myData.showText = _root.createTextField;
if(my_fmt:TextFormat = new TextFormat ());
myData.send(“cart.asp”,myData,“GET”);
};
ASP Code:
<% showText = Request.QueryString(“myText”) %>
Browser Yields Blank Page With URL Reading;
http://www.websitename.com/cart.asp?showText=[type%20Function]
If flash is sending Vars successfully to the ASP page shouldn’t we be seeing something like myData=Part1,Part2,Part3
Pm me the public URL to addCart.asp and I will try and hook it up… Just do a response.write so i can see the result…
Thanks Digitalosophy. Finally figured it out… now attempting to do multiple submissions. Will post successful code when complete.