Solved

Triangle Information

Posted on 2003-11-13
1
292 Views
Last Modified: 2010-04-03
Continuing from http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_20793393.html

I need to put a mouse over the triangle and somewhere URL should be shown, or some infor about triangle taken from trinagles.xml
0
Comment
Question by:valentin_v
1 Comment
 
LVL 27

Accepted Solution

by:
negatyve earned 500 total points
ID: 9743569
try this:


BOXES.XML
============================================
<?xml version="1.0" encoding="UTF-8"?>
<boxes>
      <item
            thickness="1" rgb="002040" alpha="100"
            mx="140" my="10"
            x1="160" y1="10"
            x2="160" y2="100"
            x3="140" y3="100"
            x4="140" y4="10" />
      <item
            thickness="1" rgb="002040" alpha="100"
            mx="180" my="10"
            x1="260" y1="10"
            x2="260" y2="100"
            x3="180" y3="100"
            x4="180" y4="10" />
</boxes>
============================================


TRIANGLES.XML
============================================
<?xml version="1.0" encoding="UTF-8"?>
<triangles>
      <item
            link="http://www.altavista.com/" target="_blank"
            info="wow!, nice portal"
            thickness="1" rgb="002040" alpha="100"
            mx="100" my="130"
            x1="358" y1="130"
            x2="358" y2="260"
            x3="100" y3="130" />
      <item
            link="http://www.yahoo.com/" target="_self"
            info="yeah, what a good (sic) search engine!"
            thickness="2" rgb="FFCC00" alpha="20"
            mx="400" my="130"
            x1="663" y1="130"
            x2="400" y2="232"
            x3="400" y3="130" />
</triangles>
============================================


FLASH MOVIE
============================================
triangles_xml = new XML();
triangles_xml.path = this;
triangles_xml.ignoreWhite = true;
triangles_xml.onLoad = function(ok)
{
      if (ok) {
            this.triangles = this.firstChild.childNodes;
            this.drawTriangles();
            clearInterval(this.loadID);
            this.loadID = setInterval(this, "updateData", 5000);
      } else {
            trace("XML FILE NOT FOUND");
      }
};
triangles_xml.updateData = function()
{
      for (var i = 0; i < this.triangles.length; i++)this.path["tre" + i].removeMovieClip();
      delete this.triangles;
      this.load("triangles.xml");
};
triangles_xml.drawTriangles = function()
{
      for (var i = 0; i < this.triangles.length; i++) {
            var pen = this.path.createEmptyMovieClip("tre" + i, i);
            var attributes = this.triangles[i].attributes;
            pen.lineStyle(attributes.thickness, parseInt(attributes.rgb, 16), attributes.alpha);
            pen.moveTo(attributes.mx, attributes.my);
            pen.beginFill(parseInt(attributes.rgb, 16), attributes.alpha);
            for (var j = 1; j < 4; j++)pen.lineTo(attributes["x" + j], attributes["y" + j]);
            pen.endFill();
            pen.__target = attributes.target;
            pen.__link = attributes.link;
            // --- ADDED CODE ----------------------
            pen.__info = attributes.info;
            // -------------------------------------
            pen.onRelease = function()
            {
                  this.getURL(this.__link, this.__target);
            };
            // --- ADDED CODE ----------------------
            pen.onRollOver = function()
            {
                  this._parent.info_txt.text = this.__info;
                  this._parent.info_txt._visible = true;
            };
            pen.onRollOut = function()
            {
                  this._parent.info_txt.text = "";
                  this._parent.info_txt._visible = false;
            };
            // -------------------------------------
      }
};
triangles_xml.load("triangles.xml");
boxes_xml = new XML();
boxes_xml.path = this;
boxes_xml.ignoreWhite = true;
boxes_xml.onLoad = function(ok)
{
      if (ok) {
            this.boxes = this.firstChild.childNodes;
            this.drawBoxes();
            clearInterval(this.loadID);
            this.loadID = setInterval(this, "updateData", 5000);
      } else {
            trace("XML FILE NOT FOUND");
      }
};
boxes_xml.updateData = function()
{
      for (var i = 0; i < this.boxes.length; i++)this.path["box" + i].removeMovieClip();
      delete this.boxes;
      this.load("boxes.xml");
};
boxes_xml.drawBoxes = function()
{
      for (var i = 0; i < this.boxes.length; i++) {
            var pen = this.path.createEmptyMovieClip("box" + i, i + 1000);
            var attributes = this.boxes[i].attributes;
            pen.lineStyle(attributes.thickness, parseInt(attributes.rgb, 16), attributes.alpha);
            pen.moveTo(attributes.mx, attributes.my);
            for (var j = 1; j < 5; j++)pen.lineTo(attributes["x" + j], attributes["y" + j]);
      }
};
boxes_xml.load("boxes.xml");

// --- ADDED CODE ----------------------
function createsMyText()
{
      this.createTextField("info_txt", 10000, 0, 0, 200, 1)
      this.info_txt.border = this.info_txt.background = true;
      this.info_txt.autoSize = true;
      this.info_txt._visible = false;
}
createsMyText()
// -------------------------------------
============================================
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now