Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Technical animation problem 1

Status
Not open for further replies.

dwnhllr

IS-IT--Management
Aug 12, 2003
14
US
Hello experts,

I have an issue with an animation that I am trying to create. It is a rather complicated animation involving a number of interrelated components, and I want to make the animation as efficient as possible. Some answers to the following questions would make my life much easier.

First of all this animation is of a system. There are several components to this system:
* engine cross-section
* pistons (with hydraulics)
* airflow indicators (arrows)
* temperature indicators (arrows)
* pressure indicators (colored regions)

Secondly, I would like to add the capability to zoom into different regions of the animation in order to visualize more detail.

Thirdly, I should mention that while I've programmed in C/C++ for over a dozen years, this is my first Flash project. As of this writing, my only flash experience has been to read a tutorial, and opening Flash MX to review the development environment.

Here is how I am currently conceiving of structuring the animation:
1. Static background in its own layer.
* Q1: Does the timeline for this layer need to extend for the number of frames which the entire simulation is intended to run? Can I programmatically position a background at a particular coordinate without having to manually place it?
2. Several components:
a. Piston (movie clip)
* Q2a: Logically, I supppose I should create movie clips for the different animated components. For example, if I have a cam (or dial) that rotates 45 degrees and another cam will rotate 90 degrees over the same time period do I need to create two separate clips? ...or should I just programmatically rotate them? which is more efficient?
b. Animated indicators (various movie clips)
c. Static components
* Q2c: I am supposing that I will move these static components around, and such...
d. Preloader
* Q2d: A preloader seems essential. Do I need to place this preloader in its own layer? Which frame does it go in? (sorry)
3. Control System for animated components
* Q3: This is where I get hung up. The timeline seems to add great capability to create animations, but, at the same time seems to add the annoyance of poor scalability. Additionally, it seems that if I programmatically control every aspect of the animation with ActionScript, then I am giving up the use of the timeline...or is this a bad assumption?
4. Control system for user interactivity
* Q4: Can I combine the use of the timeline with the use of ActionScript? Logically, it seems like it should work properly, but I have no idea how the event handler of Flash MX functions so it makes it difficult for me to visualize how all of the user interactions will flow.

Any help would be greatly appreciated.
 
Well, here goes...

1. Yes. And yes, But if it is going to remain still, I don't see how it would be necessary.

2.a) Two would be more appropriate. Either scripting, or just having two movie clips with tweening, may be more suitable, depending on how you everything else.

d) It doesn't need to be in its own layer, but it can be useful to keep things organised. It should be at the beginning.

3. & 4. You can combine both the use of the timeline and of actionscript, if need be.



If you want to be able to zoom in, you should probably contain all of the engine's animations in one symbol, so that you can easily manipulate its size and placement.
 
Thanks, but I've already created one component of the animation and run into a snag with how to integrate the timeline and Actionscript. For example,
1.) Animation consisting of three components which need to interface (one constrains the other by limiting its degrees of freedom), components have the following characteristics:
- component "i" is a graphic
- component "ii" is a button with a clickable area
- component "iii" is a graphic
A.) I wrote a simple piece of Actionscript that allows the three graphic pieces to move according to a set of rules about their motion. Component "ii", when clicked, should trigger a time-based animation (essentially, the focus of the view should zoom into a detailed view of the button component)
* Q1A.) This doesn't seem to work too well. I want the time-based animation of zooming to occur while the Actionscript continues to run the animation of the two other components. However, when I click the button to perform a zoom, this doesn't occur. Ideas? Perhaps I need to control everything within the Actionscript? Also, I have the idea that the "zoom" occurs within a popped-up private window that shows the zoom and detail, and that window could defocus when the mouse is moved. Although, with that option it seems like I need some window routines which don't exist by default in Actionscript (It's like dark-ages C programming).
B.) Timing, timing, timing....
* Q1B.) Where's the event-handling capabilities in Flash? Can I overload an object with my own event handler? Can I time how long it takes to process a particular function or set of functions?
 
* engine cross-section
* pistons (with hydraulics)
* airflow indicators (arrows)
* temperature indicators (arrows)
* pressure indicators (colored regions)

