Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com Need Help with A*

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 10-13-2013, 02:23 AM PM User | #1 NthMetal New to the CF scene   Join Date: Oct 2013 Posts: 2 Thanks: 0 Thanked 0 Times in 0 Posts Need Help with A* So I'm using as3 with the World Construction Kit and I made an attempt to implement the A* algorithm, but it doesn't work. This is the error it gives me: Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds. I have 3 classes. A Sensor_Node class which detects if it's being touched, and functions as the nodes that the algorithm evaluates. I also have a Sensor_Start and Sensor_Stop classes that the Sensor_Node detects in order to differentiate between the start and stop positions and obstacles. Where I run my code I create all the nodes and put them in a 2D array. I then have a heuristic function that evaluates the heuristics and assigns those values to each node. Then some functional methods, then the algorithm. I attempted to teach myself the algorithm and I understand how it works and the process it goes through, but I can't understand why it's not working here. Maybe WCK is made to cut off after a certain time-out point and the algorithm takes too long, but I think it's likely I made a mistake with it somewhere. So finally here's the code it runs: Code: ```var loadBoolean:Boolean = true; var nodeArray:Array = []; var open_List:Array = []; var closed_List:Array = []; var start_Node:Sensor_Node; var target_Node:Sensor_Node; var checking_Node:Sensor_Node; var foundTarget:Boolean = false; var base_MoveCost:int = 10; var tempNode:Sensor_Node = new Sensor_Node(); stage.addEventListener(Event.ENTER_FRAME, frameLoaded); stage.addEventListener(KeyboardEvent.KEY_DOWN, startAStar); function frameLoaded(e:Event){ if(loadBoolean){ for(var i=0;i<23;i++){ nodeArray[i] = []; for(var j=0;j<40;j++){ nodeArray[i][j]= new node_SensorNode(); nodeArray[i][j].x = (j+0.5)*20; nodeArray[i][j].y = (i+0.5)*20; this.addChildAt(nodeArray[i][j],((i*23)+j)); } } loadBoolean = false; } } function getHeuristic():Boolean{ var touching_Stop_i:int = -1; var touching_Stop_j:int = -1; for(var i=0;i<23;i++){ for(var j=0;j<40;j++){ if(nodeArray[i][j].touching_StopNode){ touching_Stop_i = i; touching_Stop_j = j; break; } } } if(touching_Stop_i>-1 && touching_Stop_j>-1){ for(i=0;i<23;i++){ for(j=0;j<40;j++){ var xdiff:int = Math.abs(touching_Stop_j - j); var ydiff:int = Math.abs(touching_Stop_i - i); nodeArray[i][j].h_Heuristic = xdiff+ydiff; } } return true; }else{ return false; } } function arrayContains(v:Sensor_Node,a:Array):Boolean{ for(var i=0;i
 10-13-2013, 07:47 AM PM User | #2 NthMetal New to the CF scene   Join Date: Oct 2013 Posts: 2 Thanks: 0 Thanked 0 Times in 0 Posts I found the problem. I forgot to initialize the stop node if anyone was wondering. Though i'd still like this thread deleted.

 Bookmarks

 Tags as3, astar, wck, world construction kit

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 04:48 AM.