Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

create clickable link

Explorer ,
Apr 08, 2009 Apr 08, 2009

I need to create something like this:

   _myButton.addEventListener(MouseEvent.CLICK, onMouseClick);

function onMouseClick(e:MouseEvent):void
{
var request:URLRequest = new URLRequest("http://www.inspired-evolution.com");
navigateToURL(request,"_blank");
}

except not with a button click.

Instead I just need to create the link within text eg:

LinkText.text="Click here to download the doucment";

how can I accomplish this?

TOPICS
ActionScript
3.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Apr 08, 2009 Apr 08, 2009

In flash there is a link input box in the properties panel for text.

1. Select the text you want to be the link.

2. Go to the properties panel.

3. Find the "URL Link" box.  In CS3 this is designated by an icon that looks like a chain link.

4. Enter the URL that you want the text to link to in the box.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 08, 2009 Apr 08, 2009

You can do this by setting the text field to html and using the code below.

LinkText.htmlText="<a href='http://www.adobe.com'>Click here to download the doucment</a>";
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 08, 2009 Apr 08, 2009

the name of the text field is feedback and I am trying this code, but it doesn't seem to be working.

feedback.setTextFormat(format);
                addChild(feedback);
               
            }else if (type == "success") {
                feedback.text = "Congrats on finishing the exam!\r\nYour score is "+Math.round(score*100)+"%\r\nClick to download your certificate\r\nYou may now close the exam window .";
                feedback.htmlText="<a href='http://www.adobe.com'>Click here to download the document</a>";
                feedback.setTextFormat(format);
                addChild(feedback);

the ouputing result is just Click here to download the document without the hyperlink.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Apr 08, 2009 Apr 08, 2009

You can't put text AND htmlText into a text field.  It has to be 1 or the other.

So:

feedback.htmlText = "Congrats on finishing the exam!<br>Your score is "+Math.round(score*100)+"%<br>Click to download your certificate<br>You may now close the exam window .<br><a href='http://www.adobe.com'>Click here to download the document</a>";

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 08, 2009 Apr 08, 2009

thanks, but when I try that in the window, everthing else works,  but the HTMl isn't rendereing. Do I need to change something somewhere else as well?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 08, 2009 Apr 08, 2009

Did you set the text field as html in the properties panel?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 08, 2009 Apr 08, 2009

no, but everything is being generated with AS3 code and not with the text box. I think the <br />

is rendering, but not the <a href>. Here is the entire code in case I need to set a variable or something.

package exam {
   
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;
   
    //this class is used to create a "pop-up" window to ask users to confirm they want to exit (after clicking
    //exit exam button), and then to report back on how the submission went, and offer to resend if necessary
    public class MessageWindow extends Sprite {
        //VARIABLES
        private var feedback:TextField;
        private var confirm:YesBtn;
        private var quit:CancelBtn;
        private var resend:ResendBtn;
       
        public function MessageWindow (type:String, unanswered:Number=0, score:Number=0) {
            var bg:Shape = new Shape();
            bg.graphics.beginFill(0xcccccc,1);
            bg.graphics.lineStyle(3,0x122837);
            bg.graphics.lineTo(400,0);
            bg.graphics.lineTo(400,250);
            bg.graphics.lineTo(0,250);
            bg.graphics.lineTo(0,0);
            bg.graphics.endFill();
            addChild(bg);
           
           
           
            var format:TextFormat = new TextFormat();
            format.font = "Arial";
            format.size = "16";
            format.bold = false;
            format.color = 0x122837;
            feedback = new TextField();
            feedback.width = 300;
            feedback.x = 50;
            feedback.y = 15;
            feedback.wordWrap = true;
            feedback.autoSize = TextFieldAutoSize.LEFT;
            feedback.mouseEnabled = false;
            feedback.multiline=true;
           
            if (type == "confirm") {
                feedback.text = "Are you sure you want to exit the exam?";
                if (unanswered > 0) {
                    feedback.appendText("  You still have "+unanswered+" unanswered questions.");
                }
                feedback.setTextFormat(format);
                addChild(feedback);
                quit = new CancelBtn();
                quit.setType("cancel");
                quit.x = 25;
                quit.y = this.height - (quit.height + 15);
                addChild(quit);
                confirm = new YesBtn();
                confirm.setType("confirm");
                confirm.y = quit.y;
                confirm.x = this.width - (confirm.width + 25);
                addChild(confirm);
            }else if (type == "success") {
                feedback.htmlText = "Congrats on finishing the exam!<br />Your score is "+Math.round(score*100)+"%<br />Click to <a href='http://link to pdf.pdf '>download</a> your certificate<br />You may now close the exam window after you have downloaded and printed the certificate .";
               
                feedback.setTextFormat(format);
                addChild(feedback);
            }else {
                if (type == "databaseError") {
                    feedback.text = "Errors occured while saving your data.  Please retry.";
                }else if (type == "networkError") {
                    feedback.text = "Could not contact the server.  Please make sure you are connected to the internet and try again.";
                }
                feedback.setTextFormat(format);
                addChild(feedback);
                resend = new ResendBtn();
                resend.setType("resend");
                resend.x = 200-(resend.width/2);
                resend.y = this.height - (resend.height + 15);
                addChild(resend);
            }
        }
    }
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Apr 08, 2009 Apr 08, 2009

Remove "feedback.mouseEnabled = false;"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 08, 2009 Apr 08, 2009

ok, that resolved the link not working, thanks. One more small thing. Is there a way for the link to be a different color than the other text, like it would be on a web page?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Apr 08, 2009 Apr 08, 2009

Set the text format before setting the text, then just use <font color='#CC0000'>download</font>.

Edit: CC0000 should be 0000CC if you want it blue, temporary brain fart on the rgb

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 08, 2009 Apr 08, 2009

for some reason this doesn't change the font color for me. Am I doing something wrong?

feedback.htmlText = "Congrats on finishing the exam!<br /><br />Your score is "+Math.round(score*100)+"%<br /><br />Click to <a href='http://etsi-dataservices.com/Centocor/Simponi_certificate.pdf ' target= '_ blank '><font color='#0000cc'><u>download</u></font></a> your certificate.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 08, 2009 Apr 08, 2009

What does it show for you?

It returned an error for me saything that the <br>s were throwing an error.

Try this:

feedback.htmlText = "Congrats on finishing the exam!"

feedback.htmlText +="Your score is %<br><br>Click to <a href='http://etsi-dataservices.com/Centocor/Simponi_certificate.pdf ' target= '_ blank '><font color='#0000cc'><u>download</u></font></a> your certificate."

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 08, 2009 Apr 08, 2009
LATEST

I wasn't getting any errors, with the <br> when I compiled, but anyway what you have did the trick. Thanks again.

BTW how do you format your code the way you did with this new forums configuration? I haven't figured that out yet.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines