Results 1 to 7 of 7

Thread: copy motion as moviescript into a class

  1. #1
    37
    posts
    Registered User

    copy motion as actionscript into a new mc class

    Good day, kind sir's. I have a quick question..

    Why doesn't this work:

    i have a class that extends movieclip, then in it i put a "move" function that runs when an instance of the class is added (event.ADDED).

    Then, i created that class in the main time line, created a keyframe, made a motion tween and stuff, then copied those frames as action script.

    In the "move" function, i pasted the above motion code.

    However... when i run it, it doesn't move =(

    i placed trace functions before and after the pasted coded and both of them were working properly... what step am i missing?

    i already imported:
    import flash.display.*;
    import flash.events.*;
    import fl.motion.Animator;
    import fl.motion.*;
    into the class btw..

    thanks for your time
    Last edited by zoink; September 3rd, 2008 at 01:35 PM.

  2. #2
    37
    posts
    Registered User
    anyone?

  3. #3
    We're not psychic. You need to paste your class, not just the import statements (that are wrong btw, never use .* unless you're actually USING every single class in the package...)

  4. #4
    37
    posts
    Registered User
    Sorry about that... here it is:

    package com.fred.stuff
    {
    import flash.display.*;
    import flash.events.*;
    import fl.motion.Animator;
    import fl.motion.*;


    public class TestExperiment extends MovieClip
    {

    public function TestExperiment():void
    {
    this.addEventListener(Event.ADDED, swirl);
    }

    function swirl(event:Event):void
    {

    trace("TestExperiment, Swirl");
    import fl.motion.Animator;
    var this_xml:XML = <Motion duration="20" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
    <source>
    <Source frameRate="12" x="162.35" y="134.35" scaleX="1" scaleY="1" rotation="0" elementType="movie clip" symbolName="testMotion" class="com.fred.stuff.testMotion">
    <dimensions>
    <geom:Rectangle left="0" top="0" width="38" height="32"/>
    </dimensions>
    <transformationPoint>
    <geomoint x="0.5" y="0.5"/>
    </transformationPoint>
    </Source>
    </source>

    <Keyframe index="0" rotateDirection="cw" rotateTimes="1" tweenSnap="true" tweenSync="true">
    <tweens>
    <SimpleEase ease="0"/>
    </tweens>
    </Keyframe>

    <Keyframe index="19">
    <color>
    <Color alphaMultiplier="0"/>
    </color>
    </Keyframe>
    </Motion>;

    var this_animator:Animator = new Animator(this_xml, this);
    this_animator.play();


    }

    }
    }

    the whole bunch of stuff inside swirl function was the pasted code using "copy motion as action script"


    in my main class, i have:



    import com.fred.stuff.TestExperiment;
    var testExperiment:MovieClip;


    testExperiment = new TestExperiment();
    addchild(testExperiment);


    When i run it... the trace in swirl works... but the copy pasted code doesn't work... The testExperiment just sits in the stage... =(

  5. #5
    37
    posts
    Registered User
    help anyone? i'm not really one who likes to bother others.. but i really need help on this one >_< thanks in advace

  6. #6
    try:
    Code:
    animator = new Animator(animatorXML,this.getChildAt(0));

  7. #7
    37
    posts
    Registered User
    thanks for the reply Felixz! I figured it out though... apparently i had to declare the animator instance outside of the function so i put

    var this_animator:Animator;


    outside all the functions of my TestExperiment class.

    I still don't know why i have to do that though X_X but thanks for your help ^_^

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012