Flash Tooltip-Text-Styling Frage

Beitrag Oktober 14th, 2009, 6:50 pm

Hallo,

Ich habe eine Flash Virtuelle Tour von einer früheren Kollegin geerbt und haben einen Haken schlagen. Der Tooltipp Ich benutze stützt sich auf die "alt"-Tag von meiner XML-Dokument. Ich brauche, um den wissenschaftlichen Namen kursiv, aber anscheinend kann ich nicht nur ein paar Worte kursiv zu machen.

In dem XML-Dokument kann ich die altFont fest, die der ganzen Linie kursiv...aber wirklich brauchen, um nur ein paar Wörter im Satz angeben.

Ich dachte, vielleicht brauche ich etwas, um das Flash ActionScript hinzu und eine neue "Attribut angeben"? Ich bin ein Designer und Entwickler nicht so hoffe, es ist jemand da draußen, die mich in die richtige Richtung weisen könnten?

Unten ist die ActionScript...

Thanks heaps!

ACTIONSCRIPT Code: [ Download ] [ Select ]
// Tooltips plugin
 
var id:String="Tootips";
var version:String="1.0";
var panoController:Object=null;
var pano:Object=null;
var hotspots:Object;
var waitTimer:Timer;
 
// this function is called on plugin's start
function init (panoMain:Object) {
   panoController = panoMain;
   if (panoMain.addExternal(this)) {
      waitTimer = new Timer(50);
      waitTimer.addEventListener(TimerEvent.TIMER, waitHotspots, false, 0, true);
      waitTimer.start();
   }     
}
 
// this function is called when new panorama is loading
function newPano(link:Object) {
   pano = link;
}
 
// wait for Hotspots plugin to load before starting tooltips
function waitHotspots (event:Event) {
   if (panoController.externals.hotspots!=null) {
      waitTimer.stop();
      waitTimer = null
      hotspots = panoController.externals.hotspots;
      hotspots.addEventListener(MouseEvent.MOUSE_OVER, doOver, false, 0, true);
      hotspots.addEventListener(MouseEvent.MOUSE_OUT, doOut, false, 0, true);
      hotspots.addEventListener(MouseEvent.CLICK, doOut, false, 0, true);
   }
}
 
var animationTimer:Timer;
var speed:Number;
var currentObject:Object;
var alphaMax:Number = 1;
var alphaMin:Number = -1.4;
var alphaPlus:Number = 0.2;
var alphaMinus:Number = -0.08;
 
visible = false;
alpha = alphaMin;
tip.scale9Grid = new Rectangle(5, 5, tip.width-10, tip.height-10);
tip_txt.autoSize = TextFieldAutoSize.LEFT;
 
function doOver (event:Event) {
   // find object with property "attributes" (all hotspots has this object)
   var obj:Object = event.target;
   while (!obj.hasOwnProperty("attributes")) {
      if (obj.hasOwnProperty("parent")) {
         obj = obj.parent;
      } else {
         return;
      }
   }
   // try to get propery alt (stored in XML: <spot url="1.jpg" alt="My Picture" />)
   var text:String = obj.attributes.getParam("alt");
   if (text!=null) {
      currentObject = obj;
      // if text contais \n, it is multilines
      if (text.indexOf("\n")!=-1) {
         text = text.replace(/\n/g, "\n")
      }
      tip_txt.text = text;
      tip.width = tip_txt.width+10;
      tip.height = tip_txt.height+4;
      // start animation
      speed = alphaPlus;
      visible = true;
      if (animationTimer!=null) {
         animationTimer.stop();
      }
      animationTimer = new Timer(30);
      animationTimer.addEventListener(TimerEvent.TIMER, animation, false, 0, true);
      animationTimer.start();
   }
}
 
function doOut (event:Event) {
   speed = alphaMinus;
}
 
function animation (event:Event) {
   if (speed>0) {
      if (alpha < alphaMax) {
         alpha += speed;
      } else {
         alpha = alphaMax;
      }
      x = parent.mouseX-8;
      y = parent.mouseY+20;
      //
      if (x<0) {
         x = 0;
      }
      if (x+width>pano.width) {
         x = pano.width-width;
      }
      if (y+height>pano.height) {
         y = pano.height-height;
      }
      if (!currentObject.visible) {
         speed = alphaMinus;
      }
   } else {
      if (alpha > alphaMin) {
         alpha += speed;
      } else {
         alpha = alphaMin;
         animationTimer.stop();
         animationTimer = null;
      }
   }
}
 
