I need to provide a link (like Click here to view.....) in开发者_开发知识库 a AlertBox that redirects to another page. Help needed...
Then you may want to consider making something that isn't an alert box. An alert box is just that, a box alerting you of something. I'm sure you could pound a square peg into a round hole, but I would rather take the easier route and make a custom component that looks like an alert box with an html link in it.
Create your custom component extending Panel
. Add a link Label
to it. Than use PopUpManager.addPopUp
to show your custom alert box.
Create custom TitleWindow and style it to look like Alert box. Set header height 0 and you get rid of TitleWindow header. Use PopUpManager to popup your own Alert window.
As others have said, you'll need to create a new Panel or TitleWindow and add your own link there. Here's an example that should get you started:
NewAlert.mxml
import mx.core.FlexGlobals;
import mx.managers.PopUpManager;
static public function show(text:String = null, title:String = 'Alert', modal:Boolean = true):NewAlert
{
var w:NewAlert = PopUpManager.createPopUp(FlexGlobals.topLevelApplication, NewAlert, modal) as NewAlert;
w.title = title;
w.text = text;
return ;
}
// Can be HTML text
public function set text(value:String):void
{
if(value && value.length > 0)
{
richTxt.textFlow = TextConverter.importToFlow(value, TextConverter.TEXT_FIELD_HTML_FORMAT);
}
}
]]>
</fx:Script>
<s:RichEditableText id="richTxt"
editable="false"
focusEnabled="false">
<s:textFlow>
<s:TextFlow>
<s:p>
Default Text with Link: <s:a href="http://www.adobe.com">Adobe.com</s:a>
</s:p>
</s:TextFlow>
</s:textFlow>
</s:RichEditableText>
</s:TitleWindow>
From here, you can just do NewAlert.show('some HTML content')
as long as the html text is properly formatted, it'll be good.
精彩评论