|
SWiSH Forum Forum użytkowników programów SWiSH |
 |
SWiSH Max - Wstawianie tekstu w zaznaczonym miejscu w dynamic/input text
tito - Sro 31 Mar, 2010 20:01 Temat postu: Wstawianie tekstu w zaznaczonym miejscu w dynamic/input text Witajcie
Mam następujący problem...>>
Stworzyłem input text field(okno_zmian) do którego ładuje się tekst formatowany w html z bazy danych.
Do tego tekstu potrzebuję skryptu który po zaznaczeniu np jednego z wyrazów:
a) zrobi z niego link
b) pogrubi text
c) kursywa
Sposób dodawania linków i tekstów pogrubionych zrobiłem, ale problem jest w tym .. aby to wstawiało się w zaznaczonym miejscu, a nie na końcu.
Pytanie moje jest takie:
Czy jest jakiaś funkcja lub skrypt, który ma możliwość edycji zaznaczonego tekstu w dynamic/input/text field?
pod tym linkiem znajdziecie wersję roboczą>>
http://www.multimedialnarewolucja.pl/phptest
Proszę o pomoc, gdyż szukam, szukam i nic jak dotychczas nie znalazłem.
Pozdrawiam
Januszr - Sro 31 Mar, 2010 21:24
Text Editor napisany w swish jest tutaj:
http://forums.swishzone.c...showtopic=68682
Wygląda mniej więcej jak na obrazku.
Może cokolwiek Ci podpowie ten link.
Pozdrawiam,
JanuszR
tito - Wto 06 Kwi, 2010 14:02
Dzięki Januszu!
Wile mi to ułatwi, ale mam jeszcze jeden problem ze skryptem ładującym z xml.
Cały skrypt działa bez problemów, jeżeli w danej animacji nie ma animacji i nie jest to plik ładowany do głównego movie.
Mam coś takiego, do głównego movie, do klipu >> galeria/load_here ładuje plik
Kod: | _parent.galeria.load_here.loadMovie("galeria/4/g4.swf"); |
z takim oto kodem:
Kod: | onSelfEvent (load) {
var catalogue = new XML();
catalogue.ignoreWhite = true;
var record = 0;
var total = 0;
var current = 0;
catalogue.load("gallery.xml");
catalogue.onLoad = function(success)
{if (success)
{category_txt = this.firstChild.childNodes[_root.record].attributes.category;
pictitle_txt = this.firstChild.childNodes[_root.record].attributes.pictitle;
notes_txt = this.firstChild.childNodes[_root.record].attributes.notes;
picHolder.loadMovie("images/"+this.firstChild.childNodes[_root.record].attributes.image);
total = this.firstChild.childNodes.length;
current = record + 1;
entryNum_txt = current+" of "+ total;
}};
stop();
back_btn.onPress=function()
{if(record == 0) {record = total - 1;}
else {record -= 1;}
catalogue.load("gallery.xml");};
forward_btn.onPress=function() {if(record + 1 == total) {record = 0;}
else {record += 1;}
catalogue.load("gallery.xml");};
} |
I tak jak pisałem, plik działa prawidłowo sam ale jak jest załadowany do głónwgo movie... nie.
Jeżeli miałbyś jakąś podpowiedź, będę wdzięczny. Pozdrawiam serdecznie i jeszcze raz dzięki za pomoc.
Januszr - Wto 06 Kwi, 2010 14:34
1) plik ładowany jest w innej wersji FP niż plik do którego jest ładowany;
2) plik ładowany używa AS, ktorego nie obsługuje plik, do którego jest ładowany (np pliku z ActionScript3 nie załadujesz do pliku zrobionego ze swish, który obsługuje max AS2)
3) ilość "_parent" nie jest wystarczająca
4) zgaduj zgadula
Nie znam się na edycji/wykorzystywaniu XML z swf.
tito - Czw 08 Kwi, 2010 15:21
Darowałem sobie "pośredniczenie" pliku xml.
Powrócę do tego Text Editora. Chciałem aby do niego ładował się tekst z bazy danych poprzez:
this.loadVariables("czytaj.php",'GET');
a potem zapisywał przez
this.loadVariables("zmien.php",'POST');
ale problem mam taki, że ten Text Editot tworzy sobie pole tekstowe poprzez skrypt i niby podany jest w tym skrypcie
EdiorText.variable = "eText";
ale nie chce się do niego załadowac tekst z poprzez plik php.
Jak zrobię pole tekstowe o takim "variable" to sie ładuje.
I pytanie teraz czemu nie ładuje się do tego pola które tworzy ten skrypt:
Kod: | onSelfEvent (load) {
var EdiorWidth:Number = 539;
var baseTabs:Array = new Array();
var oneStep:Number = 24;
var steps:Number = Math.floor(EdiorWidth/oneStep);
for (i=1; i<=steps; i++) {
var cStep:Number = i*oneStep;
baseTabs.push(cStep);
}
var baseFormat:TextFormat = new TextFormat();
baseFormat.align = "left"; // "left" / "right" / "center" / "justify"
baseFormat.blockIndent = null; // Einzug alle Zeilen in einem Abschnitt: Zahl in Pixel (negativ möglich wenn > 0)
baseFormat.bold = false; // true / false
baseFormat.bullet = false; // Aufzählung: true / false
baseFormat.color = 0x000000; // Farbe Hexformat: z.B.: 0xFF0000 für Rot
baseFormat.font = "Arial"; // Schriftart (muss eingebettet sein)
baseFormat.indent = null; // Einzug 1. Zeile: Zahl in Pixel (negativ möglich wenn > 0)
baseFormat.italic = false; // true / false
baseFormat.kerning = false; // Sollte nicht aktiviert werden
baseFormat.leading = 0; // Zahl, die den Abstand zwischen den Zeilen in Pixel (vertikaler Abstand) angibt, kann negativ sein
baseFormat.leftMargin = null; // Der linke Rand des Absatzes in Punkt.
baseFormat.letterSpacing = 0; // Der Platz, der gleichmäßig zwischen den Zeichen aufgeteilt wird. Der Wert gibt an, wie viel Pixel Leerraum hinter
// jedes Zeichen einzufügen sind. Bei einem negativen Wert wird der Platz zwischen den Zeichen verkleinert.
// Systemschriften unterstützen nur Ganzzahlen. Bei eingebetteten Schriften können Sie jedoch
// Fließkommawerte angeben (z. B. 2,6).
baseFormat.rightMargin = null; // Der rechte Rand des Absatzes in Punkt.
baseFormat.size = 12; // Die Punktgröße von Text in diesem Textformat.
baseFormat.tabStops = baseTabs; // Gibt benutzerdefinierte Tabstopps als Array aus nicht negativen Ganzzahlen an. Jeder Tabstopp wird in Pixeln angegeben.
// Wenn keine benutzerdefinierten Tabstopps definiert werden (null), wird als Standardtabstopp 4 verwendet
// (durchschnittliche Zeichenbreite). \t ist das Tabulatorzeichen
baseFormat.target = "_blank"; // Gibt das Zielfenster an, in dem der Hyperlink angezeigt werden soll: "_self", "_blank", "_parent", "_top" oder Benutzerdefiniert
baseFormat.underline = false; // true / false
baseFormat.url = null; // Basisurl für Hyperlinks etc.
createTextField("EdiorText", getNextHighestDepth(), 1, 70, EdiorWidth, 338);
EdiorText.embedFonts = false;
EdiorText.antiAliasType = "normal";
EdiorText.type = "input";
EdiorText.variable = "eText";
EdiorText.html = true;
EdiorText.maxChars = null;
EdiorText.selectable = true;
EdiorText.autoSize = false;
EdiorText.multiline = true;
EdiorText.wordWrap = true;
EdiorText.mouseWheelEnabled = true;
EdiorText.background = false;
EdiorText.condenseWhite = false;
EdiorText.border = true;
EdiorText.tabEnabled = false;
EdiorText.setNewTextFormat(baseFormat);
var EdiorMenu:ContextMenu = new ContextMenu();
var prInBr:ContextMenuItem = new ContextMenuItem("Preview in Browser", browserPreview, false, true, true);
var sRe:ContextMenuItem = new ContextMenuItem("Redo last Action", Redo, true, false, true);
var sUn:ContextMenuItem = new ContextMenuItem("Undo last Action", Undo, false, false, true);
EdiorMenu.customItems.push(prInBr,sRe,sUn);
EdiorText.menu = EdiorMenu;
/*var TextStyle:TextField.StyleSheet = new TextField.StyleSheet();
TextStyle.onLoad = function(success:Boolean) {
if (success) {
EdiorText.styleSheet = TextStyle;
eText = '<a href="test">Das ist ein Test</a>';
}
};
TextStyle.load("flashStyles.css");*/
EdiorText.onKillFocus = function() { clearInterval(cC); }
EdiorText.onSetFocus = function() { cC = setInterval(checkChange,200); }
sS = null;
sE = null;
var cChanged:Boolean = false;
btn_Link.swapDepths(getNextHighestDepth());
btn_Size.swapDepths(getNextHighestDepth());
btn_Color.swapDepths(getNextHighestDepth());
var savePoint:Array = new Array();
var cRedoPos:Number = 0;
var maxRedoPos:Number = 50;
RDId = setInterval(checkRedoPoint,1000);
Selection.setFocus(EdiorText);
if (EdiorText.text.length==0) { EdiorText.replaceSel(" "); }
var EditorHTMLPresaved:String = EdiorText.htmlText;
}
function browserPreview() {
if (typeof(postPreview)=="movieclip") {
postPreview.removeMovieClip();
}
createEmptyMovieClip('postPreview',getNextHighestDepth());
postPreview.htmlPostVar = EdiorText.htmlText;
postPreview.parseFlash = "defined";
postPreview.getURL("htmlPreview.php", "_blank","POST");
}
function checkChange() {
if (sS != Selection.getBeginIndex() OR sE != Selection.getEndIndex()) {
sS = Selection.getBeginIndex();
sE = Selection.getEndIndex();
cChanged = false;
}
else if (!cChanged) {
returnSelectionsFormat();
cChanged = true;
}
}
function returnSelectionsFormat() {
sS = Selection.getBeginIndex();
sE = Selection.getEndIndex()
if (sS == sE && sS > 0) { sS--; }
if (sS == sE && sS == 0) { sE++; }
if (EdiorText.text.length==0) { EdiorText.replaceSel(" "); }
btn_Bold.toggleBold(EdiorText.getTextFormat(sS, sE).bold);
btn_Italic.toggleItalic(EdiorText.getTextFormat(sS, sE).italic);
btn_Underline.toggleUnderline(EdiorText.getTextFormat(sS, sE).underline);
btn_Bullet.toggleBullet(EdiorText.getTextFormat(sS, sE).bullet);
btns_Align.toggleAlign(EdiorText.getTextFormat(sS, sE).align);
btn_Size.toggleSize(EdiorText.getTextFormat(sS, sE).size);
btn_Color.toggleColor(EdiorText.getTextFormat(sS, sE).color);
btn_WSpace.toggleWordSpace(EdiorText.getTextFormat(sS, sE).letterSpacing);
btn_HSpace.toggleHSpace(EdiorText.getTextFormat(sS, sE).leading);
btn_Link.toggleURL(EdiorText.getTextFormat(sS, sE).url, EdiorText.getTextFormat(sS, sE).target);
}
function checkRedoPoint() {
if (EdiorText.htmlText != EditorHTMLPresaved) {
EditorHTMLPresaved = EdiorText.htmlText;
addSavePoint();
}
}
function addSavePoint() {
if (cRedoPos < (savePoint.length-1)) {
savePoint = savePoint.slice(0, cRedoPos);
}
if (savePoint.length > maxRedoPos) {
savePoint.shift();
savePoint.sort(16);
savePoint[savePoint.length] = EdiorText.htmlText;
}
else {
savePoint[savePoint.length] = EdiorText.htmlText;
}
cRedoPos = (savePoint.length-1);
sUn.enabled = true;
sRe.enabled = false;
}
function Redo() {
cRedoPos++;
clearInterval(RDId);
EdiorText.htmlText = savePoint[cRedoPos];
var tFormat:TextFormat = new TextFormat();
tFormat.tabStops = baseFormat.tabStops;
tFormat.indent = baseFormat.indent;
EdiorText.setTextFormat(tFormat);
EditorHTMLPresaved = EdiorText.htmlText;
RDId = setInterval(checkRedoPoint,1000);
if (cRedoPos==(savePoint.length-1)) { sRe.enabled = false; }
sUn.enabled = true;
}
function Undo() {
cRedoPos--;
clearInterval(RDId);
EdiorText.htmlText = savePoint[cRedoPos];
var tFormat:TextFormat = new TextFormat();
tFormat.tabStops = baseFormat.tabStops;
tFormat.indent = baseFormat.indent;
EdiorText.setTextFormat(tFormat);
EditorHTMLPresaved = EdiorText.htmlText;
RDId = setInterval(checkRedoPoint,1000);
if (cRedoPos==0) { sUn.enabled = false; }
sRe.enabled = true;
} |
hmm... co myślisz?
W zasadzie wystarczyłoby mi to co zrobiłem
http://multimedialnarewolucja.pl/phptest/
tylko aby link (kursywa lub pogrubienie) wstawiało się w miejscu zaznaczenia, a nie na końcu, bo zrobiłem to dość łopatologicznie (dodaje to na końcu):
on (release) {
_parent.okno_zmian = _parent.okno_zmian add b1 add tekst_pogrubiony add b2;
}
Oczywiście jeżeli w tym Text Editorze da sie przycisać ładowany z bazy tekst .. to będzie lepiej.
Pozdrawiam
Januszr - Czw 08 Kwi, 2010 20:33
Nie wiem
|
|