Search Page For Nearest Dealer
I like to make a search page when u fill in a zip code [the place where you live]. The result will give a name and adress of a nearest dealer in that region.
Can please someone help me with a script or fla file.
ThanXs
FlashKit > Flash Help > Flash ActionScript
Posted on: 01-17-2003, 06:59 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Proximity Based Dealer Search?
Is there a nice, simple, EASY way to accomplish this??
my boss wants customers to be able to enter their zip code and in turn display a list of dealers within a certain distance. he got the idea from one of his competitors: click here to see their site.
anyway, the big difference is that I'm working in Flash (MX 2004 Pro) and the other site was done in HTML. Another issue that I'm gonna have is that I don't have the slightist hint of a clue as to how to use PHP. Not even a little bit!
Anyway, any suggestions would be appreciated. If I can't get this worked out then I guess it isn't a HUGE deal, I'll just tell the man to deal without but I'd like to be able to get it done.
Thanks in advance
-James
Search For The Nearest Location By ZIP CODE
Greetings,
I am posting this to find suggestions for creating a flash script that will allow the user to enter their zip code and a potential radius to bring up results of the closest locations...
Thoughts, Suggestions, Rebukes welcome please and Thank You.
JH
Store Locator To Search By Zip Code And Return 4 Nearest Stores
Hi,
I need to figure out the best way to add an approriate store locator to my site. The site is in flash. I am actually re-doing a site someone else did before me (I have no relationship with them though). and I see that they had a functioning script that searched by zip code in the usa and returned the 4 closest stores to that zip code. However they managed (or had to) to integrate an html form into an html page that looked the same dimensions as the flash movie (the user was redirected to this page when they had to visit the store locator section).
I have been looking online and see many scripts but none that return the four nearest stores, and many seem extremely expensive so although i'm willing to shell out, i'm nervous to do so incase its the wrong thing.
Also, i suppose the script shoudl have enough functionality so tah tif i like, i can search by city or state, since i just had a call from eth client who mentioned they may prefer this. Grrr.
many Thanks in advance of any help/advice/redirection : )
Cheska
Finding A Dealer By Zipcode
what i'm doing here is actually fixing someone else's code- they have made two flash projects with the same functionality, and they appear to be alike other than the names of the objects they call out to in the project.
however only one of them works, and takes you to the dealer's website showing all the nearest locations based on the zipcode entry on the banner. trace shows up everywhere in what i assume is the bad function- postZip()
If anyone can spy an issue in this script that I'm missing, that would be AWESOME and save me much confusion. I'll post if I find a solution before someone else does. Thanks!
PHP Code:
// Add return key listener for zip code field.
var keyListener:Object = new Object();
keyListener.onKeyDown = function()
{
if(Key.getAscii() == 13)
{
postZip();
}
}
Key.addListener(keyListener);
// Post zip code field value to the exit URL
function postZip() {
Key.removeListener(keyListener);
if ( zipCode.length != 0 && zipCode.text != "Enter Your Zip Code" ) {
_root.motifData.zipcode = zipCode.text;
_root.conduit.exit(2, _root.motifData);
gotoAndStop("frame1");
}
}
zipCode.onSetFocus = function() {
trace("You have selected the zip code field.");
//if ( zipCode.text == "Enter Your ZIP Code" ) {
zipCode.text = "";
//}
}
zipCode.onKillFocus = function() {
if ( zipCode.length == 0 )
zipCode.text = "Enter Your ZIP Code";
}
go_btn.onRelease = function() {
trace("You clicked the GO button.");
postZip();
}
Flash MX Software Best Price...any Internet Dealer?
I would like to buy one set of the full function flash MX software.
After checking out the price via the bizrate website, the best price now is around USD400.
Does anyone know if there is other internet dealer offering better price then this?
Random Card Dealer Not Dealing Randomly Enough...
Hey all,
I've been spending the evening working on a random tarot card dealer, but the problem is that the cards don't seem to come out randomly enough to be realistic. The cards at the start and end of the deck all seem to be drawn last almost every time.
Test it out here -- http://www.drexle.com/tarotDealer001.html (Just keep refreshing the page once it finishes the list)
Also troubling is that sometimes once it gets to the very end of the deck, it will occasionally start drawing blanks... if it worked correctly, you would have 78 cards every time (from 0-77) with no blanks at all.
Here's the relevant code
ActionScript Code:
/////////////////
// The Full Deck
/////////////////
tarotDeck = new Array;
tarotDeck = ["I","will","spare","you","the","giant","list","of","cards"];
/////////////////
// The Used deck
/////////////////
drawnCards= new Array;
drawnCards= [];
////////////////////
// The temp pile
////////////////////
tempPile=new Array;
tempPile=[];
function drawCard(){
//Find a card by using a random number
drawn=Math.round(Math.random()*tarotDeck.length-1);
//Remove cards from tarotDeck and place them in the temp pile until the random number has been reached
for(i=0;i<=(tarotDeck.length-(drawn-1));i++){
tempPile.push(tarotDeck.pop());
}
//place selected card into the drawnCards array
drawnCards.push(tempPile.pop());
//Replace the cards that are in the tempPile array back into the tarotDeck array
for(i=0;i<=tempPile.length;i++){
tarotDeck.push(tempPile.pop())
}
}
File attached, if you want to compile it yourself with the full list of cards.
Flash Search Page
I have a flash site that I would like to have a search funtion on. If this involves too much code and hence too much time I have created an HTML site map, once you search this page for a string and click on the answer I would like it to take the user to a specific location within the flash movie. I know you can do this if the flash movie is embedded with the HTML page you are using to search. So, two options - have the flash movie on the same page as the search page (which does not look good) or have the search page be able to jump to a frame number or label in an external flash movie.
Cheers..........
Search Box And Results Page
I am trying to translate a html search box script into a Flash MX action and can't get it to work and am probably on the wrong track .
My html code is <input type="text" name="SearchKeyword" size="24"> <input type="button" value="Go" onClick="location.href='webcontent-2.htm?' + SearchKeyword.value"></input>
It takes the search query and inputs it into another search page which has the search engine.
I created a input text field and then a button and tried some action script but don't really know what I am doing.
on(release){
getURL("webcontent-2.htm"+_root.SearchKeyword)
}
Zip Code Search From SWF To ASP Page
Im using Flash MX 2004 and I need help
I have a swf movie with a input text field for a zip code search that results are shown in asp page and sql database
<form method="POST" action="usa/ZipSearchAll.asp">
How do I do this please help
Thank You so much for Help
Flash Search Page
I have a flash site that I would like to have a search funtion on. If this involves too much code and hence too much time I have created an HTML site map, once you search this page for a string and click on the answer I would like it to take the user to a specific location within the flash movie. I know you can do this if the flash movie is embedded with the HTML page you are using to search. So, two options - have the flash movie on the same page as the search page (which does not look good) or have the search page be able to jump to a frame number or label in an external flash movie.
Cheers..........
Search Function With In Page Flipper
Hi
I have been making page flipping e-book with this Premium Page Flip for a while. I usually make small book that is less than 30 page so i was usually happy about using navigation button and pull down list called "combobox" given by the source code.
I was think about a search function to help me get to certain page. Since my page source is mostly jpg file. I was thinking about has search function search through a list with some keyword with page information attach to it and then print these information on a pop up box.
however, I have played with flash for a week. i seems I can't find proper function to do it. I wonder if anyone can help me or i just went a completely wrong directly.
Is It Possible To Search A Flash Page For Details?
Hello,
I want to make a page which holds a lot of text data. Actually its pages with a lot of companies and there email address and other information. And I was wondering if it was possible to have a search engine for that web site only.
For example if I typed in "Computers" it would search my web site and then display all the information dealing with Computers from my web site.
Ok I need to know if it can be done in Flash first before I even try to make this.
If it can let me know where should I start. It is very important that it only checks my site!
So I invite all to join in.
Yours Respectfully
Avin Sinanan
Multiple Page Search Results
Hey
I am busy working on a results page. What it does is to collect data from a php qeury via AMFPHP. And dynamicly creates 12 text fields per page with the results. The data that comes in comes from an array.
I then need to create the next/previous page buttons plus the number of pages for the results. (Kind of like the google results pages)
"noPage" is a value that i worked out earlier in the script. It is the no of item in the array devided by 12
"volumesLoop(i,a,n,x,y,d);" is a call to a function that writes the 12 bits of info
Code:
function createPageLabels(noPages) {
x2 = 200;
d2 = 30;
pageVal = 1;
while (noPages>0) {
trace("creating page number");
_root.createEmptyMovieClip("canvas_mc", d2);
canvas_mc.createTextField("page", d2, x2, 573, 15, 18);
canvas_mc.page.text = pageVal;
canvas_mc.page.setTextFormat(pageTextFormat);
// starting the new page function
canvas_mc.onRelease = function(pageVal) {
trace("onRelease called");
trace("");
d = 13;
while (d>=0) {
dirname.removeTextField();
d--;
}
d = 13;
a = (canvas_mc.page.text -1 )*12;
n = 1;
y = 230;
x = 50.3;
volumesLoop(i,a,n,x,y,d);
};
// end of the new page function
noPages--;
pageVal++;
d2--;
x2 = x2+15;
}
}
So at the moment this script creates an empty movieclip (canvas_mc) and the a text field and it puts a vlue of a page in the text field and then creates the next movie clip with the next page number and so on until the pageVal===NoPages.
If you click on a page number to go to the results it then wipes all the current info of the frame and is suppose to write the next lot of movieclips in its place.
My problem comes in with the linking the page no. movieclip to the correct number in the array. For example if someone clicks on page 2 a should = 12 if you click on page 4 a should = 36 and so on.
Can anyone offer advice on how to do this?
Internet Search For Content In A Flash Page
So I have a web page that I created entirely in flash and only using html for the publication of the host site itself. It is a page for an a cappella group I'm in and I want to make it so that if someone were to search on google or a similar search engine, things like the group name and the member names would be available as the primary responses. The old format of the page, which used html, would produce the top response in google. This is an obvious advantage for when other groups are seaching for us. If anyone knows a way to overcome this obstacle, maybe by hiding some html in there, I would be greatly appreciative. Thanks much.
Search Engines With FLASH Front Page
My employer would like a front page built with FLASH but is very concerned about search engine listings. He asks if there is a way to build an index page without the embedment of the FLASH applet on the index page?
Convert Html Search Page To Flash
im trying to change my search page thats in html with php and javascript ..and convert it to a flash pop-up on my flash movie...and have it look the same with all the pull down list....the html page has arrays in the scripting so when u choose a state it gives u the city choses for that state.....and i also need the to php page to connect it to the mysql database ive built...u can email me if u need additional..info olm75@hotmail.com
the search page is at www.nightspotz.com/search.htm
the web site is of course www.nightspotz.com
Parse Error In Search/results Page
I'm developing a small inventory app for a client, using a PHP/MySql model. I have a search page with only one text field and a submit button. I want to search for data matching the string entered in the text field in ANY field in the table/recordset. I'm using Dreamweaver MX2004 to generate the code. I thought I had everything right, but here's the error I'm getting:
Parse error: parse error, unexpected '=', expecting ',' or ')' in c:inetpubwwwrootlicenseapp
esults.php on line 12
Here are lines 10 - 13 of the code:
PHP Code:
$varsearch_authset = "%";
if (isset(#search#)) {
$varsearch_authset = (get_magic_quotes_gpc()) ? #search# : addslashes(#search#);
}
Here's the SQL statement:
SELECT *
FROM `authorization`
WHERE AuthorizationID LIKE 'varsearch' OR EffectiveDate LIKE 'varsearch' OR ExpDate LIKE 'varsearch' OR AuthNumber LIKE 'varsearch' OR AuthLevel LIKE 'varsearch' OR Requirements LIKE 'varsearch' OR ContactFirst LIKE 'varsearch' OR ContactLast LIKE 'varsearch' OR ContactEmail LIKE 'varsearch' OR ContactPhone LIKE 'varsearch' OR ContactAddy LIKE 'varsearch' OR ContactSuite LIKE 'varsearch' OR ContactCity LIKE 'varsearch' OR ContactState LIKE 'varsearch' OR ContactZip LIKE 'varsearch' OR ContactCountry LIKE 'varsearch' OR Vendor LIKE 'varsearch' OR Personal LIKE 'varsearch' OR Business LIKE 'varsearch' OR Retail LIKE 'varsearch' OR Government LIKE 'varsearch' OR EduK12 LIKE 'varsearch' OR EduHigher LIKE 'varsearch'
And, in the Advanced Recordset dialogue box, I have the variable, 'varsearch' set as follows:
Name - varsearch
Default Value - %
Runtime Value - #search# (the name of the textbox on the search page)
Can anybody see what I'm doing wrong?
TIA,
acorn
POSTing Input Text To A Search PHP Page...
I originally posted this on Macromedia's official support forums, but I can't even reply to suggestions since the connection to that site keeps timing out...
Anyway, I am using the xoops CMS on my site. (www.paintballandstuff.net) Anyway, I converted the original HTML code on the page to something in the flash header.
The original HTML code was:
<form style="margin-top: 0px;" action="<{$xoops_url}>/search.php" method="post"><input type="text" name="query" size="14" style="background-color: rgb(255,255,255); color: rgb(0,0,0); border: 1px solid rgb(0,0,0)" />
<input type="hidden" name="action" value="results" />
<input type="submit" value="Go" style="background-color: rgb(255,255,255); font-family: Tahoma, Verdana, sans-serif; font-size: 12px; border: 1px groove rgb(0,0,0)" />
</form>
Anyway, I thought of using this actionscript in my flash header:
I have a movieclip that contains a button that also has an input text box. The name of this box is "query" and the flash actionscript is:
on (press, keyPress "<Enter>") {
getURL("../../search.php", "", "POST");
}
Anyway, the point of this post is: when I enter text and click on the go button, the search page loads up, but the variable information does not get passed along.
Anyone know why this may be the case?
Flashkit/tutorials Page Doesn't Have Functional Search Engine
flashkit/tutorials page doesn't have functional search engine
if i try searching for some .fla tutorials + .fla file for a specific built-in action, it's too hard. if i try typing it in the search bar, i always get zero results.
Another thing is most .fla files are flash 4 which is really hard to understand for someone who starts learning with AS 2.0 flash 8
anyone remedy?
Map With 'my Nearest'
Hi all... heres one for you...
Will defo need coding etc, but let me know your ideas:
I've got a database of shops with address's and postcodes. I want to have a system where the user would enter their post-code, and the map would show the nearest shops.
I know different websites do this, but I want it to go off my database.
It might not need flash, but any ideas would be appreciated.
Cheers, Andy
Distance To Nearest Anything...?
I would like to be able to have many instances of a movie clip symbol all over a large field, with each one making independent decisions according to the same rules.
I want it to only look at the symbols nearby, perform calculations based on
the distance to the nearby symbols and the frames they are on, and then either go to another frame or not. It doesn't matter which instance is nearby.
Is the only way I can do this really to measure the distance between every symbol to every other symbol, one at at time? That seems hopelessly clunky. (and exponentially more so as I add more copies...)
Next Nearest Birthday
Hey there,
I've been using the following code to obtain the next nearest birthday:
code:
// this is an array of three objects
// each object has a name and a bday
dbase = [{name:"John", bday:new Date(88, 7, 21)},
{name:"Mary", bday:new Date(88, 7, 29)},
{name:"Paul", bday:new Date(88, 7, 12)}];
today = new Date();
var year = today.getFullYear();
var closestBday = undefined;
var closestIdx = 0;
for (var i = 0; i<dbase.length; ++i) {
// for the person i
// get their birthday for this year
var nextBday = new Date(year, dbase[i].bday.getMonth(), dbase[i].bday.getDay());
// check if it already happened
if (nextBday.getTime()<today.getTime()) {
// if so, get their birthday for next year
// trace(dbase[i].name + ' already had a birthday this year');
nextBday = new Date(year+1, dbase[i].bday.getMonth(), dbase[i].bday.getDay());
}
// check if it's the closest birthday so far, if so, keep track of it
if (closestBday == undefined || nextBday.getTime()-today.getTime()<closestBday.getTime()-today.getTime()) {
closestBday = nextBday;
closestIdx = i;
}
}
trace('The next birthday belongs to '+dbase[closestIdx].name);
trace('who will be '+(closestBday.getYear()-dbase[closestIdx].bday.getYear())+' years old');
trace('on '+closestBday);
For some reason, the output is John (August 21), although it should be Paul (August 12).
I can't seem to find an error here, therefore any suggestions/thoughts are highly appreciated...
I desperately need your help here...
Rounding Up To Nearest 10
Hi everyone
I really hope someone can help me
I need to know how to use maths in Flash to convert my x & y coordinates to increments of 10
I have worked out how to remove the decimal points using the 'round' operator, but when I divide the number by 10, drop off the decimal point, then multiply it by ten, the decimal value returns.
here's my current code (where the initial value of 'positionx' might be something like 244.67):
Code:
trace(_root.mc.positionx); // number equals 244.67
trace(Math.round(_root.mc.positionx)); //number will equal 247
trace(_root.mc.positionx/=10); // number will equal 24.7
trace(Math.round(_root.mc.positionx)); // number will equal 25
trace(_root.mc.positionx * 10); // number will equal 247
the modified number I am after would be 250
I know I am probably doing this wrong - so if there's anyone who could put me straight that would be fantastic
thanks heaps
Rounding Off To Nearest 0.5
Hello guys
I need to do this ONE tiny bit before my app is complete.
Math.round lets me round off to the nearest integer, but now I really need to round off to the nearest 0.5 or whole number.
ie.
10.488889 ~ 10.5
16.9999555 ~ 17
4.9999999 ~ 5
11. 51111111 ~ 11.5
Yep the values are somewhat like those. It's really really close to the 0.5 or whole values. I've been racking my brains for the past 2 hrs and I really can't figure it out.
Will appreciated any help. Thanks a lot!!!!!!!!!!
Rounding Ot The Nearest Hundreth
I have a variable that is a number devided by a number. when its somethinglike 3 / 2 then I get a long repeating decimal. For instance:
var number=.3333333333333333333.......
how can I round it to the nearest hundreth, so it'll be
var number=.34
To The Nearest Half Metre
Hi, I am trying to do this efficienty - but I keep over complexifying things.
I have a room area calculator that returns a value in cm2.
I am trying to convert it to the nearest half metre.
For example.
8.55m2 will become 8.50m2
156.84m2 will become 157.00m2
101.12m2 will become 101.00m2
I've been up for a very long time and its now 2.23am in the uk.
But, I cannot turn in till this is done.
Any suggestions - I'm sure I'm missing something obvious.
M@?
How Do I Round A Number To The Nearest 5 Or 10?
I have the following numbers: 10.98, 1.23, 5.66.
I want to round the last digit to the nearest 5, to get: 11.00, 1.20, 5.70.
What's the best way of doing this?
Any help would be appreciated.
Thanks.
OM
Round To Nearest Multiple Of X?
Hi peeps,
One for the math code heads.
I have a scroll bar that is scolling a project list (each project being dynamically loaded). Currently the buttons at either end of the scroll bar shift the list by x amount (being the height of a project window) so that the projects are lined up neatly in the view. You can see what I mean on the site (navigate to recent work and scroll the projets with the buttons) http://www.mainframe.co.uk .
I am now adding drag function to the slider. This means the list moves freely in relation the slider being dragged. However, when the slider is released the project list won't be lined up correctly as it is dependant on the users final drag position.
So here is what I want to acheive. Say the list should move by 150 pixels each time so the projects stay lined up correctly. How do I find the nearest multiple of 150 to the new list position? Example, the user drags the slider and the list moves by 340 pixels. The list would need to move back to 300 and not forward to 450. Can I specify a multiple of 150 in the math.round script? Is this even possible?
Hope I've made my question clear enough.
Thanks for any input.
Regards, Carl
Best Way To Round A Value To Nearest 45 Degrees?
I just wrote this to return the nearest 45 degree angle. Like 0, 45, 90, 135...
It feels like there must be a better way of doing this though. This is working fine but it looks messy.
PHP Code:
public function nearestDeg(degs:int):int {
if (degs >= 0 && degs <= 45) {
if (degs <= 23) {
return 0;
}else {
return 45;
}
}
if (degs > 45 && degs <= 90) {
if (degs <= 68) {
return 45;
}else {
return 90;
}
}
if (degs > 90 && degs <= 135) {
if (degs <= 113) {
return 90;
}else {
return 135;
}
}
if (degs > 135 && degs <= 180) {
if (degs <= 158) {
return 135;
}else {
return 180;
}
}
if (degs > 180 && degs <= 225) {
if (degs <= 203) {
return 180;
}else {
return 225;
}
}
if (degs > 225 && degs <= 270) {
if (degs <= 248) {
return 225;
}else {
return 270;
}
}
if (degs > 270 && degs <= 315) {
if (degs <= 293) {
return 270;
}else {
return 315;
}
}
if (degs > 315 && degs <= 360) {
if (degs <= 338) {
return 315;
}else {
return 360;
}
}
return 0;
}
Rounding To The Nearest Tenth?
Hi guys,
I was just wondering if there was any way to round a number only to the first number beyond the decimal. I know that Math.round(X) rounds the whole number, but I'm not looking for that.
For example, with Math.round, 8.4345809 would go to 8, but I want it so it goes to 8.4.
Thanks a lot!
OnMovieFinished ? Or Nearest Function...
I am trying to tell a movie to play to the end of movie 1... once it has reached the end then play the next movie... basically I have
ActionScript Code:
mc_globe.gotoAndPlay("playEnd");
mc_globe.loadMovie("mapNewZealand.swf");
but the new movie is loaded before the last movie finishes playing. When tweening there is the function onMotionFinished... is there anything similar to say when a movie has finished playing then do x ?
Thanks in advance
Determining Nearest Number To Var
Trying to make a seek function for a video file. I want to be able to test the current time and determine the next closest number to jump to. (they are contained in vars from an xml file).
So if the time is 43 seconds, and I want to go forward, how would I say out of 91, 123 and 234 that 91 is the nearest neighbor. Or am I missing it all together and there is a better way?
Round To The Nearest Hundredth?
Hello,
I have a dynamic text box that increases its number by 0.08 every frame, for some reason however, when it reaches around 8, or 9, it starts displaying "9.04000000..." then at about 20, it says "23.529999999999999..." since these numbers extend out of the text box, i was wondering if I could round to the nearest hundredth. I cant use the normal Math.Round() because 0.08 rounds down to 0, and it just sticks at 0. So, is there a way I can round to the nearest hundredth??
Im using this actionscript:
--
_root.onEnterFrame = function() {
num = num + 0.08;
};
--
Thanks,
How Do I Round A Number To The Nearest 5 Or 10?
I have the following numbers: 10.98, 1.23, 5.66.
I want to round the last digit to the nearest 5, to get: 11.00, 1.20, 5.70.
What's the best way of doing this?
Any help would be appreciated.
Thanks.
OM
Nearest Face Of A Square.
Heyas
I've got a problem and I'm in like my 10th revision of code so maybe you all could help.
I am building a cut-down version of Visio so to speak, where you have shapes on the stage that allow you to connect between the two. So if you wanted to connect ShapeA(x:0,y:0) to Shape B (x:100, y:100) it is regarded as being in the TL corner. Thereby ShapeB's faces available are North and West which can be connected - resulting in no lines crossing over into a shapes inner region.
The concept i want to implement is that when you drag your line connector over your intended drop shape, it snaps to the nearest face (North,East,South,West) aswell as the nearest position you were draging over... ie if the end Line connector node is in the bottom left corner of your drop shape and the nearest face is West, it would then maintain the Nodes.y position but snap the Nodes.x position to the intended shapes x.postion - resulting in a snapping concept being in play.
I can get this happening on two variations. First being line Interesects, where i could determine which face has actual line intersection, based on that it determines the face.
I have also tried measuring the distance between two points, finding the shortest one and snapping to the appropriate face.
The problem with these two basically are this. If you drag your line in a 45 degree angle, so that its basically in the dead center of North/West it can't seem to determine the nearest face as its now either North/West?
I had implemented a Random Choice in the event this occures (ie randomly chooses between North or West).
Has anyone else done something of this nature? something along the lines of Line of Site mayabe?
How Do I Round A Number To The Nearest 5 Or 10?
I have the following numbers: 10.98, 1.23, 5.66.
I want to round the last digit to the nearest 5, to get: 11.00, 1.20, 5.70.
What's the best way of doing this?
Any help would be appreciated.
Thanks.
OM
Nearest Face Of A Square.
Heyas
I've got a problem and I'm in like my 10th revision of code so maybe you all could help.
I am building a cut-down version of Visio so to speak, where you have shapes on the stage that allow you to connect between the two. So if you wanted to connect ShapeA(x:0,y:0) to Shape B (x:100, y:100) it is regarded as being in the TL corner. Thereby ShapeB's faces available are North and West which can be connected - resulting in no lines crossing over into a shapes inner region.
The concept i want to implement is that when you drag your line connector over your intended drop shape, it snaps to the nearest face (North,East,South,West) aswell as the nearest position you were draging over... ie if the end Line connector node is in the bottom left corner of your drop shape and the nearest face is West, it would then maintain the Nodes.y position but snap the Nodes.x position to the intended shapes x.postion - resulting in a snapping concept being in play.
I can get this happening on two variations. First being line Interesects, where i could determine which face has actual line intersection, based on that it determines the face.
I have also tried measuring the distance between two points, finding the shortest one and snapping to the appropriate face.
The problem with these two basically are this. If you drag your line in a 45 degree angle, so that its basically in the dead center of North/West it can't seem to determine the nearest face as its now either North/West?
I had implemented a Random Choice in the event this occures (ie randomly chooses between North or West).
Has anyone else done something of this nature? something along the lines of Line of Site mayabe?
How Do I Round A Number To The Nearest 5 Or 10?
I have the following numbers: 10.98, 1.23, 5.66.
I want to round the last digit to the nearest 5, to get: 11.00, 1.20, 5.70.
What's the best way of doing this?
Any help would be appreciated.
Thanks.
OM
To The Nearest Half Metre
Last edited by gameon : 2003-09-26 at 01:36.
Hi, I am trying to do this efficienty - but tend to over complexify things.
I have a room area calculator that returns a value in cm2.
I am trying to convert it to the nearest half metre.
For example.
8.55m2 will become 8.50m2
156.84m2 will become 157.00m2
101.12m2 will become 101.00m2
Im tired, so this solution may not be great. But - it does the job.
To you pro-coders:
Can you do this better?
Am I formatting the script as it should be?
Am I using variables correctly?
Code:
//This is a sting of the length in cm, with the last two digits
//as the mm
//EG: 156.84m2 goes to 15684
//There will be no lengths uner 1m2 or over 100m2
var Cm2 = String("15684");
var SwitchNo = Cm2.length;
switch (SwitchNo) {
case 3:
//Convert to x.xxm
var TheTest = Cm2.substring(0,1)+"."+Cm2.substring(1,3);
break;
case 4:
//Convert to xx.xxm
var TheTest = Cm2.substring(0,2)+"."+Cm2.substring(2,4);
break;
case 5:
//Convert to xx.xxm
var TheTest = Cm2.substring(0,3)+"."+Cm2.substring(3,5);
break;
default:
//ERROR
var TheTest = "Do error";
}
//Get the last two digits
var LastTwo = TheTest.substring(TheTest.length-2,TheTest.length-1)+TheTest.substring(TheTest.length-1,TheTest.length);
//Covert them into a number
var LastTwoNum = Number(LastTwo);
//When this variable is true we will be adding a m on and setting the last
//two digits to '00' - this will be for anything above x.74m
var Add1=false;
//if the number is not greater than zero
//it is zero - so leave it alone
if(LastTwoNum>0){
//if the number is not 50 it must be lower or higher
if(LastTwoNum!=50){
//if taking off 26 makes it lower than 0 - its less than 25
//so we round down
if((LastTwoNum-26)<0){
LastTwoNum=0;
}
//if adding 26 takes it over 100
//we round up
else if((LastTwoNum+26)>100){
LastTwoNum=0;
Add1=true;
}
//this is a catch - set it to 50
else{
LastTwoNum=50;
}
}
}
//get the digits before the '.'
var FrontNumber = Number(TheTest.substring(0,TheTest.length-3));
//if 'Add1' is true : add 1
if(Add1){
FrontNumber+=1;
}
//turn LastTwoTest into a sting of LastTwoNum
var LastTwoTest = String(LastTwoNum);
//if LastTwoTest is a single digit (<10) add a zero infront
//(to make it 00)
if(LastTwoTest.length<2){
LastTwoNum+="0";
}
//output result!
TheTest = String(FrontNumber+"."+LastTwoNum+" m2");
trace("TheTest= "+TheTest);
Cheers if you have the time...
M@)
Round Up/down To Nearest 90 Degrees.
Hi guys.
I have a graphic (arrow) which spins round on the same spot pointing to wherever the mouse go's.
Instead of the arrow pointing to every single angle (360 degrees) I want it to either point up, down, left or right. I think it might need rounding up/down some how to the nearest 90 degrees?
Here's my code that I use just to spin the arrow graphic.
onClipEvent (load) {
_x += Number(2);
friction = .7;
speedratio = .2;
xspeed = 0;
yspeed = 0;
xgoal = this._x;
ygoal = this._y;
}
onClipEvent (enterFrame) {
// figure out our slope
var slope = (_root._ymouse-_y)/(_root._xmouse-_x);
// get it in usable form...
var radians = Math.atan(slope);
var theta = (radians*180)/Math.PI;
theta += (_root._xmouse<_x) ? 180 : 0;
// set the rotation
_rotation = theta;
}
Can anyone help?? Much appreciated.
How Do I Round A Number To The Nearest Hundreth
I am trying to round a number to the nearest hunredth. I use the Math.round() function, but it rounds to the whole number. How do I round to the nearest hundreth? Any help would be appreciated.
Rounding To Nearest Decimal Place
Hey Flash Family,
I am getting the correct output i want but is also giving me like 8 numbers after the decimal place...all i want is the numbers rounded to the nearest cent meaning only 2 numbers to the right of the decimal point....what do i need to add to the current code to correct this issue.
Thanks N Advance
Attach Code
onClipEvent(enterFrame) {
//Set all variables and text boxes for ROI
//final computations. Verify that data is
//acceptable, if not, show message box to
//tell user to adjust variables
//Establish val_tcost
_root.how.ROIM.val_tcost = (_root.how.ROIM.val_cph * _root.how.ROIM.val_homes) / _root.how.ROIM.val_uses;
//Set text box for tcost
this.txt_tcost.text = "$" + _root.how.ROIM.val_tcost;
//Establish val_savings
_root.how.ROIM.val_savings = (_root.how.ROIM.val_trepair - _root.how.ROIM.val_tcost) * (_root.how.ROIM.val_percent/100);
//Set text box for savings
this.txt_savings.text = "$" + _root.how.ROIM.val_savings;
//compute and post percentage
_root.how.ROIM.val_psavings = _root.how.ROIM.val_savings / _root.how.ROIM.val_trepair;
//Post
this.txt_psavings.text = int(_root.how.ROIM.val_psavings * 100)/100 + "%";
this.btn_placeorder.label = "Place order for " + int((_root.how.ROIM.val_tubs * _root.how.ROIM.val_homes)/_root.how.ROIM.val_uses) + " Tub Guards!";
}
Edited: 05/30/2007 at 07:16:44 AM by dabramshunt
Need To Find Nearest Movie Clips
Hi all,
I have an app which has between 30 and 200 nearly identical movie clips on the stage at any time.
I need to get an array of the top 10 movie clips which have the closest global position (X/Y) to any given clip.
Obviously I could do this with a lot of sorting. And I could do it with a server call, and use PHP, since it has advanced multidimensional array sorting methods. But I'd like to avoid server calls, as they will slow the app down.
Is there some high-level way to do this in Actionscript? I'm using Flash MX (6).
Perhaps collision detection methods can be used?
Thanks in advance!! Kindest regards,
-joshua
staff@dot-comet.com
Numerical Operation Rounding To Nearest 100's
I am trying to create a piece of logic to prevent me from doing tons of if statements. Basically, what I need to do is round to the nearest hundreds. For example, if the integer is 30 it will be rounded to 100; If the integer is 123 then it will be rounded to 200; and so forth.
I have been looking at the math functions but I can't find anything that will suit this logic because math.ceil will round to the nearest whole number (6.1 = 7)
Any suggestions or maybe I need to rethink the logic?
Thanks in advance.
How Do I Round A Number Up To The Nearest Integer? URGENT
Folks,
This is what I got into..
To send a package that weights from 0 to 25 kilos from X to Y costs USD 170. And my company charges 5 dollars for every kilo that's over 25 kilos.
The thing is, I couldn't figure out how to create something that calculates the final price of the shipment.
Example: 50 kilos
The actionscript needs to subtract 50 from 25, then we get 25 kilos over the limit and we would charge 5 dollars for every kilo.
Ok, that part has already been figured. The only problem is that sometimes people send 26.8 kilos (or anything heavier, but with decimals). That's 1.8 kilo over 25, isn't it?
In this case we would charge as of 2 kilos over.
Anything that's after the decimal (except zero) would have to be rounded up to the next number, then the actionscript calculates how many kilos we got over 25.
Did you understand the situation????
Quote:
if (varWeight<=25) {
price = "170.00";
total = "0";
} else if (varWeight>25) {
total = (((((int(((Number(varWeight-25))*5.00;
price = Number(170.00)+Number(total);
}
varWeight = Number(varWeight);
The action above just calculates how many kilos we have over 25, but it's not able to round the number up in case we have something after the decimal.
COULD YOU FIX MY FORMULA??
Tks a lot!!!
Find Nearest Theta(circle) Position
I have objects that fly around randomly.
When the objects come near to a ball they turn around the ball.
With this code:
ActionScript Code:
var degreeIncrement = rpm
theta += degreeIncrement;
theta %= 360;
const DEG_TO_RAD:Number = Math.PI / 180;
var radians:Number = DEG_TO_RAD*theta;
this.x += Math.cos(radians)*Pradius*Direction
this.y += Math.sin(radians)*Pradius
Because theta tells them where they should go they should go in the circle the object sometimes go right through the ball to get to this point. But I don't want the objects to go through the ball when they start to turn around. I want the objects to find the theta position nearest to them, so they won't go through the ball.
Anybody have an idea how to do that?
If my question isn't clear enough please tell me.
Math.floor? Round Down To Nearest 10th
Hi Folks, Math is not my friend so I need some help.
I want to round a whole number down to the nearest whole 10th.
Like 52, becomes 50. Or 49, becomes 40. Or 2005, becomes 2000.
Does that make sense? I imagine it has a math.floor approach, but I can not figure it out.
Thanks in advance for any help!!!
|