Plotting An External Jpg
Hi
I am just starting out with actionscript and i am stuck, i want to plot an external jpg/gif image into a .swf using code but i cant find the code for it
Can anyone tell me the Script to show and external jpg/gif at a specific location on the page, and can this then be used within an if statement i.e. If a condition is true - plot the picture else - dont plot the picture
Any help would be greatly appreciated
ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 10-30-2006, 01:43 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Plotting Help
need to plot dates on a timeline. stumped.
Code:
event_month = xml.childNodes[i].attributes.month;
event_year = xml.childNodes[i].attributes.year;
timeline_firstyear = 1880;
decades = 12;
// where the events are plotted.
timeline_mc._width = 4500;
ok, so loop through xml.childNodes[i].length, get names, months, and years of events. Then what? I know that the total width is 120 years (or 1440 months).
Code:
var decade_width = timeline_mc._width/decades;
// somehow get _x
attachedMC._x = even_year/...??
Plotting
Has anyone seen any examples of longitude and latitude being used in Flash? I have an idea but I have to get past this part or understand how it has been done. Thanks so much.
GSM Map Plotting
Hi All
I'm building a map application, and wondered if anyone has had any experience of map plotting systems in flash (mx or mx2004) I only really need to go as far as city level, not down to street level.
I was hoping to link flash to a database which contains x position & y position of city, then render the city location in flash.
If anyone could point me in the right direction would be much appreciated.
Dan
Plotting A Graph
Im starting to wonder if this can be done or not, I have posted on several sites and have not gotten any replys so this will be the last try. What I am trying to do is make a flash interfase that will have a range lets say from the bottam left of 0 to the top say 100, now what I want to do is be able to have flash get the information from my data base on stocks and take lets say x=9 and y=2 then draw me a simple line on the chart showing the percent of growth of that stock. any ideas if this can even be done or perhaps if the Gods are smileing on me a tutorial that may be out there some were I have not looked that might lead me in the right direction. thanks in advance.
Plotting A Line . . .
I have several movieclips which I wish to plot several lines between using actionScript!
Any ideas????
Cheers,
Stu
Plotting In Flash
this is my first post and it's probably a really easy/embarassing question.
How can I "draw" something in Flash using actionscript? By that I mean put in an equation in actionScript and have it plot the result of it.
Plotting In Flash
I'm kinda new to Flash so this is probably a really easy/embarassing question.
How can I "draw" something in Flash using actionscript? By that I mean put in an equation in actionScript and have it plot the result of it.
Point Plotting
i work for a consulting firm, and one of the things we do is make people take silly tests about themselves, the data spits out 4 numbers that must be graphed, this is what a sample graph would look like.
http://www.tamcoinc.com/flashkitrules/
how can i make a flash file that would allow someone to enter their 4 numbers (ranging from 1-100) and it move the points on the graph?
any help would be greatly appreciated.
(i know nothing about action scripting)
Plotting A Graph , Help
i need to plot a graph and have no idea how to even kick start. These is what how dynamic the graph is:
Basically is letting user trace the point(the correct X and Y coordination) on the graph and allow them to plot the graph. For example, when the user click on the correct coordination, a dot will appear and when the user click on the 2nd coordination, a line will appear to connect the first point to the 2nd one and etc. The last fucntion of this graph is to have a clear button that allow the user to clear the last plot attempt and so forth so that the user can continue to plot the graph.
Any idea where can i get the necessary information and possible someone can offer me some advice ?
Graph Plotting Ax^2+bx+c
I am trying to plot a graph of ax^2+bx+c via actionscript can anybody help me in this i am looking for a complete tutorials as i am very new to it
Plotting A Graph
i need to plot a graph and have no idea how to even kick start. These is what how dynamic the graph is:
Basically is letting user trace the point(the correct X and Y coordination) on the graph and allow them to plot the graph. For example, when the user click on the correct coordination, a dot will appear and when the user click on the 2nd coordination, a line will appear to connect the first point to the 2nd one and etc. The last fucntion of this graph is to have a clear button that allow the user to clear the last plot attempt and so forth so that the user can continue to plot the graph.
Any idea where can i get the necessary information and possible someone can offer me some advice ?
HELP On Graph Plotting
Can anyone help me out with this? I attached the source file. It's a graph plotting when user can enter values for a quadratic /cubic equation and it'll plot the graph.
However, my problem is i wish to set the range when the graph will shown. That means if i enter -5 to 5, the graph will plots from that range. (i named it ak and bk) When i enter let's say -5 to -1 and it will only show that range.
Another question, how do i set so the graph will fit dynamically into the screen exactly.
Thanx in advance!
Plotting A Graph , Help
i need to plot a graph and have no idea how to even kick start. These is what how dynamic the graph is:
Basically is letting user trace the point(the correct X and Y coordination) on the graph and allow them to plot the graph. For example, when the user click on the correct coordination, a dot will appear and when the user click on the 2nd coordination, a line will appear to connect the first point to the 2nd one and etc. The last fucntion of this graph is to have a clear button that allow the user to clear the last plot attempt and so forth so that the user can continue to plot the graph.
Any idea where can i get the necessary information and possible someone can offer me some advice ?
HELP On Graph Plotting
Can anyone help me out with this? I attached the source file. It's a graph plotting when user can enter values for a quadratic /cubic equation and it'll plot the graph.
However, my problem is i wish to set the range when the graph will shown. That means if i enter -5 to 5, the graph will plots from that range. (i named it ak and bk) When i enter let's say -5 to -1 and it will only show that range.
Another question, how do i set so the graph will fit dynamically into the screen exactly.
Thanx in advance!
Plotting Data Points
I am attempting to create a "graphing calculator" of sorts. I have a list of about 200 data points (x, y coordinates) that I need to plot on a graph. What is the most effective way of doing this so that the objects remain dynamic? The numbers will have to be changed & updated. Can I have two arrays (one for x-values and one for y-values) and then have an action that will plot each dot accordingly? Is there a way to duplicate each dot (as a movie clip) in the correct placement or will I have to set all objects on the stage and then go from there?
Thanks in advance for your advice!
Mercator Map Latitude Plotting
hey dudes!
I am working on plotting Long and Lat coordinates on a Mercator map at the moment, but I cant seem to get the latitude plotting right... I have looked all over the web at Wikis and University websites but I cant seem to get a concise answer as to how the Mercator plotting actually works. I found lots of sites saying that the Mercator way is actually not accurate...
I have come to a point where I am going to have to use some kind of inaccurate lookup table coz I aint making any progress...
Would anyone mind explaining in a little detail how the latitude gets translated onto the map? I managed fine to convert the degrees, minutes and seconds to Lat and Long, and I obviously managed to plot the longitude.. that part is easy. I have even referenced some flight school manuals, to no avail. Oh, and any equations would be helpful too!
I can share what I have on request. Bit strapped for time
Trouble Plotting The Mandelbrot Set
I'm trying to create a simple flash that will draw the Mandelbrot set by looping through coordinates, sending those coordinates through iterations of the Mandelbrot function and drawing a line at those coordinates, who's color is dependent upon the amount of iterations taken.
Here is that code:
ActionScript Code:
var dot:Sprite = new Sprite()
this.addChild(dot)
for (var X:int = 0; X <= 500; X++) { //Iteration for horizontal
for (var Y:int = 0; Y <= 500; Y++) {//Iteration for vertical
var compnum:Array = new Array(X-250, Y-250); //How I created a pseudo-complex number.
//The subtraction is to offset the plot by so the center is 0
var I:int = 0
while (compnum[0] * compnum[0] + compnum[1] * compnum[1] < 25000 && I < 200) {//As long as the absolute value of the complex number
//is less than the arbitrary number I chose, keep trying.
//If it takes more than 200 times, give up and move on
I++
compnum = new Array((compnum[0] * compnum[0] - compnum[1] * compnum[1]) + compnum[0], 2 * compnum[0] * compnum[1] + compnum[1]);
//this is the actual mandelbrot function part, I don't believe this could cause any problems beyond taking a while to compute
}
dot.graphics.lineStyle(1, 0xFFFF00+(I<<16)) //Theoretically, the more iterations, the bluer the line
dot.graphics.moveTo(X, Y);
dot.graphics.lineTo(X, Y+1);
}
}
All has worked as expected so far. Unfortunately, since the interesting stuff occurs near 1, the actual coordinates, which are integers, don't work. With this in mind I made the below code in which I changed the range from the original -250 to 250 to a much smaller -2 to 2 (essentially zooming in) and made the necessary adjustments. At least I think I made all necessary adjustments, because, while the original code took some time to load, the new code exceeds the script time limit. I'm not sure if I did something wrong or if the adjustments just take that much longer, but I would be grateful if you would take look at it:
ActionScript Code:
var dot:Sprite = new Sprite()
this.addChild(dot)
for (var X:int = 0; X <= 4; X+=0.008) {//now the plot will be 4 units big and the step is much smaller(1/500th of 4)
for (var Y:int = 0; Y <= 4; Y+=0.008) {//same here
var compnum:Array = new Array(X-2, Y-2);
var I:int = 0
while (compnum[0] * compnum[0] + compnum[1] * compnum[1] < 4 && I < 200) {
I++
compnum = new Array((compnum[0] * compnum[0] - compnum[1] * compnum[1]) + compnum[0], 2 * compnum[0] * compnum[1] + compnum[1]);
}
dot.graphics.lineStyle(1, 0xFFFF00+(I<<16))
dot.graphics.moveTo(X*125, Y*125); //here the numbers based on the 4 range are converted back to bigger numbers
dot.graphics.lineTo(X*125, Y*125+1); // 500/4=125
}
}
Also if anyone knows how to force the display to update (like updateAfterEvent) in FlashDevelop that would also be useful.
Plotting A Golf Ball In 3d
My next game is supposed to be a golf game that takes into account weather conditions, (wind, rain, etc).
I'm planning on it being 3rd person, so I'll need to show the golf ball trajectory from behind the golfer.
Anybody got any ideas where I can go to learn/read up on this kind of math?
Plotting Maps Dynamically?
I've checked out some of the previous posts on this topic in the Google version of the forums. But, I don't think they address my specific questions. So, I appreciate any additional insight you can provide.
I want to create a map that reads in marker coordinates from an XML file. I've got the XML import covered and I believe I can address almost every function of the map. But, I'm not sure how to handle plotting the markers (locations where the user will click to get detailed info) on the map. A couple of questions:
1. Do I plot manually, or is there some sort of mapping software/component/database out there that I can purchase a subscription too, that will help with plotting? If something exists, will it work through a firewall?
2. Either way, how do I retain plot markers if I allow the user to zoom in on the map?
3. If nothing exists to help plot map markers, how do you go about (in laymens terms 1st please - step-by-step - no code just yet) plotting dynamically - manually? You know - building your own dynamic marker plotting?
Thanks for any help. I'm just getting started with this so am looking for high-level info right now. I don't need to dive into the code just yet.
Plotting 3D Cordinates In Flash
Hi
Can any one tell me is it possible to plott x,y,z co.orinates in flash screen.I know 3D is not supported by flash,but still any short cuts available.
Infact Kiruba tutorial deals with rotating objects in 3 dimension but I need to plot 3 coordinates and draw a curve.
thankX in Advance
Plotting Coordinates Onto Globe
what will i have to do to the code below to see it working, also could someone comment the plotcircle function and emptycircle part to explain whats going on, thanks
code:--------------------------------------------------------------------------------
GraphPole = newArray(latitude,longitude);
GraphPole = [
[61.67,-71.75],
[61.67,-70.93],
[61.69,-70.28 ] ,
[61.69,-69.63]];
GraphEquat = newArray(latitude,longitude);
GraphEquat = [
[52.81,-71.57],
[52.82,-70.83],
[52.84,-70.0 8 ] ] ;
function degreesToRadians(a) {
return a*Math.PI/180.0;
}
function polarToCartesian(radius,lat,long) {
return {x:radius* Math.cos(lat)*Math.cos(long),y:radius*Math.cos(lat itude)*Math.sin(longitude) };
}
function plotCircle(radius,origin,a) {
for (var i=0;i<a.length;i++) {
var polar = a[ i ];
var cart =polarToCartesian(radius,degreesToRadians(polar[0]
),degreesToRadians(polar[1]));
cart.x += origin.x;
cart.y += origin.y;
if (i==0) {
moveTo(cart.x,cart.y);
saveFirst = cart;
} else {
lineTo(cart.x,cart.y);
}
}
moveTo(saveFirst.x,saveFirst.y); // close the circle
}
this.emptyMovieClip();
plotCircle(200,{x:200,y:200},GraphPole);
plotCircle(200,{x:200,y:200},GraphEquat);
Plotting Mc Inside Of A Circle
What I'm trying to do is attach a bunch of movieclips onto my game table in a grid like pattern. But the game table is a circle. So I want to cut out all of the coordinates that are not inside the circle. I could sit there and map out all of these possible coordinates my self, but I'd rather have my actionscript do it dynamically. Anyone have a good idea on how to do this?
Plotting 3D Cordinates In Flash
Hi
Can any one tell me is it possible to plott x,y,z co.orinates in flash screen.I know 3D is not supported by flash,but still any short cuts available.
Infact Kiruba tutorial deals with rotating objects in 3 dimension but I need to plot 3 coordinates and draw a curve.
thankX in Advance
Help Needed Plotting A Curve...
I'm trying to depict the swing of a baseball in top-view on the screen, the ball is travelling from a fixed point at the bootom of the screen, towards the top. I need to be able to select the co-ords where the ball travels to. I've figured out all tht, wht I need help with is, plotting points on a curve, so I can change the x,y co-ords of my mcBall so it seems as if the ball is swinging due to wind. i'd be grateful if someone could point me to a curve drawing algo or something...
here's wht I need:
1] ability to select the end co-ords of the ball, the start is constant and at the bottom-center of the screen.
2] ability to specify the amt of swing, which I shall vary depending on wind conditions in my game.
I can get the required curve using curveTo, but since I can extract the co-ords of the curve, I can change the x,y of the mcBall. I need an algo which will gimme exact co-ords...
regards,
voidzero
Course Plotting Around Oddly Shaped Objects
In flash MX, I'm creating a military base-type game.
However, I just noted a problem and need an awnser before I can continue.
My units travel in a staright line between point A and point B.
There movement is rotation based. And the units travel towards a duplicated movieclip (waypoint), that will remove itself 8 seconds after the next waypoint is created.
The problem is, when there is an obstacle in the way, I need it to plot the shortest couse around the object, automatically.
A perfect example is in pretty much every base-building game out there. If theres a rock in the way, they go around it.
Below is the FLA, the current controls:
Shift: used to select additional units, or deselect single units.
CTRL: used as a right-click. Hold it down when clicking. Creates waypoints.
Dynamic Graph Plotting Challenge
Hi,
I am stuck with this project I got ... well let me first explain what I've done so far. First version of the project involved using a given array of eg 36 answered qustions where each answer can be from 1-5 (but points 4 & 5 are plotted on the same line so it's like there are 4) ...at the moment the graph is a static image of the circles one inside the other with common origin but different radiuses all together divided into 36 sectors (each sector belongs to a one question) reffer to the graph attached. so for example question one starts of on the radius 1 sector 1 which is 0 degrees of the circle. If answer is 1 dot is plotted in the origin if answer 2 dot is plotted on the intersection of the smallest circle and the radius line ... etc answer 4-5 plottted on the most outer intersection of biggest circle . So I've done that because I had the set number of questions and preset graphs looks (which is just a background jpg image) so I just manually placed the dots and activated each one depending on the array values ... and then used those coordinates to fill the shape ...so just the green area (filled area over the graph) is dynamic.
Now the problem is in new version I wont know how many questions there are going to be in other words it varies from 26 to 46 can be anything and the whole graph needs to be dynamically drawn so now I need to mathematically draw it and calculate the dots... so I'll pass to flash number of question and answer for each question (1-5 or one of the 4 dots per sector) it needs then to calculate how to draw graph and how many sectors to draw and then calculate the dots and plot the graph by connecting dots and filling the area.
Any ideas my maths is not that good
cheers
Plotting A Clips On The Stage, Based Off An XML
Hi All,
I'm having a problem plotting a clip with AS2 onto the stage based off an XML. I think its looping thought the xml fine but for some reason its not plotting all the clips on the time line...
So what I'm trying to do is plot a clip on a line based off its <note_position> and <note_height> which it does just fine. But its not plotting all the <note> nodes... it plots 2 <note> clips from <line tName="Name-1" color="0x336633"> then it plots 1 <note>clips from <line tName="Name-2" color="0x333366"> then it plots 2 <note>clips from <line tName="Name-3" color="0x663366">
what it should do is plot all the <note>clips from <line tName="Name-1" color="0x336633"> then plot all the of the <note>clips from <line tName="Name-2" color="0x333366"> and last but not least plot all the of the <note>clips from <line tName="Name-3" color="0x663366">...
So all in all what it is doing is plotting 5 <note>clips in total in stead of the 10 <note> clips it should be plotting on the stage...
OK well I think I'm going to loos my mind... I no longer think its the looping thought the XML that is the problem. I think its either the way I'm attaching the plot clip or something I can't see thought the fog...
I have broken out my code into separate functions
My XML
Code:
<?xml version="1.0" encoding="iso-8859-1" ?>
<entry>
<line tName="Name-1" color="0x336633">
<note>
<note_date>04/25/2002</note_date>
<note_headLine><![CDATA[Test Head Copy]]></note_headLine>
<note_copy><![CDATA[test copy 1]]></note_copy>
<note_position>10</note_position>
<note_height>580</note_height>
</note>
<note>
<note_date>04/29/2002</note_date>
<note_headLine><![CDATA[Test Head Copy]]></note_headLine>
<note_copy><![CDATA[test copy 1]]></note_copy>
<note_position>20</note_position>
<note_height>470</note_height>
</note>
<note>
<note_date>05/02/2002</note_date>
<note_headLine><![CDATA[Test Head Copy]]></note_headLine>
<note_copy><![CDATA[test copy 1]]></note_copy>
<note_position>40</note_position>
<note_height>360</note_height>
</note>
<note>
<note_date>05/02/2002 & 05/28/2002</note_date>
<note_headLine><![CDATA[Test Head Copy]]></note_headLine>
<note_copy><![CDATA[test copy 1]]></note_copy>
<note_position>60</note_position>
<note_height>250</note_height>
</note>
<note>
<note_date>05/02/2002 NOT 05/28/2002</note_date>
<note_headLine><![CDATA[Test Head Copy]]></note_headLine>
<note_copy><![CDATA[test copy 1]]></note_copy>
<note_position>80</note_position>
<note_height>140</note_height>
</note>
</line>
<line tName="Name-2" color="0x333366">
<note>
<note_date>2-1</note_date>
<note_headLine><![CDATA[head 2-1]]></note_headLine>
<note_copy><![CDATA[test copy 2]]></note_copy>
<note_position>200</note_position>
<note_height>580</note_height>
</note>
<note>
<note_date>2-2</note_date>
<note_headLine><![CDATA[head 2-2]]></note_headLine>
<note_copy><![CDATA[test copy 2]]></note_copy>
<note_position>220</note_position>
<note_height>470</note_height>
</note>
<note>
<note_date>2-3</note_date>
<note_headLine><![CDATA[head 2-3]]></note_headLine>
<note_copy><![CDATA[test copy 2]]></note_copy>
<note_position>240</note_position>
<note_height>360</note_height>
</note>
</line>
<line tName="Name-3" color="0x663366">
<note>
<note_date>3-1</note_date>
<note_headLine><![CDATA[head 3-1]]></note_headLine>
<note_copy><![CDATA[test copy 3]]></note_copy>
<note_position>325</note_position>
<note_height>570</note_height>
</note>
<note>
<note_date>3-2</note_date>
<note_headLine><![CDATA[head 3-2]]></note_headLine>
<note_copy><![CDATA[test copy 3]]></note_copy>
<note_position>350</note_position>
<note_height>460</note_height>
</note>
</line>
</entry>
This loads my XML and then sends my data to the processXML () function;
code:
/***** LOAD XML****/
var timeLineXMLConn:XML = new XML ();this.timeLineXMLConn.ignoreWhite = true;
this.timeLineXMLConn.load ("02.xml");
this.timeLineXMLConn.trigger ();
trace ("this is = " + this);
this.timeLineXMLConn.onLoad = function (success:Boolean):Void {
if (success) {
this.timelineXML.onload = processXML ();
} else {
trace ("error loading XML file");
}
};
/***** LOAD XML****/
The processXML function then loops thought the first part of my XML
i.e. <line tName="Name-1" color="0x336633"> </line>
then it calls processXMLchild function
code:
/************* Process XML *****************/
function processXML () {
trace ("processXML = " + "Called");
// the y value of our entries,
// ie how far above the line they are
root_element = timeLineXMLConn.firstChild;
// loop through the XML
for (h = 0; h < root_element.childNodes.length; h++) {
trace ("--------- h = " + h + " -------- ");
element = root_element.childNodes[h];
trace ("element.childNodes.length = " + element.childNodes.length);
processXMLchild ();
}
}
The processXMLchild function then loops thought the secondpart of my XML
i.e. <note> </note> in side the note node <note_date> </note_date>, <note_headLine> </note_headLine>, <note_copy></note_copy>, <note_position> </note_position>, <note_height></note_height>
( by the way I think this only counts the first set of <note> nodes and I want it to count all the <note> nodes) the resone I think this, when I add more <note> nodes to the first set it plots that many clips to the stage. seams strange to me... any how moving on
processXMLchild function then it calls attachXMLNodes function
code:
function processXMLchild () {
// pulling out the data as we go
for (i = 0; i < element.childNodes.length; i++) {
trace (" - - ");
trace ("i = " + i);
trace ("element.childNodes["+i+"].nodeName = " + element.childNodes[i].nodeName);
//lets grab our data
entry_date = element.childNodes[i].firstChild.firstChild.nodeValue;
entry_pos = element.childNodes[i].firstChild.nextSibling.nextSibling.nextSibling.fi rstChild.nodeValue;
entry_ypos = element.childNodes[i].firstChild.nextSibling.nextSibling.nextSibling.ne xtSibling.firstChild.nodeValue;
trace ("entry_pos = " + entry_pos);
// Attach the clip and insert my data
attachXMLNodes ();
}
}
the attachXMLNodes function then attaches the clip plot to the stage and then assigns the XML data to each plot[i] clip i.e. _x, _y...
code:
function attachXMLNodes () {
// Attach the clip and insert my data
depth = i;
attachMovie ("plot", "plot" + i, depth);
// assign the values...
// Set the position
eval ("plot" + i)._y = Number (entry_ypos);
eval ("plot" + i)._x = Number (entry_pos)- 200;
}
so somewhere between processXMLchild function and the attachXMLNodes function its loseing the number of clips it should be placing on the stage.... But the question is why?
Any ideas? Ive been battaling this for the last two day and I'm at a total loss... so any help would be greatly apprecated...
Thank in advance
Scott
Plotting Points Along A Bezier Curve
Hi, I am creating a series of compositional generators. This one is based off of a series of bezier curves drawn from the same "cluster point". The objects are to be placed based on coordinates of these curves. So, when I draw a curve I can easily grab the starting anchor, ending anchor, and the control point's coordinates, but I need to be able to grab x & y coordinates along the path of the line. Anyone know a way of doing this?
Code:
function drawBezier() {
//num_plots is the number of bezier Curves to draw
//cluster_pointX is the x coordinate all beziers start at
//cluster_pointY is the y coordinate all beziers start at
num_plots = random(_parent.num_objects.objectsToCreate.text) + 3;
cluster_pointX = random((Stage.width-100) + 50);
cluster_pointY = random((Stage.width-100) + 50);
trace("Number of Bezier Plots: " + num_plots);
//loop through, create a new movie clips until reaching num_plots
for(var b=0;b<num_plots;b++) {
this.createEmptyMovieClip("bez" + b, b);
obj = this["bez" + b];
obj.lineStyle(1, 0x000000, 100);
obj.moveTo(cluster_pointX, cluster_pointY);
//ControlX: control point must be within 200 pixels of either side
//ControlY: control point must be within 200 pixels of either side
//AnchorX: anywhere on stage
//AnchorY: anywhere on stage
obj.curveTo(random(400)-200,random(400)-200,random(Stage.width),random(Stage.height));
}
};
(An example of the types of generators I'm working on is at haptic-data.com)
Plotting Curve Lines Over Sphere?
Any Geodata visualization experts out here? How do you accurately plot curved lines over a sphere?
I'm working on an open-source 3D Flash mapping application. You can see and download all the source code here (including the LAT/LONG KML XML data): http://code.google.com/p/meadanglobe
[see Line.as]
This is related to another post on latitude/longitude conversions here: http://www.actionscript.org/forums/s...957#post722957
The application will currently plot nodes over the surface of a 3D sphere (globe) by converting latitude and longitude to x, y, x cartesian coordinates. There is also a function that will plot lines between any of these nodes. However, the lines are linear (straight) and are therefore not represented accurately as if traversing over the curved surface of a globe. How to do this?
we are currently using this, which draws a straight line:
lineTo(endNode.x, endNode.y);
I imagine we will want to use something like bezier to get curved lines:
curveTo(anchor1, anchor2, endNode.x, endNode.y);
but how to calculate for the anchors?
This appears to be a complex one, but I sense achievable. Any help will be much appreciated.
Plotting Points On A Perpendicular Plane
hey guys,
i'm a total math idiot and could use some help (probably a simple thing!)
basically, i need to plot some points on a perpendicular plane. i know point A, and point B, but need some points perp. to point B. The A and B points are placed randomly so could be anywhere on the stage...positive/negative from each other etc...Here's an image to illustrate:
(i just need to know their x,y coords) any help is much appreciated!
Plotting Points On A Circle, Like A Radar.
Plotting points on a circle, like a radar.
I’ve been working with this one code for a while now that plots points in a circle where the center of the circle is today’s date and the out edge is 2 or 3 years out. The code places each point the correct distance from center randomly around the center point. It’s been working great, but now my boss wants to see the circle split into 4 quadrants. Now the points need to be within one of the quads dependant on two variables (area & port). I think the easiest way to explain it is that the circle is cut up like –
Top half = application
Bottom half = infrastructure
Left half = global wide
Right half = area wide
The math is really too far over my head at this point, so I’m hoping someone has the knowledge to help out with this.
If you put the code on the first frame and add a circle MC to the stage, call it myCircle, and have a point in your library with the id myPoint you can run this to see it work
Code:
Attach Code
circle = myCircle;
pointer = 'myPoint';
years = 2;
dates = [new Date(2008, 1, 1), new Date(2008, 1, 1), new Date(2008, 1, 1), new Date(2008, 2, 26), new Date(2008, 1, 1), new Date(2009, 1, 1)];
dates2 = [{date:new Date(2008, 1, 1), area:"global", port:"application"}, {date:new Date(2007, 12, 1), area:"area", port:"application"}, {date:new Date(2008, 11, 1), area:"global", port:"infrastructure"}, {date:new Date(2007, 11, 1), area:"area", port:"application"}];
counter = 0;
today = new Date();
edge = new Date(today.getFullYear()+2, today.getMonth(), today.getDate(), today.getHours(), today.getMinutes(), today.getSeconds(), today.getMilliseconds());
pdates = dates2.slice(0);
plotter = setInterval(plotPoints, 100);
function plotPoints() {
var cIndex = random(pdates.length);
var cDate = pdates[cIndex].date;
pdates.splice(cIndex, 1);
var percentage = (today.getTime()-cDate.getTime())/(today.getTime()-edge.getTime());
var dist = circle._width/2*percentage;
var angle = random(360);
//var angle = random(90);
//var angle = Math.round(Math.random() * (90 - 45 + 1)) + 45;
trace ("angle " + angle);
var myNumber = angle/2;
var rads = angle/(Math.PI/180);
//var rads = angle/(Math.PI/myNumber);
trace ("rads " + rads);
var sin = Math.sin(rads);
trace ("sin " + sin);
var cos = Math.cos(rads);
trace ("cos " + cos);
var y = sin*dist;
var x = cos*dist;
trace (y + "y x" + x + "
");
var centerX = (circle.getBounds(circle._parent).xMin+circle.getBounds(circle._parent).xMax)/2;
var centerY = (circle.getBounds(circle._parent).yMin+circle.getBounds(circle._parent).yMax)/2;
//trace(centerX + " " + centerY);
cPoint = circle._parent.attachMovie(pointer, 'point'+(++counter), circle._parent.getNextHighestDepth(), {_x:centerX+x, _y:centerY+y, date:cDate});
//
//
cPoint.onRollOver = function() {
_root.createTextField('tooltip', _root.getNextHighestDepth(), _root._xmouse, _root._ymouse, 0, 0);
_root.tooltip.border = true;
_root.tooltip.background = true;
_root.tooltip.backgroundColor = 0xFFFFCC;
_root.tooltip.selectable = false;
_root.tooltip.autoSize = 'left';
_root.tooltip.text = y+ " y x " + x;
cPoint.onEnterFrame = function() {
_root.tooltip._y = _root._ymouse-_root.tooltip._height;
_root.tooltip._x = _root._xmouse;
updateAfterEvent();
};
};
//
//
cPoint.onRollOut = function() {
_root.tooltip.removeTextField();
delete this.onEnterFrame;
};
//
cPoint.onPress = function() {
_root.drawMyLines();
};
//
if (pdates.length == 0) {
clearInterval(plotter);
}
//
}
Plotting On A Curve.. I Need A Math Genius
Hi All
Great forum! I have a problem you might be able to help me with.
I have a curveTo – an anchor point and a control point.
Then I have a function that will return the x and y of a point along that curve if I give it a number as a percentage of the curve (0 to 1).
It looks like this, and works perfectly..
Code:
function drawOnCurve( interval:Number, x0,y0,x1,y1,x2,y2)
{
interval = Math.max( Math.min( 1, interval ), 0 );
var intervalSq:Number = interval * interval;
var difference:Number = 1 - interval;
var differenceSq:Number = difference * difference;
var _obj = new Object();
_obj.x = differenceSq * x0 + 2 * interval * difference * x1 + intervalSq * x2;
_obj.y = differenceSq * y0 + 2 * interval * difference * y1 + intervalSq * y2;
return _obj;
}
// x0,y0 are the start point, x1,y1 the control point and x2,y2 the final anchor point
But… I want to give it a _y value instead of a percentage (interval) and it return where on the curve that would intersect. Is that possible??
What r your thoughts, how should I do this?
Many Thanks
Nic
Plotting Points On A Circle, Like A Radar
I’ve been working with this one code for a while now that plots points in a circle where the center of the circle is today’s date and the out edge is 2 or 3 years out. The code places each point the correct distance from center randomly around the center point. It’s been working great, but now my boss wants to see the circle split into 4 quadrants. Now the points need to be within one of the quads dependant on two variables (area & port). I think the easiest way to explain it is that the circle is cut up like –
Top half = application
Bottom half = infrastructure
Left half = global wide
Right half = area wide
The math is really too far over my head at this point, so I’m hoping someone has the knowledge to help out with this.
If you put the code on the first frame and add a circle MC to the stage, call it myCircle, and have a point in your library with the id myPoint you can run this to see it work
Code:
circle = myCircle;
pointer = 'myPoint';
years = 2;
dates = [new Date(2008, 1, 1), new Date(2008, 1, 1), new Date(2008, 1, 1), new Date(2008, 2, 26), new Date(2008, 1, 1), new Date(2009, 1, 1)];
dates2 = [{date:new Date(2008, 1, 1), area:"global", port:"application"}, {date:new Date(2007, 12, 1), area:"area", port:"application"}, {date:new Date(2008, 11, 1), area:"global", port:"infrastructure"}, {date:new Date(2007, 11, 1), area:"area", port:"application"}];
counter = 0;
today = new Date();
edge = new Date(today.getFullYear()+2, today.getMonth(), today.getDate(), today.getHours(), today.getMinutes(), today.getSeconds(), today.getMilliseconds());
pdates = dates2.slice(0);
plotter = setInterval(plotPoints, 100);
function plotPoints() {
var cIndex = random(pdates.length);
var cDate = pdates[cIndex].date;
pdates.splice(cIndex, 1);
var percentage = (today.getTime()-cDate.getTime())/(today.getTime()-edge.getTime());
var dist = circle._width/2*percentage;
var angle = random(360);
//var angle = random(90);
//var angle = Math.round(Math.random() * (90 - 45 + 1)) + 45;
trace ("angle " + angle);
var myNumber = angle/2;
var rads = angle/(Math.PI/180);
//var rads = angle/(Math.PI/myNumber);
trace ("rads " + rads);
var sin = Math.sin(rads);
trace ("sin " + sin);
var cos = Math.cos(rads);
trace ("cos " + cos);
var y = sin*dist;
var x = cos*dist;
trace (y + "y x" + x + "
");
var centerX = (circle.getBounds(circle._parent).xMin+circle.getBounds(circle._parent).xMax)/2;
var centerY = (circle.getBounds(circle._parent).yMin+circle.getBounds(circle._parent).yMax)/2;
//trace(centerX + " " + centerY);
cPoint = circle._parent.attachMovie(pointer, 'point'+(++counter), circle._parent.getNextHighestDepth(), {_x:centerX+x, _y:centerY+y, date:cDate});
//
//
cPoint.onRollOver = function() {
_root.createTextField('tooltip', _root.getNextHighestDepth(), _root._xmouse, _root._ymouse, 0, 0);
_root.tooltip.border = true;
_root.tooltip.background = true;
_root.tooltip.backgroundColor = 0xFFFFCC;
_root.tooltip.selectable = false;
_root.tooltip.autoSize = 'left';
_root.tooltip.text = y+ " y x " + x;
cPoint.onEnterFrame = function() {
_root.tooltip._y = _root._ymouse-_root.tooltip._height;
_root.tooltip._x = _root._xmouse;
updateAfterEvent();
};
};
//
//
cPoint.onRollOut = function() {
_root.tooltip.removeTextField();
delete this.onEnterFrame;
};
//
cPoint.onPress = function() {
_root.drawMyLines();
};
//
if (pdates.length == 0) {
clearInterval(plotter);
}
//
}
Flash 5 Draw Line By Plotting Points
I have been trying to figure out a good line drawing function for Flash 5. I haven't liked what I've found so I experimented a little.
This example has a point on the stage which can be dragged to another position (just because I could). Whenever you click on the stage, it draws a line from that point to the mouse pointer. I had used an example that scaled a MC line, but wanted to do it point by point. So I changed it around.
I thought of posting it in the Flash 5 forum, but since I have a working example I put it here. The main problem with it is that it seems to lag after 10 or so lines have been drawn. Does anyone have any ideas on this or another way to send the x-y coordinates of two points to a function and have a line drawn between the two?
Flash 5 Draw Line By Plotting Points
I have been trying to figure out a good line drawing function for Flash 5. I haven't liked what I've found so I experimented a little.
This example has a point on the stage which can be dragged to another position (just because I could). Whenever you click on the stage, it draws a line from that point to the mouse pointer. I had used an example that scaled a MC line, but wanted to do it point by point. So I changed it around.
I thought of posting it in the Flash 5 forum, but since I have a working example I put it here. The main problem with it is that it seems to lag after 10 or so lines have been drawn. Does anyone have any ideas on this or another way to send the x-y coordinates of two points to a function and have a line drawn between the two?
Problem With External MCs, Loading An External Into An External
What I have is 2 seperate files, Main file is the actual website flash, second file is the external movie clip that loads 3 other external movie clips. The site will see the external clip but nothing will appear on the site, blank movie clip only.
On the main site there is this code to load the external clip into the site:
ActionScript Code:
loadMovie("toonsext.swf", _root.toons_mc)
On the external clip these are the codes for loading the 3 characters onto it:
ActionScript Code:
loadMovie("joshtoon.swf", joshblank_mc)loadMovie("toonmatt.swf", mattblank_mc)loadMovie("metoon.swf", meblank_mc)
Seperately the external clip will work and show the characters however on the main site it will not show anything. What could be the problem can flash not load 2 seperate entities like this or is there a code wrong on my behalf?
Load External Text Inside An Already Loaded External Movie
here's the problem as simply as I can explain it.
there's a main.swf, a news.swf and a text.txt
the news.swf is loaded into the main.swf and I want to load the text.txt into the news.swf
everything works when I just load the text into the news.swf without loading it into the main.swf, so I know the text.txt part is loading.
[F8] External Text Files Wont Load Into External Swf File...
Hi,
I'm making a Flash website in Flash 8 (mac).
Structure: There is 1 main file that loads external SWF files depending on what is clicked on.
One of the external SWF files loads its text from external text files. This works fine when viewing the SWF applet on its own. But when viewing as a whole site, the text doesnt appear. Very annoying.
I made that particular SWF on my mums computer running Flash MX 2004. The flash file itself uses the Scrollbar component from MX.
Could someone tell me why the text doesnt load in this scenario? It runs fine on its own, just not as an external SWF.
I've attached the files in question. Its a 200kb ZIP download. Do tell me if you need to know more.
Thanks
How To Load An External Movie Using A Link Within An External Swf - Urgent
Hi all
Flash CS3 but coding in AS2 - mac.
I believe I have asked this question before but i was using loadMovie() - I am now using loadClip and the MovieClipLoader class and obviously I have managed to break something.
I have a number of external swfs which load fine, with preloaders using MovieClipLoader, into an empty MC on the stage called holder_mc. In one of the external swf's, there are two links to separate external swf's - if you click on either of them, the current swf is unloaded and the new one is loaded. I used:
Code:
myButtonWithinSwf.onRelease = function() {
this._parent.loadMovie("newMovie.swf");
}
However now that I am using a different code (because before, evrything wasnt preloaded, i just had a white space until it appeared) the code within the swf obviously has to change. The only problem is, I cant for the life of me work out what it is, I have tried all sorts of combinations and probably missed the most obvious one. I do not want to create empty movie clips, I want the movie to load into the MC which I have defined - holder_mc - and usually I would tell it to unloadClip() before loading the new one, but it cant load a new one if it has unloaded itself. I hope that makes sense!
This is the code I am using on the main timeline to control the preloading of the external swf's:
Code:
var mcLoader:MovieClipLoader = new MovieClipLoader();
var loadListener:Object = new Object();
loadListener.onLoadStart = function() {
holder_mc.stop();
};
loadListener.onLoadProgress = function(target:MovieClip, loadedBytes:Number, totalBytes:Number) {
pleaseWait._visible = true;
var preloaded:Number = Math.floor(loadedBytes / totalBytes * 100);
preloaderMC._visible = true;
preloaderMC.loadText.text = preloaded.toString() + "%";
preloaderMC.loadBar._yscale = preloaded;
};
loadListener.onLoadInit = function() {
preloaderMC._visible = false;
pleaseWait._visible = false;
holder_mc.play();
};
/**** register listener object with MovieClipLoader object ****/
mcLoader.addListener(loadListener);
anotherButton.onRelease = function() {
mcLoader.unloadClip(holder_mc);
mcLoader.loadClip("anotherMovie.swf", holder_mc);
}
my preloader is called preloaderMC and pleaseWait is just a movie clip that is placed on the other side of the screen for another reason. loadText and loadBar are the dynamic text and loading bar within the preloaderMC.
I really hope someone can help me ASAP as this was all working before with loadMovie() and now suddenly I cant get it working!
Thanks in advance
Theo
Load External Swf From Html Formatted External Text?
Hi to all,
new to this forum, not so new to flash, but deeper AS...
I searched a while before asking now but didn#t found a solution for what i want to do.
may be someone can give me a hint to this:
I have a html formatted external text file and i want to call from this a external swf movie like
Code:
<a href="loadMovieNum("products.swf",10)">products</a>
I guess i need a asfunction for this?
So i read this:
http://www.macromedia.com/cfusion/kn...fm?id=tn_15639
But still get not the trick how to..?
I tried this:
in 1. Frame of movie i placed:
Code:
function myFunction () {
loadMovieNum("products.swf",10);
}
and changed html text in:
Code:
<a href="asfunction:myFunction">products</a>
when i publish and add a trace function is still got the comment i gave in trace but external swf is not loaded.
I get no error in output window, but not loaded.
Any ideas or hints?
Would be great.
Thank you for a hint.
all best
cyrano
Preloader For External Swf That Pauses External Swf Until Completely Loaded
I'm fairly new to all of this stuff, so bear with me . . .
I want to load an external swf into a main swf movie. (This much I can do).
I would like a separate preloader movie in the main swf movie to display the amount loaded.(I've found tutorials for that, so that's not the issue.)
The problem is that I want the external swf not to start playing until it is completely loaded.
If I put a stop on the first frame of the external swf, that will keep it from playing, but, I'm not sure how to get the external swf to recognize that the load is complete.
I could put a preloader in the external swf, but I'm trying not to so that I can reuse the preloader for other external swf files without having to put it in each one.
Maybe I put a preloader without a visual component on each external swf?
Any help would be greatly appreciated.
Thanks.
Preloaded External Swf Do Not Show External Dynamic File...?
okeli... I am posting because I am totally stuck... my xp regarding coding and stuff is absolutely crap (although I do understand most logic to the scripts u all write out), so I have followed most of ur tutorials on the site.
The problem:
I have made a main file and used primarily two of ur tutorials together. The first one is Claudio's Preloader and transition tutorial, http://www.kirupa.com/developer/mx/p...transition.htm, but also kirupa's Scrolling dynamically loaded text, http://www.kirupa.com/developer/mx/dynamic_scroller.htm.
The file main.swf should load, with transition and loading, the file members.swf - which it does. However when members.swf should load currentmembers.asp as a scrolling text the text do not show up. When I however view members seperately the scrolling text DO SHOW up! I am all confused at this and the only thing I can imagine being wrong is somewhere in the coding of main.fla file... :/ Perhaps I am wrong (which would not be a surprise) so if someone kind enough can have a look through at the coding of the main.fla and/or members.fla I would be sinceraly grateful... thanks...
The files:
http://www.sebszhost.com/~leete/FftC/currentmembers.asp
http://www.sebszhost.com/~leete/FftC/main.fla
http://www.sebszhost.com/~leete/FftC/members.fla
Loading External SWF From External SWF Onto An Empty MC On Main Timeline?
Hi Everyone,
Please bear with me while I explain. I have an external swf that loads into a frame in the main timeline, into an empty MC. I can do this just fine. Once this clip is loaded, I have a button in this clip that loads another external swf into a different empty MC on the main timeline. I'm using loadMovie, and I need to load these movies into specific empty MCs. In other words,
I have the following:
MainStage: frame 5, contains empty MC "ClipA"; frame 6, contains empty MC "ClipB"
External swf: "Movie1"
External swf: "Movie2"
"Movie1" goes into "ClipA" of frame 5 on Main Timeline; and "Movie1" has a button that loads "Movie2" into "ClipB" of frame 6 on Main Timeline. I need help loading "Clip B" into "Movie2" from a button in "ClipA."
I'm sorry my message is so roundabout - it's not really a complicated situation, but explaining it makes it seem so.
Thank you in advance for any help - I'm assuming it's some sort of _root or _parent issue things I'm not quite understanding.
Thanks!
macgirl
Trigger External Swf To Load Into Main Swf From Button In Another External Swf
I'm really stuck with this and it seems like such a simple problem to solve.
I am trying to get a nav button in one movie (main_nav.swf) to target a my main movie (index.swf) and load a sub nav movie (metals_subnav_infinite.swf) into it. The sub nav movie will do a similar task - loading a portfolio swf into main movie (index.swf).
Here is the file breakdown of my working files:
index.swf - main final movie which loads "main_nav_infinite3.swf" on start
main_nav_infinite3.swf - loads main nav "main_nav.swf" and scrolls it infinitely (infinite menu)
main_nav.swf - main nav with buttons that trigger sub nav "metals_subnav_infinite.swf" to load into index.swf
metals_subnav_infinite.swf - loads sub nav "metals_subnav.swf" and scrolls it infinitely
metals_subnav.swf - sub nav with buttons that trigger "folio.swf" (have not created this file yet!) to load into "index.swf"
The script I was focusing on is in main_nav.fla and it is:
metals_mc_bn.onRelease = function() {
reActivateMenu();
this.gotoAndStop(3);
this.enabled = false;
_level1.sub_nav_content_mc.loadMovie("metals_subna v_infinite.swf");
};
I haven't yet activated all the buttons yet just the "Metals" button as the first to get working.
I have attached the FLAs.
exxie!
How To Load An External Movie Using A Link Within An External Swf - Urgent
Hi all
Flash CS3 but coding in AS2 - mac.
I have asked this question before but i was using loadMovie() - I am now using loadClip and the MovieClipLoader class and obviously I have managed to break something.
I have a number of external swfs which load fine, with preloaders using MovieClipLoader, into an empty MC on the stage called holder_mc. In one of the external swf's, there are two links to separate external swf's - if you click on either of them, the current swf is unloaded and the new one is loaded. I used:
Code:
myButtonWithinSwf.onRelease = function() {
this._parent.loadMovie("newMovie.swf");
}
However now that I am using a different code (because before, evrything wasnt preloaded, i just had a white space until it appeared) the code within the swf obviously has to change. The only problem is, I cant for the life of me work out what it is, I have tried all sorts of combinations and probably missed the most obvious one. I do not want to create empty movie clips, I want the movie to load into the MC which I have defined - holder_mc - and usually I would tell it to unloadClip() before loading the new one, but it cant load a new one if it has unloaded itself. I hope that makes sense!
This is the code I am using on the main timeline to control the preloading of the external swf's:
Code:
var mcLoader:MovieClipLoader = new MovieClipLoader();
var loadListener:Object = new Object();
loadListener.onLoadStart = function() {
holder_mc.stop();
};
loadListener.onLoadProgress = function(target:MovieClip, loadedBytes:Number, totalBytes:Number) {
pleaseWait._visible = true;
var preloaded:Number = Math.floor(loadedBytes / totalBytes * 100);
preloaderMC._visible = true;
preloaderMC.loadText.text = preloaded.toString() + "%";
preloaderMC.loadBar._yscale = preloaded;
};
loadListener.onLoadInit = function() {
preloaderMC._visible = false;
pleaseWait._visible = false;
holder_mc.play();
};
/**** register listener object with MovieClipLoader object ****/
mcLoader.addListener(loadListener);
anotherButton.onRelease = function() {
mcLoader.unloadClip(holder_mc);
mcLoader.loadClip("anotherMovie.swf", holder_mc);
}
my preloader is called preloaderMC and pleaseWait is just a movie clip that is placed on the other side of the screen for another reason. loadText and loadBar are the dynamic text and loading bar within the preloaderMC.
I really hope someone can help me ASAP as this was all working before with loadMovie() and now suddenly I cant get it working!
Thanks in advance
Theo
Preloader For External Swf That Pauses External Swf Until Completely Loaded
I'm fairly new to all of this stuff, so bear with me . . .
I want to load an external swf into a main swf movie. (This much I can do).
I would like a separate preloader movie in the main swf movie to display the amount loaded.(I've found tutorials for that, so that's not the issue.)
The problem is that I want the external swf not to start playing until it is completely loaded.
If I put a stop on the first frame of the external swf, that will keep it from playing, but, I'm not sure how to get the external swf to recognize that the load is complete.
I could put a preloader in the external swf, but I'm trying not to so that I can reuse the preloader for other external swf files without having to put it in each one.
Maybe I put a preloader without a visual component on each external swf?
Any help would be greatly appreciated.
Thanks.
External Clip, External Variables Don't Load
hi all,
I'm having some trouble with external variables and external movie clips. I have a main movie, and one part of it is an external movie, the main movie has a bunch of variables stored in a text file. This works fine. The external movie also has a bunch of variables in a different text file. When I play the external movie on it's own it works fine too. When I load the external movie from my main movie, the movie loads but the variables don't. Is there a special way to do this with more movies, do I have to load variables on different levels or something?
I generally use this to load variables
loadVariables ("roznet.txt", "");
I have tried using absolute paths as well (http://) but the same thing. It works by itself but when it is within my main movie the variables don't load. Any ideas? Thanks.
|