2

I guess this is a question for real gurus only..

I'm using the Flash Authoringtool to create MovieClips, yet I play them using my own engine (which behaves better for mobile).

Yet, for proper behaviour, given a DisplayObject, I need to know if its parent is tweening it inside the MovieClip it is part of.

I've already come up with Brute-force and non-elegant ways to do that:

  • In the authoring tool, add a prefix to the name of any movieclip that is subject to tweening. That name prefix can be checked lateron at any moment. Of course, as this prefixing is a manual process, it's easy to forget or mistype one.

  • In the code, play each sub-movieclip of the main movieclip for all of its frames, and for all of its children, detect if the transformation matrix changes at any of these frames. If so, automatically prefix their names. Although automized, this solution may take up noticable time for larger movieclips.

So what I'm hoping for is that some other way exists like:

if((dpo.parent) as MovieClip) != null)
{
    bDpoIsBeingTweened = ((dpo.parent) as MovieClip).someProperty;
}

Looking forward to any elegant solution.

taskinoor
  • 45,586
  • 12
  • 116
  • 142
  • I don't know how flexible your animations should be...would using sprite sheets make sense ? Also, are the animations created from code or in the Flash Authoring timeline ? – George Profenza Oct 04 '13 at 23:52
  • The animations are created using the Flash Authoring timeline (because I like the WYSIWYG approach). The only kind of tweens I use in it, are motion tweens. Software of my own then transforms it into what I call a "MovieClipInterpolator" object. For a selected framerate, it calculatates all positions/rotations/scalings/alphas for all interpolated sample-points. The topic adressed here is how to find the animated subclips, such that everything below the lowest ones can be cached into bitmaps automatically. – Marius Versteegen Oct 05 '13 at 18:17
  • I'm starting to understand more. I'm guessing your best best would be whipping out a [JSFL script](http://help.adobe.com/en_US/flash/cs/extend/flash_cs5_extending.pdf), scripting Flash Authoring, to recursively drill down the selected movie clip's hirarchy, traverse timelines/frames and check frame's `tweenType` property (e.g if it's value is `motion` as opposed to `shape` or `none`). Also, i you want to extract values from the motion tween programatically, you might find the [Motion XML structure](http://flashthusiast.com/2008/11/04/understanding-flash-cs4-motion-xml/) useful – George Profenza Oct 05 '13 at 21:11
  • I see.. and after parsing that data, pack it with my swf. Eheheh.. I guess that's indeed a possible solution. A real guru-answer indeed. I applaud it, and I know I should not whine about it, but as I'm not that much of a guru myself, for me such a complex project could easily take one or two weeks. I'm still hoping for someone to come up with a simple runtime solution, although I'm starting to realize that it's unlikely to exist. – Marius Versteegen Oct 07 '13 at 07:17

1 Answers1

1

The solution is quite simple: stop using Adobe's tweening library.

Use TweenLite which is hundreds of times faster, easier to code, and has many other benefits. For example being able to use isTweening to determine if some object is being tweened or not.

Here's the documentation.

To include external libraries in the Flash IDE you can do it in 2 ways.

1) Copy the folder of the external library in your project folder (where your .fla file is)

2) Define a folder in "File > Actionscript settings" where you want to put external libraries files in your hard disk.

Then in your code you just need to import those classes with import. For example:

import com.greensock.TweenLite;
Pier
  • 10,298
  • 17
  • 67
  • 113
  • While this will work for request, the other limitation X's this idea - he has to develop MCs in authoring engine, no TweenLite there. – Vesper Oct 04 '13 at 17:13
  • It's very easy to add external libraries to projects made in Flash IDE. you can either define a library path for your AS files, or just copy the AS files in your project folder. – Pier Oct 04 '13 at 23:40
  • I mean that you cannot designate a TweenLite object to tween parts of the MC, only native tweens, this makes them unavailable to be iterated via TweenLite. – Vesper Oct 05 '13 at 03:38
  • For what I am aware of by now, I have to agree with Vesper: After some studying of the docs of TweenLite (which seems to be a very cool library indeed) - I didn't see how they could replace the tweens from the authoring tool. Only by hardcoding them, but that would lose the WYSIWYG advantage. – Marius Versteegen Oct 05 '13 at 18:24