Flash style du texte tooltip question

  • environmentflash
  • Newbie
  • Newbie
  • No Avatar
  • Inscription: Oct 14, 2009
  • Messages: 7
  • Status: Offline

Message Octobre 14th, 2009, 6:50 pm

Salut,

J'ai hérité d'une visite virtuelle Flash à partir d'un collègue précédente et ont atteint un hic. La pointe de l'outil que j'utilise s'appuie sur la touche "alt" tag de mon document xml. J'ai besoin de faire varier les noms scientifiques en italique, mais n'arrive pas à faire juste quelques mots en italique.

Dans le document XML je peux préciser le ALTFONT et faire l'italique ligne entière...mais vraiment besoin de préciser que quelques mots dans la phrase.

Je pensais peut-être que je besoin d'ajouter quelque chose à l'actionscript Flash et spécifier un attribut «nouveau»? Je suis un concepteur et non pas un développeur espère bien il ya quelqu'un là-bas qui pourrait me point dans la bonne direction?

Ci-dessous est le code ActionScript...

Merci heaps!

ACTIONSCRIPT Code: [ 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
  • Inscription: 25 Feb 2008
  • Messages: ?
  • Loc: Ozzuland
  • Status: Online

Message Octobre 14th, 2009, 6:50 pm

  • IceCold
  • Guru
  • Guru
  • Avatar de l’utilisateur
  • Inscription: Nov 05, 2004
  • Messages: 1254
  • Loc: Ro
  • Status: Offline

Message Octobre 15th, 2009, 11:34 pm

vous pouvez utiliser la propriété htmlText pour tip_txt;
si, ensemble
tip_txt.html = true;
(Réglez cette après la ligne: tip_txt.autoSize = TextFieldAutoSize.LEFT;)
puis, au lieu de
= tip_txt.text texte;
tip_txt.htmlText utilisation = text;
Et dans le langage XML, pour les mots en italique, lieu <i> word </ 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. ”
  • environmentflash
  • Newbie
  • Newbie
  • No Avatar
  • Inscription: Oct 14, 2009
  • Messages: 7
  • Status: Offline

Message Octobre 18th, 2009, 3:10 pm

IceCold a écrit:
vous pouvez utiliser la propriété htmlText pour tip_txt;
si, ensemble
tip_txt.html = true;
(Réglez cette après la ligne: tip_txt.autoSize = TextFieldAutoSize.LEFT;)
puis, au lieu de
= tip_txt.text texte;
tip_txt.htmlText utilisation = text;
Et dans le langage XML, pour les mots en italique, lieu <i> word </ i>



Salut IceCold,

Merci de votre réponse. J'ai inséré le code dans mon doc Flash (à l'aide d'ActionScript 3. 0) mais je reçois cette erreur:

1119: Accès des éventuellement html propriété non définie par une référence à flash.text type statique: TextField.
Source: tip_txt.html = true;

Par conséquent, l'encadré d'aide ne fonctionne plus.

Désolé, je ne sais pas assez sur ActionScript pour être en mesure de résoudre le problème!

Votre aide nous serait encore plus apprécié.

Enviro.
  • IceCold
  • Guru
  • Guru
  • Avatar de l’utilisateur
  • Inscription: Nov 05, 2004
  • Messages: 1254
  • Loc: Ro
  • Status: Offline

Message Octobre 19th, 2009, 2:00 am

semble que la propriété html ne sont plus nécessaires en AS3,
donc enlever cela.
Vérifiez également aider à vivre d'Adobe: 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. ”
  • environmentflash
  • Newbie
  • Newbie
  • No Avatar
  • Inscription: Oct 14, 2009
  • Messages: 7
  • Status: Offline

Message Octobre 19th, 2009, 9:15 pm

merci!

mon doc xml refuse de travailler quand je insérer les balises pour l'italique...Ill continuer à essayer et voir ce moi peut-il se rendre au travail...merci encore pour votre aide.

Enviro
  • IceCold
  • Guru
  • Guru
  • Avatar de l’utilisateur
  • Inscription: Nov 05, 2004
  • Messages: 1254
  • Loc: Ro
  • Status: Offline

Message Octobre 20th, 2009, 12:03 am

utilisation CDATA. à savoir:
<XML..... >
<items>
<item> <! [CDATA mon texte avec les balises qui sont <i> pas autorisées </ i> par XML ]]> </ item>
</ items>

