473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Attaching a animation to a movie clip and calling it later

This is a project I have been working on lately and I keep running into problems.
The idea is to be able to attaching an animation to a movie clip and call it later. Or multiple animation at once.

example:
on the stage you have a black box called: myClip
in actionscript you type:
growClip = grow(myClip);
spinClip = spin(myClip);

now when you call:
growClip.run();
spinClip.run();
myClip will grow and spin.

These function are ran with setinterval but when I do this myClip only spins.

the function grow looks like this:
Expand|Select|Wrap|Line Numbers
  1. grow = function(mc,opts){
  2.     //opts == object containing required vars
  3.     opts.dir = (opts.dir > 0 || opts.dir == 0)?1:-1;
  4.     id=random(10000);
  5.  
  6.     mc["attach_animation"+id] = {}
  7.     co = mc["attach_animation"+id];
  8.     co.grow = {}
  9.     //Start: effect creation
  10.         co.grow.run = function(){
  11.             mc._xscale = mc._yscale = (opts.dir > 0)?0:100;
  12.             co.grow.growID = setInterval(co.grow.effect,5);
  13.         };
  14.         co.grow.kill = function(){
  15.             if(mc._xscale < 1) mc._visible = false;
  16.             mc._xscale = mc._yscale = 100;
  17.  
  18.             clearInterval(co.grow.growID);
  19.             delete co.grow;
  20.             trace("motion complete");
  21.         };
  22.         co.grow.effect = function(){
  23.             mc._xscale += opts.dir; 
  24.             mc._yscale = mc._xscale;
  25.             if(mc._xscale < 1 || mc._xscale > 100){
  26.                 co.grow.kill();
  27.             }
  28.         };
  29.         co.grow.growID = 0;
  30.  
  31.     //END: effect creation
  32.     return co.grow;
  33. }
  34.  
  35. growthis = grow(myClip,{dir:1});
  36. shrinkthis = grow(myClip,{dir:-1});
  37. growthis.run();
  38.  
The idea for the above code is from Adobe Spry framework

Does setInterval cancel if they are applied together?
Sep 6 '07 #1
1 1813
Well,

This is depressing because I have found that everything I was trying to do has already been done for you by Adobe (and of course done better).

I guess I am answering my own question here.
If anyone cares all you have to do is:

Expand|Select|Wrap|Line Numbers
  1. //your movie clip is named "myClip"
  2.  
  3. import mx.transitions.*;
  4. import mx.transitions.easing.*;
  5. TransitionManager.start(myClip, {type:Zoom, direction:Transition.IN, duration:2, easing:Elastic.easeOut});
  6.  
  7. //or
  8.  
  9. grow = new new TransitionManager(myClip);
  10. grow.startTransition({type:Zoom, direction:Transition.IN, duration:2, easing:Elastic.easeOut});
  11.  
  12. /*
  13. There are lots of these with differant easing just search "TransitionManager" in the flash Help under "Components Language Reference" book
  14. */
  15.  
  16. -J
  17.  
  18.  
  19.  
Sep 24 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: torbs | last post by:
I have a problem when I use javascript to get the length and position of a movie I recieve from a rtsp stream. The length and position is extremely high and not the actual length and position of...
4
by: petermichaux | last post by:
Hi, Is there any way to make DOM scripted animation smoother? Flash is far superior in this area. Any one here know what makes Flash so smooth by comparison? I don't like the fact that the...
10
elamberdor
by: elamberdor | last post by:
Hello All! Well, I can load in swf's just loverly, but what I have is a sliding menu, with buttons in it, that when pressed, load an image into an empty movieclip. I really just need to know how...
0
by: RLW | last post by:
Hi, I inherited a Flash usability problem: It's a self assessment test created in Flash. I think it was originally built using individual flash files for each question and arrays. Now it has...
2
by: robtyketto | last post by:
Greetings, I have workable code to allow movie clips to be dragged around. However I can't find an example of a drag n drop where the movie clip has to be placed with a certain range/xy...
4
by: Sin Jeong-hun | last post by:
Most applications, including Windows Explorer, show some sort of 'wait' dialog with animation when a lengthy operation is going on. For example, When the Windows Explorer is searching for...
1
Fary4u
by: Fary4u | last post by:
Hi i'm trying to design the picture gallery ever thing works fine but whn i've make test movie or export the swf file it's runs fine but problme i'm using this with in movie clip & i think...
1
by: gusheneshin | last post by:
hi everyone im Using this code to Creat a Movie Clip and load a movie "SWF" into this Flash ------------ stop(); loady._x = 226.4;this.createEmptyMovieClip("loady",5);
1
by: angelicdevil | last post by:
ok wat i m trying to do it get flash to read a xml file and load the titles in xml as a button into the imagetitles movie clip made on stage in flash . so that when i click on a title it displays...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.