but in more compleks route, and i want to make the car can choose direction (straigt, turn left of turn right)
but 1st thing 1st.
i need a logical state for the timeline
how the car works?
how can i set the car run independently?
because it can't be done in the main timeline.
i'm guessing it has something to do the the action script, but i have no idea.
i'm kinnda new to flash, this is the 1st time i want to create a AI-like programing with flash.
please help, thanks.
Im using CS4
Last edited by whitelynx_nivla; 08-28-2010 at 12:03 PM.
Reason: resolved for now
I don't mean to be a d*ck but looking at your first post, I'm thinking this might be way too advanced for you.
You're gonna wanna stay away from the timeline altogether when you create a project like this. Everything would be done through code.
You should probably start with a small project where you don't use the timeline at all and make everything happen from the code. Then you can go from there.
I agree with Beathoven. I've been programming a while and I've been reluctant to built these site because I don't feel I have enough experience with the language. Programming AI isn't something you can do on a whim.
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
To get you started, I would have a couple classes separated as follow:
Level : contains the level, the bounds that the cars are allowed in.
Car: contains all the information about the car, where it's trying to go.
Lights: Traffic light objects, graphics & dispatches "go & stop events". The events would let all the other objects if they can go through the lights in the direction they're trying to go. Lights would be a child of level.
Then you would have your main document class that would generate a level object and random car objects coming in from the different possible entry roads.
I don't mean to be a d*ck but looking at your first post, I'm thinking this might be way too advanced for you.
You're gonna wanna stay away from the timeline altogether when you create a project like this. Everything would be done through code.
You should probably start with a small project where you don't use the timeline at all and make everything happen from the code. Then you can go from there.
Originally Posted by samac1068
I agree with Beathoven. I've been programming a while and I've been reluctant to built these site because I don't feel I have enough experience with the language. Programming AI isn't something you can do on a whim.
thanks for the sugestions
but I already make couples of AI program with other language, such as C++ and Java
Now I want to pick up Flash because I think I can manipulate the animation more easily with it (CMIIW)
Originally Posted by Beathoven
To get you started, I would have a couple classes separated as follow:
Level : contains the level, the bounds that the cars are allowed in.
Car: contains all the information about the car, where it's trying to go.
Lights: Traffic light objects, graphics & dispatches "go & stop events". The events would let all the other objects if they can go through the lights in the direction they're trying to go. Lights would be a child of level.
Then you would have your main document class that would generate a level object and random car objects coming in from the different possible entry roads.
That would be the base logic behind it.
Thanks
Very helping
About the cars, just to make sure, I really can't animate it with time line right?I have to move it with code right?
Well if you're making a game, you're probably gonna wanna randomise where and when the stuff comes in (In this case the cars). You're gonna want the car to go from point A to point B, C, D or E randomly. Thus you will have to animate them accordingly.
You're gonna have to create a car object and pass it a 'route' argument. Starting point finish point. And then you will have to programmatically figure how to get from said start and finish points. You will have to hittest and account for other cars as well as lights along the way.
The animations will be fairly easy. They are simple Tweens.
They are created this way:
var myCarTween:Tween = new Tween(myCar_mc, "x", Strong.easeIn, 0, 1, 500, false);
And there you have it, you're car is moving along the x axis from x:0 to x:1 in 500 milliseconds.
Most properties can be tweened easily (x, y, width, height, rotation, etc.). That makes it even easier to deal with than the actual time line.
Well if you're making a game, you're probably gonna wanna randomise where and when the stuff comes in (In this case the cars). You're gonna want the car to go from point A to point B, C, D or E randomly. Thus you will have to animate them accordingly.
You're gonna have to create a car object and pass it a 'route' instance. Starting point finish point. And then you will have to programmatically figure how to get from said start and finish points. You will have to hittest and account for other cars as well as lights along the way.
The animations will be fairly easy. They are simple Tweens.
They are created this way:
var myCarTween:Tween = new Tween(myCar_mc, x, Strong.easeIn, 0, 1, 500, false);
And there you have it, you're car is moving along the x axis from x:0 to x:1 in 500 milliseconds.
Most properties can be tweened easily (x, y, width, height, rotation, etc.). That makes it even easier to deal with than the actual time line.
Does that help a bit?
Yes
I've sorted out the points where the car start, but I didnt manage to find an easy way to animate the car to run
Hmm
i got errors
1046 : type was not found or was not a compile-time constan
1180 : call to a possible undefined method Tweeen.
1120 : Access of imdefinged propertu Strong.
also, when I type Strong.easIn it request input
(t:Number,b:Number,c:Number,d:Number):Number
Just so you know there's other easing algorythms. Just google "easing actionscript 3" and the adobe website will have documentation on all possible easing types.
Just so you know there's other easing algorythms. Just google "easing actionscript 3" and the adobe website will have documentation on all possible easing types.
First off you have to make sure that the car has a name.
Click on your car instance and look in the properties tab. You'll see you have a car of instance "car_mc" but above it it won't have a name. So assign it the name you're gonna use to refer to it.
Then use that name in the code.
Now I have to warn you, I can already tell you're using the timeline and layers and it's gonna become very messy very quick.
I don't think you grasp the concept of Object Oriented Programming yet. You should probably look into it before getting any further ahead.
Your FLA file should contain 1 frame and 1 layer with a initiating document class assigned to it. Everything blank. The library can contain your fonts and your visual objects. For instance you could design the car inside the fla as a MovieClip and keep it in the library. From there you would export the car_mc object for actionscript so you can refer to it and create it on the fly within the code.
First off you have to make sure that the car has a name.
Click on your car instance and look in the properties tab. You'll see you have a car of instance "car_mc" but above it it won't have a name. So assign it the name you're gonna use to refer to it.
Then use that name in the code.
Now I have to warn you, I can already tell you're using the timeline and layers and it's gonna become very messy very quick.
I don't think you grasp the concept of Object Oriented Programming yet. You should probably look into it before getting any further ahead.
Your FLA file should contain 1 frame and 1 layer with a initiating document class assigned to it. Everything blank. The library can contain your fonts and your visual objects. For instance you could design the car inside the fla as a MovieClip and keep it in the library. From there you would export the car_mc object for actionscript so you can refer to it and create it on the fly within the code.
Hmm
Yes, my car image's name is car.jpg
and the instance name of the movie clip from that image is car_mc
maybe I am not ready for this...
I'll starting with more simple task
You converted it to a MovieClip symbol (Right click, Convert To Symbol...)
And then you clicked on it, went in the properties panel and changed <Instance Name> to car_mc (As shown in the attached picture).
You then made your tween in the actionscrip this way:
var myTween:Tween = new Tween(car_mc, "x", Strong.easeIn, 0, 100, 500, false);
yes I did
I also chage the 500 to 5000 so that I can see the movement more easy.
5000mili seconds means 5 seconds for the movement right?
Also I tried to move in Y cordinate
so I wrote
var myTweenX:Tween = new Tween(car_mc, "x", Strong.easeIn, 0, 100, 5000, false);
var myTweenY:Tween = new Tween(car_mc, "y", Strong.easeIn, 100, 200, 5000, false);
I aslo put stop(); at the end of the script, because there's a simple timeline tween animation for the prolog.
I dont want the prolog to be looping around each time the time line ends.
Does it effect the code?
Last edited by whitelynx_nivla; 08-27-2010 at 04:40 PM.
yes I did
I also chage the 500 to 5000 so that I can see the movement more easy.
5000mili seconds means 5 seconds for the movement right?
Also I tried to move in Y cordinate
so I wrote
var myTweenX:Tween = new Tween(car_mc, "x", Strong.easeIn, 0, 100, 5000, false);
var myTweenY:Tween = new Tween(car_mc, "y", Strong.easeIn, 100, 200, 5000, false);
I aslo put stop(); at the end of the script, because there's a simple timeline tween animation for the prolog.
I dont want the prolog to be looping around each time the time line ends.
Does it effect the code?
Just as a note, Tweens created within the actionscript are 'asynchronous' which means they are not affected by the timeline.