![]() |
|
||||||||||
|
|||||
|
Регистрация: Feb 2009
Сообщений: 15
|
Посидел, много error's набрал и понял что пока мозгов моиз не хватает,
поиск много чего дает(кому-то), но изменить, пока тоже не получается. Вся надежда на тебя !-) Люди, нужна поддержка... Как же надо изменить КОД, на что-то типа этого? (Помогите, я только начал изучать AS (10 дней назад, сразу как закрыл сессию и перешел на 2 курс)) Последний раз редактировалось l576; 15.07.2009 в 02:34. |
|
|||||
|
Регистрация: Jul 2009
Сообщений: 47
|
Присоединяюсь к вопросу.
Кто-нибудь может помочь. |
|
|||||
|
Можешь так попробовать.
var outputTextField:TextField; var startIndex:Number; var endIndex:Number; var txt:String; btn.onPress = rep_select; function rep_select():Void { startIndex = Selection.getBeginIndex(); endIndex = Selection.getEndIndex(); txt = outputTextField.text.substring(startIndex, endIndex); trace(txt); outputTextField.replaceText(startIndex,endIndex,'<a href="'+txt+'"></a>'); } |
|
|||||
|
Регистрация: Jul 2009
Сообщений: 47
|
// Как должен выглядеть КОД полностью, так не срабатывает,
var caretIndex: Number = -1; var outputTextField:TextField; var startIndex:Number; var endIndex:Number; var result:String; Key.addListener(this); this.btn.onRelease = function():Void { startIndex = Selection.getBeginIndex(); endIndex = Selection.getEndIndex(); txt = outputTextField.text.substring(startIndex, endIndex); }; function storeCaretIndex():Void { if ( Selection.getFocus() != String(this.outputTextField) ) return; this.caretIndex = Selection.getCaretIndex(); trace(this.caretIndex); } //----------------------------------- // // Events handlers // //----------------------------------- function onKeyUp():Void { this.storeCaretIndex(); } function onMouseDown():Void { this.onEnterFrame = this.enterFrameHandler; } function enterFrameHandler():Void { this.onEnterFrame = null; this.storeCaretIndex(); } var app: Object = this; var outputTextField: TextField; var inputTextField: TextField; var caretIndex: Number = -1; Key.addListener(this); this.button.onRelease = function():Void { var result: String; var inline: String = '<a href="' + app.inputTextField.text + '"></a>'; if ( app.caretIndex > -1 ) { result = app.outputTextField.text.slice(0, app.caretIndex) + inline + app.outputTextField.text.slice(app.caretIndex + 1); } else { result = app.outputTextField.text + inline; } app.outputTextField.text = result; }; function storeCaretIndex():Void { if ( Selection.getFocus() != String(this.outputTextField) ) return; this.caretIndex = Selection.getCaretIndex(); trace(this.caretIndex); } //----------------------------------- // // Events handlers // //----------------------------------- function onKeyUp():Void { this.storeCaretIndex(); } function onMouseDown():Void { this.onEnterFrame = this.enterFrameHandler; } function enterFrameHandler():Void { this.onEnterFrame = null; this.storeCaretIndex(); } Последний раз редактировалось codfelix; 15.07.2009 в 12:23. |
|
|||||
|
.
|
кат-то так можно
var app: Object = this; var pattern: String = '<a href="{s}"></a>'; var outputTextField: TextField; var beginIndex: Number = -1; var endIndex: Number = -1; this.button.onRelease = function():Void { if (app.beginIndex == -1 || app.endIndex <= app.beginIndex ) return; Selection.setFocus( String(app.outputTextField) ); Selection.setSelection(app.beginIndex, app.endIndex); var inline: String = app.substitute ( pattern, app.outputTextField.text.slice(app.beginIndex, app.endIndex) ); app.outputTextField.replaceSel(inline); }; this.outputTextField.onMouseUp = this.outputTextField.onKeyUp = function():Void { app.beginIndex = Selection.getBeginIndex(); app.endIndex = Selection.getEndIndex(); }; this.outputTextField.onSetFocus = function():Void { Key.addListener(this); Mouse.addListener(this); }; this.outputTextField.onKillFocus = function():Void { Key.removeListener(this); Mouse.removeListener(this); }; function substitute():String { var temp: Array = arguments[0].split('{s}'); var i: Number = temp.length; if (i-- > 1) while (i--) temp[i] += arguments[i + 1]; return temp.join(''); } |
![]() |
![]() |
Часовой пояс GMT +4, время: 08:54. |
|
|
« Предыдущая тема | Следующая тема » |
|
|