function remove () {
   hotspots.removeEventListener(MouseEvent.MOUSE_OVER, doOver);
   hotspots.removeEventListener(MouseEvent.MOUSE_OUT, doOut);
   if (animationTimer!=null) {
      animationTimer.stop();
   }
   animationTimer = null;
}
  1. // Tooltips plugin
  2.  
  3. var id:String="Tootips";
  4. var version:String="1.0";
  5. var panoController:Object=null;
  6. var pano:Object=null;
  7. var hotspots:Object;
  8. var waitTimer:Timer;
  9.  
  10. // this function is called on plugin's start
  11. function init (panoMain:Object) {
  12.    panoController = panoMain;
  13.    if (panoMain.addExternal(this)) {
  14.       waitTimer = new Timer(50);
  15.       waitTimer.addEventListener(TimerEvent.TIMER, waitHotspots, false, 0, true);
  16.       waitTimer.start();
  17.    }     
  18. }
  19.  
  20. // this function is called when new panorama is loading
  21. function newPano(link:Object) {
  22.    pano = link;
  23. }
  24.  
  25. // wait for Hotspots plugin to load before starting tooltips
  26. function waitHotspots (event:Event) {
  27.    if (panoController.externals.hotspots!=null) {
  28.       waitTimer.stop();
  29.       waitTimer = null
  30.       hotspots = panoController.externals.hotspots;
  31.       hotspots.addEventListener(MouseEvent.MOUSE_OVER, doOver, false, 0, true);
  32.       hotspots.addEventListener(MouseEvent.MOUSE_OUT, doOut, false, 0, true);
  33.       hotspots.addEventListener(MouseEvent.CLICK, doOut, false, 0, true);
  34.    }
  35. }
  36.  
  37. var animationTimer:Timer;
  38. var speed:Number;
  39. var currentObject:Object;
  40. var alphaMax:Number = 1;
  41. var alphaMin:Number = -1.4;
  42. var alphaPlus:Number = 0.2;
  43. var alphaMinus:Number = -0.08;
  44.  
  45. visible = false;
  46. alpha = alphaMin;
  47. tip.scale9Grid = new Rectangle(5, 5, tip.width-10, tip.height-10);
  48. tip_txt.autoSize = TextFieldAutoSize.LEFT;
  49.  
  50. function doOver (event:Event) {
  51.    // find object with property "attributes" (all hotspots has this object)
  52.    var obj:Object = event.target;
  53.    while (!obj.hasOwnProperty("attributes")) {
  54.       if (obj.hasOwnProperty("parent")) {
  55.          obj = obj.parent;
  56.       } else {
  57.          return;
  58.       }
  59.    }
  60.    // try to get propery alt (stored in XML: <spot url="1.jpg" alt="My Picture" />)
  61.    var text:String = obj.attributes.getParam("alt");
  62.    if (text!=null) {
  63.       currentObject = obj;
  64.       // if text contais \n, it is multilines
  65.       if (text.indexOf("\n")!=-1) {
  66.          text = text.replace(/\n/g, "\n")
  67.       }
  68.       tip_txt.text = text;
  69.       tip.width = tip_txt.width+10;
  70.       tip.height = tip_txt.height+4;
  71.       // start animation
  72.       speed = alphaPlus;
  73.       visible = true;
  74.       if (animationTimer!=null) {
  75.          animationTimer.stop();
  76.       }
  77.       animationTimer = new Timer(30);
  78.       animationTimer.addEventListener(TimerEvent.TIMER, animation, false, 0, true);
  79.       animationTimer.start();
  80.    }
  81. }
  82.  
  83. function doOut (event:Event) {
  84.    speed = alphaMinus;
  85. }
  86.  
  87. function animation (event:Event) {
  88.    if (speed>0) {
  89.       if (alpha < alphaMax) {
  90.          alpha += speed;
  91.       } else {
  92.          alpha = alphaMax;
  93.       }
  94.       x = parent.mouseX-8;
  95.       y = parent.mouseY+20;
  96.       //
  97.       if (x<0) {
  98.          x = 0;
  99.       }
  100.       if (x+width>pano.width) {
  101.          x = pano.width-width;
  102.       }
  103.       if (y+height>pano.height) {
  104.          y = pano.height-height;
  105.       }
  106.       if (!currentObject.visible) {
  107.          speed = alphaMinus;
  108.       }
  109.    } else {
  110.       if (alpha > alphaMin) {
  111.          alpha += speed;
  112.       } else {
  113.          alpha = alphaMin;
  114.          animationTimer.stop();
  115.          animationTimer = null;
  116.       }
  117.    }
  118. }
  119.  
  120. function remove () {
  121.    hotspots.removeEventListener(MouseEvent.MOUSE_OVER, doOver);
  122.    hotspots.removeEventListener(MouseEvent.MOUSE_OUT, doOut);
  123.    if (animationTimer!=null) {
  124.       animationTimer.stop();
  125.    }
  126.    animationTimer = null;
  127. }
