07.30
Today I was working with an animation that a designer had built, and converting it into a format that could be translated into several languages. The designer had built a bunch of animations on the timeline, and several of the timeline animations had embedded text fields that needed to be regionalized via XML. My first idea was to copy the motion of these timeline-animated text fields using the “Copy Motion as ActionScript 3.0…” right-click option. This takes the timeline animation and converts it into an instance of the Motion animation engine. My idea was that I could generate my regionalized text field dynamically based on the language on the host computer, and pass this text field to the generated animation code as the target. This sounds all well and good, until you actually try to use the code that it generates.
When running the code, you will get the following error:
ReferenceError: Error #1069: Property instance1 not found on [class path] and there is no default value.
Where “instance1″ can be anything from “instance1″ to “instance99″ or higher. It’s as if the Animator class is looking for the declaration of the object instance and it’s not getting created. I thought at first that it had something to do with the Automatically declare stage instances setting, but it doesn’t make a difference if it’s checked or not.
People have logged this bug here on the Adobe Bugs database.
I stumbled on to this by accident. I don’t have access to the adobe bugs database; I don’t know if they found the solution to this or not. Here is what I found. If you put the targeted mc inside of a container mc, then the targeted mc can receive the motion actionscript without throwing the error. Example:
package com {
import flash.display.MovieClip;
import flash.events.MouseEvent;
//motion
import fl.motion.AnimatorFactory;
import fl.motion.MotionBase;
import flash.filters.*;
import flash.geom.Point;
public class Main extends MovieClip {
internal var mcContainer:MovieClip;//container mc
internal var box:MovieClip;//targeted mc
public function Main(){
mcContainer = new MovieClip();
box = new Box();
box.addEventListener(MouseEvent.MOUSE_DOWN, boxOver);
mcContainer.addChild(box);
addChild(mcContainer);
}
internal function boxOver(evt:MouseEvent){
var __motion_box_2:MotionBase;
if(__motion_box_2 == null) {
import fl.motion.Motion;
__motion_box_2 = new Motion();
__motion_box_2.duration = 10;
// Call overrideTargetTransform to prevent the scale, skew,
// or rotation values from being made relative to the target
// object’s original transform.
// __motion_box_2.overrideTargetTransform();
// The following calls to addPropertyArray assign data values
// for each tweened property. There is one value in the Array
// for every frame in the tween, or fewer if the last value
// remains the same for the rest of the frames.
__motion_box_2.addPropertyArray(“x”, [0]);
__motion_box_2.addPropertyArray(“y”, [0]);
__motion_box_2.addPropertyArray(“scaleX”, [1.000000]);
__motion_box_2.addPropertyArray(“scaleY”, [1.000000]);
__motion_box_2.addPropertyArray(“skewX”, [0]);
__motion_box_2.addPropertyArray(“skewY”, [0]);
__motion_box_2.addPropertyArray(“rotationConcat”, [0]);
__motion_box_2.addPropertyArray(“blendMode”, ["normal"]);
__motion_box_2.addPropertyArray(“tintColor”, [0x0049ff]);
__motion_box_2.addPropertyArray(“tintMultiplier”, [0.000000,0.111111,0.222222,0.333333,0.444444,0.555555,0.666667,0.777778,0.888889,1.000000]);
// Create an AnimatorFactory instance, which will manage
// targets for its corresponding Motion.
var __animFactory_box_2:AnimatorFactory = new AnimatorFactory(__motion_box_2);
__animFactory_box_2.transformationPoint = new Point(0.500000, 0.500000);
// Call the addTarget function on the AnimatorFactory
// instance to target a DisplayObject with this Motion.
// The second parameter is the number of times the animation
// will play – the default value of 0 means it will loop.
__animFactory_box_2.addTarget(box, 1);
}
}
}
}
wow, thanks b_trout.
I can’t believe that worked.
b_trout U JUST SAVED MY LIFE …. THANKS man who ever u are !!! I love you man ! it worked !!!!! I was about to lose my mind.
b_trout TNX!!!!!