Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   Flex (http://www.flasher.ru/forum/forumdisplay.php?f=84)
-   -   выделение ссылок в htmlText (mx:Text, mx:Label etc...) (http://www.flasher.ru/forum/showthread.php?t=111505)

†‡Paladin‡† 29.04.2008 10:46

выделение ссылок в htmlText (mx:Text, mx:Label etc...)
 
В справке сказано цитирую:
Цитата:

<a href='http://www.adobe.com' target='_blank'>Go Home</a>

You can also define a:link, a:hover, and a:active styles for anchor tags by using style sheets.

The <a> tag does not make the link text blue. You must apply formatting tags to change the text format. You can also define a:link, a:hover, and a:active styles for anchor tags by using style sheets.
Насколько я понимаю ссылки просто так цветом не выделить. Для этого их нужно обернуть в <font color="#0000FF"></font>. Есть другие варианты? Так-же сказано, что можно задать a:hover и a:link. Где задавать и как задавать совершено непонятно. Если у кого есть пример поделитесь плз.

etc 29.04.2008 14:46

using style sheets

†‡Paladin‡† 29.04.2008 15:28

Это я понял. Реквестирую пример стиля.

etc 29.04.2008 16:03

Код:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="this.init();">
        <mx:Label id="testLabel">
        </mx:Label>
        <mx:Script>
                <![CDATA[
                        import mx.core.mx_internal;
                        use namespace mx_internal;
                       
                        private function init():void {
                                var styleSheet:StyleSheet = new StyleSheet();
                                styleSheet.setStyle("a:link", { textDecoration: "none", color: "#813F98" });
                                styleSheet.setStyle("a:hover", { textDecoration: "underline" });
                                styleSheet.setStyle("a:active", { textDecoration: "underline" });
                                this.testLabel.htmlText = '<a href="http://ya.ru">ya.ru</a>';
                                this.testLabel.mx_internal::styleSheet = styleSheet;
                        }
                ]]>
        </mx:Script>
</mx:Application>


†‡Paladin‡† 29.04.2008 16:55

Спасибо за костыли. Финально это выглядит так
Код:

                        private function createAdvicesStyle():void {
                                adviceStyle.setStyle("a:link", { textDecoration: "none", color: "#D0EB55" });
                                adviceStyle.setStyle("a:hover", { textDecoration: "underline" });
                                adviceStyle.setStyle("a:active", { textDecoration: "underline" });
                        }

                                        <mx:Repeater id="advicesRPTR" dataProvider="{_advices}">
                                                <mx:Canvas label="{'- ' + advicesRPTR.currentItem.title}" width="100%" height="100%"
                                                        backgroundColor="#6F7777" fontWeight="normal">
                                                        <mx:Text width="100%" height="100%" selectable="true"
                                                                creationComplete="{event.target.styleSheet = adviceStyle}">
                                                                <mx:htmlText>
                                                                        {'  ' + advicesRPTR.currentItem.body}
                                                                </mx:htmlText>                                                                                                                       
                                                        </mx:Text>
                                                </mx:Canvas>                                       
                                        </mx:Repeater>

Как это написать чистым MXML у меня идей нету.

kutuzov 26.08.2008 15:44

А что делать, если мне необходимо динамически менять fontSize?
Код:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" applicationComplete="init()"
        click="onChangeFontSize()">
       
        <mx:Script>
                <![CDATA[
                        import mx.core.mx_internal;
                        use namespace mx_internal;
                       
                        private function init():void {
                                var css:StyleSheet = new StyleSheet();
                                css.setStyle("a:link", {color:"#0000CC"});
                                txt.mx_internal::styleSheet = css;
                        }
                       
                        private function onChangeFontSize():void {
                                var size:Number = box.getStyle("fontSize") + 1;
                                box.setStyle("fontSize", size);
                        }
                ]]>
        </mx:Script>
       
        <mx:Box id="box" width="100%" height="100%">
                <mx:Text id="txt">
                        <mx:htmlText>
                                <![CDATA[qwe <a href="http://ya.ru">ya.ru</a> qwe]]>
                        </mx:htmlText>
                </mx:Text>
        </mx:Box>
</mx:Application>

Кликая по сцене шрифт должен увеличиваться, но делает он это только если не применять css к txt

ps можно конечно обрамлять текст с помощью
Код:

<font size="16">qwe</font>
но хочется, чтоб все было автоматически как с обычным текстом без css


Часовой пояс GMT +4, время: 05:56.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.