Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Actionscript 2.0 - waiting for a non-timeline event to complete

Posted on 2007-10-08
3
Medium Priority
?
1,224 Views
Last Modified: 2010-08-05
Hi there! I'm working with a custom class called ImageBox. I'm using it to create a sort of image viewer. There will be multiple instances of these ImageBox objects on stage, and I want to be able to control their behaviour through actionscript.

I am creating a number of methods on ImageBox that do various visual effects. For example, I have a method that will cause the image to flash to white, another will blur the image, another will scale the image to full screen size, and so forth. I'm making extensive use of the Tween class to do these effects, rather than the timeline.

Now I'm looking for an elegant way to string all these actions together in sequence. Once I've imported the class into my main flash movie, I want to be able to do the following in a timeline script:

my iBox = new ImageBox();
iBox.flashImage();
iBox.zoomImage();
iBox.blurImage();

The intended result being that the image flashes, then zooms, then blurs.

Of course, right now, all three effects will happen more-or-less simultaneously.

What's an elegant way of making each effect wait until the previous one has completed before starting? I'm thinking every time you call an effect method on an ImageBox object, that method goes into a queue. The first one processes, then when it's complete, the next one kicks in.

I anticipate that for all Tween-based effects, you would make use of an onMotionComplete() callback.

It would also be nice to be able to build in a delay between subsequent "effects".

Anyone seen this before or want to take a crack at it? I'm sure I can do it, but before I start, I'd love to get another expert's Best Practice. How would you manage the queue? How would you make the system as flexible as possible and the interface as elegant as possible?

Thanks for your insights and creativity!

Tom
0
Comment
Question by:tomaugerdotcom
2 Comments
 
LVL 14

Accepted Solution

by:
trigger-happy earned 1500 total points
ID: 20037357
I suggest you use the fusekit, it does exactly what you want and more: http://www.mosessupposes.com/Fuse/
Just take your time to learn it a bit, because it's definitely worth it.

--trigger-happy
0
 
LVL 14

Author Comment

by:tomaugerdotcom
ID: 20185925
I'm not feeling the love for a third-party tool with its own complicated API as a solution, but since it's the only one I got, I'll grant trigger the points to close off the question.

I resolved the issue by building my own toolset with a dispatcher method that read in an array of arrays. Each array was a "command" - essentially the name of a private method on the object, for example "blur" or "fade", and followed by the parameters for that method, and a delay value.

The dispatacher would then see if there already was an "action" in progress, in which case it would do thing, otherwise, it would shift the first command off the queue and execute it.

Each private "action" method had a completion state that triggered a cleanup event. Part of the responsibilities of that cleanup event was to check the dispatch queue and if there were other commands in the queue, it would then process the next one via the dispatcher.

The dispatcher was also responsible for handling the delay. If a delay parameter was provided and the last "command" was just completed, it would initiate a timer event for the duration provided by that action's delay parameter.

Hope this is useful to someone out there,

Tom
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question