les chaînes de caractères gras rouges sont le début CDATA et balise de fin.
“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. ”
  • environmentflash
  • Newbie
  • Newbie
  • No Avatar
  • Inscription: Oct 14, 2009
  • Messages: 7
  • Status: Offline

Message Octobre 20th, 2009, 3:02 pm

Salut,

Merci encore!

J'ai essayé, mais je pense que le doc xml fonctionne différemment .. voici l'un des éléments tooltip j'ai essayé de changer:

<id = Tache "01rock» liée = "pano01" url = "/ includes / eau / Visites virtuelles / images / photo.png" pan = "-1" tilt = "0" profondeur = "-120" scalable = " 0 "alt =" Mangrove Nerita (balteata Nerita) "
onClick = "01rockInfo. visibles + = 1 "/>
<id = Tache "01rockInfo» liée = "pano01" url = "images/smithspoint-01/image1.jpg" statique = "1" profondeur = "120" visible = "0"
lissage = "0" glow = "100" glowColor = " #FFFFFF "glowBlur =" 2 "glowInner =" 1 "shadow =" 1 "shadowDistance =" 3 "shadowAlpha =" 0. 49 "
onClick = "visible = 0" onOver = "" onOut = "" />

Ses la balise alt (les mots entre parenthèses) que je veux en italique partiellement.

Enviro
  • IceCold
  • Guru
  • Guru
  • Avatar de l’utilisateur
  • Inscription: Nov 05, 2004
  • Messages: 1254
  • Loc: Ro
  • Status: Offline

Message Octobre 21st, 2009, 3:37 am

puis il suffit de remplacer les parenthèses, comme dans cet exemple.
Code: [ 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);


dans votre code sera:
Code: [ 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. ”
  • environmentflash
  • Newbie
  • Newbie
  • No Avatar
  • Inscription: Oct 14, 2009
  • Messages: 7
  • Status: Offline

Message Octobre 27th, 2009, 5:26 pm

merci encore,

Je dois admettre cela me donne l'erreur suivante dans flash:

1180: Appel à une StringReplace possibly undefined method.

Désolé, youve été très utiles mais il me semble être une cause perdue!

Enviro
  • IceCold
  • Guru
  • Guru
  • Avatar de l’utilisateur
  • Inscription: Nov 05, 2004
  • Messages: 1254
  • Loc: Ro
  • Status: Offline

Message Octobre 28th, 2009, 5:59 am

vous avez oublié de copier le StringReplace fonction à partir du premier code :)
“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. ”
  • environmentflash
  • Newbie
  • Newbie
  • No Avatar
  • Inscription: Oct 14, 2009
  • Messages: 7
  • Status: Offline

Message Octobre 28th, 2009, 3:17 pm

dieu .. Im un tel flash amateur.... Cela fonctionne dans le fichier Flash maintenant...publie amende.

ce que cela signifie dans la doc XML au lieu de <i> et </ i> je viens d'utiliser les parenthèses ()? Il n'est toujours pas en italique.

Merci encore!

Enviro

Afficher de l'information

  • Total des messages de ce sujet: 11 messages
  • Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 46 invités
  • Vous ne pouvez pas poster de nouveaux sujets
  • Vous ne pouvez pas répondre aux sujets
  • Vous ne pouvez pas éditer vos messages
  • Vous ne pouvez pas supprimer vos messages
  • Vous ne pouvez pas joindre des fichiers
 
 

© 2011 Unmelted, LLC. Ozzu® est une marque déposée de Unmelted, LLC