all individual movieclips

yes 1 frame only required and control all movieclips with actionscript. positioning et al with actionscript.

a preloader or not will depend on total kb of download and intented user connection.

always better to control animation with actionscript rather than timeline as its so much easier to make adjustments.

user interactions can be of all the usual forms...sliders, buttons, input boxes etc.

component has a special meaning to actionscript programmers

once you get used to actionscript you find it easy to use and coming from a c background will pick it up in no time (its OOP)

couple of years ago i made some similar engineering animations in director (it was cd based and more to do with power stations) and your post has me thinking about receating them in flash

perhaps i could help more if i had a clearer understanding of the ultimate objectives ?
 
just my 2 bits here....
since i am relatively new to flash as well, within a year or 2, and have only begun coding seriously within the last 6 months, i may have a perspective of how you are looking at flash.

just a couple tips for you in your challenge...
(i am completely assuming you are asking for a beginner tour on movie clip control, if not, no offense intended) heh

you can create your entire movie in one frame, which is the best way i think, create your main five elements as MCs, as bill said, and then nest deeper if necessary individual MCs of smaller components.
i think the scripting you are looking for is to control the movie clips.

you need to know that to call upon an object (MC) to control it with script, it will need an instance name
for ex.

create MC frame one main timeline, call it "pistons"(symbol name) and then in your properties area, type "pistons" in the instance name box.

your MC can now be manipulated by actionScript
(flash 4 your could have used Tell target, might help to look it up)

your path to control the clip is now:

_root.pistons

and now you can tell that clip to dance with a button
(button actions)

on (release){
_root.pistons.gotoAndPlay(2);
}

or, to have your arrows show up to indicate something important about the piston movement at a particular part in the piston animation, put a keyframe and action on the frame where you want to tell the arrow clip to animate:
(MC instance _root.pistons, frame 10)

_root.arrows.gotoAndStop("pointHere");//pointHere being a frame label

with just this small understanding when beginning flash, you can do an amazing amount of things, hope that this could help

cheers
paul

 
Regarding the event model there are several inbuilt events you can work from, the most important one for an animation of this type is most likely going to be 'enterFrame'. You could use this as the backbone of a control script:

Code:
this.onEnterFrame=function(){
doPiston();
doTemperature()
doAirflow();
//etc.
}[code]

...each one of those functions could then control an individual clip.

The timing issues you talked about in controlling the animations' behaviour can be addressed in a couple of ways:

1) getTimer() a read-only property which counts the elapsed time in milliseconds since the movie started...

[code]piston.speed=(getTimer()>3000)? 2 : 5;

2)
Code:
setInterval(functionToCall,millisecondInterval,parametersToPass(optional))[code]

3) or by counting frames in a standard movieclip...

[code]if(temperatureClip._currentframe>=100){
//do stuff
}
 
Thanks all for taking the time to reply to my novice questions. This all gives me lots of ideas.

A few other quick questions along the same line (although, maybe these are RTFMs...):
- If I need to place some elements so that they are "visually" in a nice place, but may not want these components displayed all the time, is there a way to place the element, read its location, and then place it via scripting?
- I've written my control system with all of the inputs, outputs, and datafeeds. Do any of you have experience on the best way to structure such a system so that other elements can interface with it in a scalable way? For example, if I have a Finite Element Analysis module, and I want to link that to the control system without having to modify the behavior of any of the constituent elements, is that done? I think I'm thinking along the lines of classes and templates, but it would help if someone out there could reorient my thinking so that I could more easily think in terms of the Flash object model (which, frankly, isn't really jumping out at me).
 
items on stage are easily moved around with actionscript. refer to the object by its instance name and you have control over its properties. x y co-ords visible or not etc

if you look in the actionscript dictionary you can find a lists of predefined properties for different objects (movieclips, sounds, textfields and so on)

you can also create/define your own objects and give these objects whatever properties are required

flash also supports the creation of classes and superclasses.


has some excellent tutorials (mx) dealing with objects, listeners (sounds like you will probably require these) and classes, and a read through a couple could only help to clarify things in your mind.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top