Moderator Remark: added code tags. Please use [code=actionscript]{code goes here[/code] when posting actionscript code. Thanks
  • Anonymous
  • Bot
  • No Avatar
  • Registriert: 25 Feb 2008
  • Beiträge: ?
  • Loc: Ozzuland
  • Status: Online

Beitrag Oktober 14th, 2009, 6:50 pm

  • IceCold
  • Guru
  • Guru
  • Benutzeravatar
  • Registriert: Nov 05, 2004
  • Beiträge: 1229
  • Loc: Ro
  • Status: Offline

Beitrag Oktober 15th, 2009, 11:34 pm

Sie können htmlText Eigenschaft für tip_txt;
so setzen
tip_txt.html = true;
(setzen Sie diese nach der Zeile: tip_txt.autoSize = TextFieldAutoSize.LEFT;)
dann, statt
tip_txt.text = text;
Verwendung tip_txt.htmlText = text;
Und in der XML für die kursive Wörter, Ort <i> Wort </ i>
“True mastery transcede any particular art. It stems from mastery of oneself - the ability, developed throgh self-discipline, to be calm, fully aware, and complety in tune with oneself and the surroundings. Then, and only then, can a person know himself. ”

Beitrag Oktober 18th, 2009, 3:10 pm

IceCold hat geschrieben:
Sie können htmlText Eigenschaft für tip_txt;
so setzen
tip_txt.html = true;
(setzen Sie diese nach der Zeile: tip_txt.autoSize = TextFieldAutoSize.LEFT;)
dann, statt
tip_txt.text = text;
Verwendung tip_txt.htmlText = text;
Und in der XML für die kursive Wörter, Ort <i> Wort </ i>



Hallo IceCold,

Vielen Dank für Ihre Antwort. Ich habe den Code in meine Flash-Dokument eingefügt (mit ActionScript 3. 0), aber ich bin immer diese Fehlermeldung:

1119: Access möglicherweise undefinierte Eigenschaft html über einen Verweis mit statischen Typ flash.text: TextField.
Quelle: tip_txt.html = true;

Deshalb Tooltipp nicht mehr funktioniert.

Sorry, ich weiß einfach nicht genug über ActionScript zu können fix!

Ihre Hilfe wieder würden die meisten geschätzt werden.

Enviro.
  • IceCold
  • Guru
  • Guru
  • Benutzeravatar
  • Registriert: Nov 05, 2004
  • Beiträge: 1229
  • Loc: Ro
  • Status: Offline

Beitrag Oktober 19th, 2009, 2:00 am

scheint, dass HTML-Eigenschaft wird nicht mehr in AS3 erforderlich,
entfernen, so dass.
auch überprüfen, Adobe Live-Hilfe: http://livedocs.adobe.com/flash/9.0/Act ... l#htmlText
“True mastery transcede any particular art. It stems from mastery of oneself - the ability, developed throgh self-discipline, to be calm, fully aware, and complety in tune with oneself and the surroundings. Then, and only then, can a person know himself. ”

Beitrag Oktober 19th, 2009, 9:15 pm

Danke!

meine XML-doc weigert zu arbeiten, wenn ich die Tags für Text kursiv...Ill immer wieder versuchen und sehen, ich kann es zum Laufen zu bringen...Nochmals vielen Dank für Ihre Hilfe.

Enviro
  • IceCold
  • Guru
  • Guru
  • Benutzeravatar
  • Registriert: Nov 05, 2004
  • Beiträge: 1229
  • Loc: Ro
  • Status: Offline

Beitrag Oktober 20th, 2009, 12:03 am

CDATA verwenden. Das bedeutet:
<xml..... >
<items>
<item> <! [CDATA mein Text mit Tags, die <i> nicht </ i erlaubt> nach xml ]]> </ item>
</ items>

den fett gedruckten rote Bänder sind die cdata Start-und End-Tag.
“True mastery transcede any particular art. It stems from mastery of oneself - the ability, developed throgh self-discipline, to be calm, fully aware, and complety in tune with oneself and the surroundings. Then, and only then, can a person know himself. ”

Beitrag Oktober 20th, 2009, 3:02 pm

Hallo,

Nochmals vielen Dank!

Ich habe versucht, aber ich denke, die XML-doc funktioniert anders .. hier ist eines der Elemente tooltip Ich habe versucht zu ändern:

