Skip to main content
June 17, 2010
Answered

Scripted Motion alternates

  • June 17, 2010
  • 1 reply
  • 2265 views

I defined 2 different motions for an object in Flash, saved them as Presets and then copied each as Actionscript 3.0 and

pasted them seperately into a code frame 2 on my timeline. I was thinking that with Actionscript I should be able to select

between two motions given certain conditions.

Here's what I got:

var __animFactory_digitB1_mc:AnimatorFactory;
var __motion_digitB1_mc:MotionBase;

if (theProblem.getNum(2,0).length == 1) {  // motion B1_12()
...

else { // NumberB.length > 1
   if(__motion_digitB1_mc == null) { // motion B1_21()
       __motion_digitB1_mc = new Motion();
       __motion_digitB1_mc.duration = 11;
trace("B1_21 - null");
       __motion_digitB1_mc.addPropertyArray("x", [0,8.14801,15.818,22.9697,29.5378,35.4456,40.6136,44.967,48.4119,50.8517,52.2]);
       __motion_digitB1_mc.addPropertyArray("y", [0,-13.9714,-28.1932,-42.6989,-57.4889,-72.5474,-87.8582,-103.435,-119.244,-135.226,-151.35]);
       __motion_digitB1_mc.addPropertyArray("scaleX", [1.000000]);
       __motion_digitB1_mc.addPropertyArray("scaleY", [1.000000]);
       __motion_digitB1_mc.addPropertyArray("skewX", [0]);
       __motion_digitB1_mc.addPropertyArray("skewY", [0]);
       __motion_digitB1_mc.addPropertyArray("rotationConcat", [0,36,72,108,144,180,216,252,288,324,360]);
       __motion_digitB1_mc.addPropertyArray("blendMode", ["normal"]);
       __motion_digitB1_mc.addPropertyArray("cacheAsBitmap", [false]);
       __animFactory_digitB1_mc = new AnimatorFactory(__motion_digitB1_mc);
       __animFactory_digitB1_mc.transformationPoint = new Point(0.500000, 0.500000);
    } // end null
...

There was a flash motion already defined for the digitB1_mc. The trace statement fired showing this code was

executed. But the default flash motion executed, not this one. I know that at previous times, I have fooled around and got similar code to work. But why not this? It's like it ignores this motion altogether.

Note also: When I remove the default Flash motion and run the test, digitB1_mc does NOT move at all, again

ignoring this code(which the trace stmt says is executing).

What's going on?

Thanks

This topic has been closed for replies.
Correct answer kglad

We're getting close now!

Flash has a problem with

yourtextformatinstance.font=an_tf.fontName;

I rewrote it as:

newFormat.font = an_tf.fontName;

There is no fontName method among the options so I just type it anyway. .fontName.

It works correctly now most of the time. That's a huge improvement. But on the odd

occasion it ignores the 1 parameter to addTarget and behaves as if it's a 0.

But I would have to say it works.


that code should not re-execute.  ie, make sure the code is in a frame that plays once, only.

p.s. please mark this thread as answered, if you can.

1 reply

kglad
Community Expert
Community Expert
June 17, 2010

is there an addTarget() in there?

June 17, 2010

No. I frankly don't understand

what an addTarget does.

// __animFactory_digitB1_mc.addTarget(<instance name goes here>, 0);

is in the Code Flash produced.

? What instance: digitB1_mc?

Thanks in advance!

June 17, 2010

Instance cannot be digitB1_mc. I tried that and got an error message.

What is it?