Flash :: Finding Shortest Distance / Route On Map?
Aug 9, 2011
In Actionscript, I'm trying to work out the best way to create the shortest route between two point on the map above. I have all the distances.
Algorithms like A* I dont think are relevant as it is near impossible to work out the heuristic distance.
I thought I could create a big array of all the nodes with the distances to any connected nodes and just iterate through until Ive found the the shortest distance, but this I know is very inefficient.
It is a circle divided into 5 equal parts each 72 degrees. So each state you can see is increases the rotation by 72 degrees. I have a transition for the rotation when the state changes like so:
[Code]....
Being that this is a circle you can actually rotate CW or CCW to get to the right degree for the state. Usually the rotation-transition uses whichever is lower. For example to get from Classic to Centro (0 to 72) it goes CW. But this is not always the case. To go from Lace to Lido (144 to 216) it goes CCW. This is not desired sense it would make a much better transition to go CW because it requires less spinning of the circle to get to the desired degree.
I want to put shortest int in shortest: shortest = 500; for(i = 1; i <= _global.var_process_count; i++) { if(_root["process" + i].process_time_original.text < shortest) shortest = _root["process" + i].process_time_original.text ; } What's wrong with above lines of code?
I am working on the project where everything is based on the distance from the center of the stage. First I made this fla where flash outputs the x and y distance from the center. First problem is that I want to output distance only in positive numbers.
I would like to do something like this URl...but have the individual lines animate and show progress along a route. It needs to be a 'real' map so that I can feed in LAT/Longs for for the polylines. This is also a similar effect URL... but I don't need the map panning.I am aware of the google maps api for Flash but there doesn't seem to be any animation other than panning.
I am posting my code that attaches the movieclips on stage
[Code]...
i was hoping that when the newMc expands, all other mc would keep the same distance between each other as at initialisation. I not able to figure how to do it. maybe even an earlier post or llink where similar query was explained.
I am currently working on a quite big map and trying to provide the shortest path service between two points. From what I saw, this is possible with a small map since it has to calculate ALL possible paths and then choose the shortest one (Am I right?).
I have an FLV file that I want to be able to make a text box that acts as a password field.When the user enters the correct password, I want it to route the internet explorer page to a different website.
I want to have a video with a different language on each channel, to give the viewer the possibility to switch dynamically. That's easily done with setPan, however you end up with the audio playing on only one channel, and that's pretty bad, specially if you watch in headphones. So my question is:
how do you take one channel from an FLV stream and send it to both speakers?
How I should get started to achieve two things. I am creating a map with places and routes between those places.
Objective 1: When a visitor hovers over a place name, I want a tooltip to show, which they can select to be taken to another html page to display information on that place.
Objective 2: When a visitor hovers over a line or path connecting two places, a tooltip shows to identify that route, and again when the tooltip is clicked, the visitor is taken to the route details html page for further information. I want the tooltip to show up anywhere along the path which is hovered over.
I want to know, how I should start to design this and what elements will be required to achieve this, especially the tool tips. And how easy is it to make a path highlight, like a button, when hovered over, can a path have different states? Here is a image done in Fireworks of my objectives.
I have been learning about classes and oop programming with AS2. I think I have a very good idea of how it all works, but I'm lacking in one final area before I can truly say I'm coding in OOP. Currently, I use a contentmanager class to route all button commands through. This class handles the removal and preperation of the stage for content change, and then seperate classes handle the actual loading and placement of the new content.
So in a way, its not really OOP, just very well organized code. The next step is Event Management in AS2. I know it can be done, I read through a few tutorials, but get confused by it all. What I'm looking for now is two things.. a very good Event Management tutorial or article if anyone knows of any..
as well as a sample site that can be downloaded or viewed which has been written using OOP. I want this sample site, to re-evaluate how my current way of programming holds up compared to more proffessional examples...(Perhaps even we can turn this into a hot thread with examples of code and structures to help other developers trying to gain a grip on OOP..?)
so i finally decided to jump to as3 from as2! (yes, it took me some time XD) I have a better understanding of as3 after reading tutorials, however i have a problem/doubt: I have 2 movieclips on my main timeline with the name of the instances: OBJ_1 and OBJ_2. both have animations. OBJ_1 has a stop on its 1st frame; OBJ_2 has an action in its last frame:
In the scene there is a star and an AI player.what equation would take the AI player on the most direct route to the star...i.e guide it into the path of the star...just to make things clear, the star is static and the ai plaer is controlled by the computer. i think you have to make two variables distx and disty and use some sort of trigonometry on them but i'm not entirely sure on how to go along doing this.
Currently I am working on a map that will animate the drawing of a line between two points as soon as the user hovers over the end point. A good example of this can be seen on the home page of Jet2.com (the map of Europe).
It seems I am having difficulty with drawing the line dynamically. Of course, just drawing a still line between two points is easy, just use MoveTo() and LineTo(). However, having the line expand in an animation is quite difficult for me.
Here is what I've come up with so far:
Code: // Create the clip this.createEmptyMovieClip("drawing_mc",1); // Declare variables
Im working on some actionscript drawing, right now Im drawing a curved line on a map to show a route for a shipping company, the line is red but I would like to color a portion of the line green for the completed portion of the journey.
I've been doing a number of pretty basic flash banner ads at the typical advertising size (728x90, 300x250, etc.) but the client wants to throw in some video for this upcoming batch. I've already been given the .flv movie file. It's about a minute long at 3 mb, but I'm only going to use about 4 seconds of it. My question is what is the routine/typical route to take when adding video to banners but also keeping under the file size limitations (around 37k)? I did some brief research and read about progressive downloading but wasn't sure what the typical direction was when delivering files like this to the vendors.
I'm creating a drag based control in Flex / Flash, similar to a film strip, where an individual can swipe horizontally to scroll through the items. To make the control feel a bit more natural I've added some inertia to slow the scrolling once a swipe has taken place. When first loaded up there will be five items in view with 'x' numbers of items to scroll through with the 3rd item centred and selected.
My problem though is that I want, when animating, a swipe gesture to determine whether an item will end up the middle (3rd position) and adjust its movement calculation accordingly so it docks with the 3rd / centre position. Imagine you perform a long swipe, it flys pasts 'x' amount of items, but as it slows to a stop it elegantly stops with an item centred / in the 3rd position. To do this I believe I need to determine the distance to travel just from the speed value (as time is irrelevent to the user experience, i.e. a longer / stronger swipe would justify a longer animation skimming through the items).
At the moment I'm invoking the animation routine (with inertia) in the ENTER_FRAME event when the user generates a MOUSE_UP event. When they do this, I obtain the speed of drag (by monitoring this beforehand) and then decrement this speed value on each call of the ENTER_FRAME event until it reaches an appropriate value to stop the animation.
Unfortunately all the speed calculations I've seen deal with Speed and Time to determine distance, I just need Speed. Admittedly, my knowledge isn't strong in this area so I might be missing the obvious.
I am rotating an object with TweenLite, however instead of a set duration I want the duration to be based upon the distance of rotation where 180 degrees = 3 seconds 90 = 1.5 and so on. Here is my attempt to find the distance of rotation:
var time:Number = Math.abs(Math.atan2(Math.sin(angle-wheelObj.rotation),Math.cos(angle-wheelObj.rotation)); TweenLite.to(wheelObj, time, {shortRotation:{rotation:angle}, ease:Expo.easeOut, onComplete:rotateWheel, onCompleteParams:[target]}); TweenLite.to(carObj, time, {shortRotation:{rotation:angle}, ease:Expo.easeOut});
This just isn't working, time is sometimes huge when the rotation is small and sometimes tiny when it is big, so does anyone know a better way to do this?
example im dragin one mc object. with as3 code, and when im draging i want to do next:now if(400<mc.x<450) {trace("WIN DUDE XD")}[how to make that interval ?!(how to set that condition in "if" statement)every time when i drag my mc is between 400 and 450 on x axis, to trace Win
I am given a task by my client to develop a calculator which will calculate the Cab fair from one location to another. There is a list of Cab fairs as well as their corresponding Location Name. It would be displaying the results on the screen.
I need to create a 'rolling' percentage text field, the only problem is as the size of the characters changes, the text jolts a little from right to left and back.How can this be overcome for a smoother effect?
private function init(e:Event = null):void { removeEventListener(Event.ADDED_TO_STAGE, init);
I've got a textfield creater that creates a nice textfield when I hover over a moveable button. However, when I click and drag that button around the flash movie, the text field disapears off the edge of the screen if I get to close to the right side. Can I adjust the width of the textfield as the mouse is moving closer to the edge?