<Ort id = "01rock" verbunden = "pano01" url = "/ includes / Wasser / virtual-Touren / images / photo.png" pan = "-1" tilt = "0" depth = "-120" scalable = " 0 "alt =" Mangrove Nerita (Nerita balteata) "
onClick = "01rockInfo. sichtbar + = 1 "/>
<Ort id = "01rockInfo" verbunden = "pano01" url = "images/smithspoint-01/image1.jpg" static = "1" depth = "120" visible = "0"
Glättung = "0" leuchtet = "100" glowCOLOR = " #FFFFFF "glowBlur =" 2 "glowInner =" 1 "shadow =" 1 "shadowDistance =" 3 "shadowAlpha =" 0. 49 "
onClick = "visible = 0" onOver = "" onOut = "" />

Es ist die alt-Tag (die Wörter in Klammern), die möchte ich teilweise kursiv.

Enviro
  • IceCold
  • Guru
  • Guru
  • Benutzeravatar
  • Registriert: Nov 05, 2004
  • Beiträge: 1229
  • Loc: Ro
  • Status: Offline

Beitrag Oktober 21st, 2009, 3:37 am

dann ersetzen Sie einfach die Klammern, wie in diesem Beispiel.
Code: [ Download ] [ Select ]
function stringReplace(block:String, find:String, replace:String):String
{
    return block.split(find).join(replace);
}

var altString:String = "Mangrove Nerita (Nerita balteata)"; // this you'll get from
altString = stringReplace(altString, "(", "(<i>");
altString = stringReplace(altString, ")", "</i>)");
trace(altString);
  1. function stringReplace(block:String, find:String, replace:String):String
  2. {
  3.     return block.split(find).join(replace);
  4. }
  5. var altString:String = "Mangrove Nerita (Nerita balteata)"; // this you'll get from
  6. altString = stringReplace(altString, "(", "(<i>");
  7. altString = stringReplace(altString, ")", "</i>)");
  8. trace(altString);


im Code werden:
Code: [ Download ] [ Select ]
 var text:String = obj.attributes.getParam("alt");
  if (text!=null) {
    currentObject = obj;
    // if text contais \n, it is multilines
    if (text.indexOf("\n")!=-1) {
     text = text.replace(/\n/g, "\n")
    }
    text = stringReplace(text, "(", "(<i>");
    text = stringReplace(text, ")", "</i>)");
    ...
  1.  var text:String = obj.attributes.getParam("alt");
  2.   if (text!=null) {
  3.     currentObject = obj;
  4.     // if text contais \n, it is multilines
  5.     if (text.indexOf("\n")!=-1) {
  6.      text = text.replace(/\n/g, "\n")
  7.     }
  8.     text = stringReplace(text, "(", "(<i>");
  9.     text = stringReplace(text, ")", "</i>)");
  10.     ...
“True mastery transcede any particular art. It stems from mastery of oneself - the ability, developed throgh self-discipline, to be calm, fully aware, and complety in tune with oneself and the surroundings. Then, and only then, can a person know himself. ”

Beitrag Oktober 27th, 2009, 5:26 pm

Thanks again,

Ich muss zugeben, das gibt mir die folgende Fehlermeldung in flash:

1180: Aufruf für eine möglicherweise nicht definierte Methode StringReplace.

sorry, You've Been hilfreichsten aber ich glaube, eine verlorene Sache!

Enviro
  • IceCold
  • Guru
  • Guru
  • Benutzeravatar
  • Registriert: Nov 05, 2004
  • Beiträge: 1229
  • Loc: Ro
  • Status: Offline

Beitrag Oktober 28th, 2009, 5:59 am

Sie vergessen haben, die Funktion StringReplace aus dem ersten Code zu kopieren :)
“True mastery transcede any particular art. It stems from mastery of oneself - the ability, developed throgh self-discipline, to be calm, fully aware, and complety in tune with oneself and the surroundings. Then, and only then, can a person know himself. ”

Beitrag Oktober 28th, 2009, 3:17 pm

Gott .. Im so ein Flash-Amateur -.... Dies funktioniert in der Flash-Datei jetzt...veröffentlicht in Ordnung.

bedeutet das in der XML-doc statt <i> und </ i> Ich habe gerade den Klammern () verwenden? Es ist noch nicht kursiv.

Nochmals vielen Dank!

Enviro

Buchung Informationen

  • Beiträge in diesem Thema: 11 Beiträge
  • Mitglieder in diesem Forum: 0 Mitglieder und 68 Gäste
  • Du darfst keine neuen Themen in diesem Forum erstellen.
  • Du darfst keine Antworten zu Themen in diesem Forum erstellen.
  • Du darfst deine Beiträge in diesem Forum nicht ändern.
  • Du darfst deine Beiträge in diesem Forum nicht löschen.
  • Du darfst keine Dateianhänge in diesem Forum erstellen.
 
 

© Unmelted Enterprises 1998-2009. Angetrieben durch phpBB © 2001-2009 phpBB Group.