Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Curve lines

Posted on 2003-12-04
10
Medium Priority
?
488 Views
Last Modified: 2010-04-03
Continuing from http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_20797391.html.

I want the triangle to curve at some point to look like SAIL, so lets say 3 additional curve points need to be impoted to do the job. There could be up to 10 point for a perfect curves of a SAIL.

 
0
Comment
Question by:valentin_v
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 3

Expert Comment

by:rugu_16
ID: 9900717
hi,
Follow these steps:

(1) make a triangle in flash
(2) put your mouse curor on any one line of triangle
(3) you will see small curve line near the mouse pointer
(4) when that curvy line shows up , press your mouse and drag to the direction you wanna curve it

thanking you
0
 
LVL 27

Expert Comment

by:negatyve
ID: 9902688
Could you make a an example picture?
0
 

Author Comment

by:valentin_v
ID: 9903782
Hi, This is what I need them to look like.

http://www.northsailscanada.com/test/sails.swf

Now they look like sails, not triangles.

I think I can acheive the proper curver with only one extra point on each line of triangle. I tried but can't get it to work.

Again, those coordinated need to be takes from triangles.xml , If the curve can be done with only one point on each line then it would be perfect.

Thanks in advance

Valentin
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 27

Accepted Solution

by:
negatyve earned 2000 total points
ID: 9909336
ok, follow me.


BOXES.XML (no changes)
============================================================
<?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 (changes: look at the attributes of the first
node, "sail". If sail is equal to "no", flash movie will draw
triangles, if is equal to "yes", will draw sails. So, if you
want to switch from firsts to seconds, just change that
attribute.
There are a few more attributes in the inner nodes: for each
triangle vertex, there are two anchor points which make sails
drawing possible. If the "sail" attribute of the first node
is set to "no", they are simply ignored)
============================================================
<?xml version="1.0" encoding="UTF-8"?>
<triangles sail="yes">
      <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"
            a1="290" b1="150"
            x2="358" y2="260"
            a2="370" b2="200"
            x3="100" y3="130"
            a3="290" b3="220" />
      <item
            link="http://www.yahoo.com/" target="_self"
            info="yeah, what a good (sic) search engine!"
            thickness="2" rgb="FFCC00" alpha="100"
            mx="400" my="130"
            x1="663" y1="130"
            a1="400" b1="150"
            x2="400" y2="232"
            a2="400" b2="200"
            x3="400" y3="130"
            a3="370" b3="150" />
</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;
            // --- ADDED CODE -----------------------------
            this.drawTriangles(this.firstChild.attributes.sail);
            // --------------------------------------------
            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;
      // --- ADDED CODE -----------------------------
      // --- use online to avoid caching ------------
      // this.load("triangles.xml?update=" + (new Date().getTime()));
      this.load("triangles.xml");
      // --------------------------------------------
};
triangles_xml.drawTriangles = function(sail)
{
      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++) {
                  // --- MODIFIED CODE -------------------------
                  if(sail == "yes"){
                        pen.curveTo(attributes["a" + j], attributes["b" + j], attributes["x" + j], attributes["y" + j]);
                  } else {
                        pen.lineTo(attributes["x" + j], attributes["y" + j]);
                  }
                  // -------------------------------------------
            }
            pen.endFill();
            pen.__target = attributes.target;
            pen.__link = attributes.link;
            pen.__info = attributes.info;
            pen.onRelease = function()
            {
                  this.getURL(this.__link, this.__target);
            };
            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;
      // --- ADDED CODE -----------------------------
      // --- use online to avoid caching ------------
      // this.load("boxes.xml?update=" + (new Date().getTime()));
      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");
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
 

Author Comment

by:valentin_v
ID: 9919901
negatyve .......YOU THE BEST

What if I want extra points for curves lets say 1 more point on each line

Thanks in advance
0
 

Author Comment

by:valentin_v
ID: 9920837
Just a small question if you need points I'll give you

Sometimes I;ll load 30 sails at once, and I need to be able to scroll horizontally through movie to see all 30 in a line. Like this I can see maybe 10 ro 12 but no more.

How Can I do that

Thanks
0
 
LVL 27

Expert Comment

by:negatyve
ID: 9933903
hey, I've been off for some day, as soon as I can I'll make you an example with the scrollpane, to scroll all sails.. :)
0
 
LVL 27

Expert Comment

by:negatyve
ID: 9937613
0
 

Author Comment

by:valentin_v
ID: 9964690
The problem that I encounter with the Scrolling is the INFO that gets displayed at the point 0,0 .

If I change the to another value, scrolls will not work.
0
 
LVL 27

Expert Comment

by:negatyve
ID: 10003017
try to change the script this way:

.....
pen.onRollOver = function()
{
      this._parent.info_txt._x = this._parent._parent.getScrollPosition().x
      this._parent.info_txt.text = this.__info;
      this._parent.info_txt._visible = true;
};
.....
and use the "createsMyText" function as it is
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses

604 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