Previously I blogged about using the new Copy Motion to ActionScript 3 feature. Now I I would like to show you how to take that feature and extend it to Flex.
I have included my FFanimaotr flex project that has a working sample of this. You must have Flex and Flash CS3 installed for this to work since we need the Animator class that ships with Flash CS3. Just import the project to Flex and it should work.
Here is the Flex code:
|
<?xml version="1.0" encoding="utf-8"?> <mx:HTTPService url="{ combo.selectedItem + ‘.xml’ }" resultFormat="e4x" id="xmlService"/> <mx:Script>
<
Ok, so how does this work? simple, you just run the same AS3 code that I showed before (in Red). Except this time you tell it to animate a Flex component. In this case I am using the calendar component, but feel free to replace it with any component (SWFloader, VideoDisplay, etc) just make sure to give it an ID of "moveThis".
The only thing I am doing a bit different than what I did in my Flash CS3 example is calling Animator’s rewind function. as in:
if (my_animator) my_animator.rewind();
I am doing this so that when you select a different animation the component you are animating doesn’t continue from where it finished and fly off the page.
My example is actually more complicated than it needs to be. I am using a combo box with two animations you can select from. When one is selected it calls my animate function with in tern loads the XML file and then uses the Animator class to apply the animation to any component that has an ID of "moveThis". The beauty is that its all at runtime.
Play around with it. See what you can do with it and if you think you have something cool please share.

I am getting 1180 errorType was not found or was not a compile-time constant: Animator
It’s nice to see a sample of Copy Motion used outside of an FLA. Nice integration with Flex!Cheers.
This is how we did the Motion XML Previewer over at http://www.motionxml.com – give us feedeback!
Hi!is there any revealable inside info about the flash-to-illustrator export issue? (the fact that there is no way to move complex paths from flash to ai without destroying vectors/colors) Fixing that would change many lives!thanx
This is great. Maybe i wont have to mess about with those darn flex effect so much now.Big question thow, is there a way to set props for the flash animation from flex? …Like say i make a tween in flash that moves a component along a curvy motion guide path. Could i set the start and end point from flex. maybe even use it in a custom effect and set it as a components moveEffect???That would be stunning!!!
Thank-You Galvan, this is exactly what I was looking for.jdd
thanks man,it really helped me.I also managed to use it with flex component move effect.the idea is to create an fl.motion object using an XML file and to interpolate it within penner easing function.