开发者

Error #1034 with Document Class

开发者 https://www.devze.com 2023-04-12 12:42 出处:网络
Hello I got a little class and all works fine. Then I add it in Document Class and puff, Error 1034 happens.

Hello I got a little class and all works fine. Then I add it in Document Class and puff, Error 1034 happens.

Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@2be9dba1 to fl.text.TCMText. at flash.display::Sprite/constructChildren()

at flash.display::Sprite()

at flash.display::MovieClip()

at Wyjazd()

at Wyjazd/wyskok()

My class Code.

package 
{
    import fl.transitions.Tween;
    import fl.motion.easing.*;
    import flash.filters.*;
    import flash.events.MouseEvent;
    import flash.display.Stage;
    import flash.display.MovieClip;

    public class Wyjazd extends MovieClip
    {

        public function Wyjazd(ar:Array=null)
        {
            if (ar!=null)
            {
                init(ar);
            }
        }

开发者_StackOverflow        public function init(ar:Array):void
        {
            var time:Number = 0.2;
            var offset:Number = 0;
            var posX:Array = new Array(12);
            for (var i:Number = 0; i < ar.length; i++)
            {

                var tween:Tween = new Tween(ar[i],"x",Sine.easeOut,ar[i].x,266.65 + offset,time,true);

                ar[i].addEventListener(MouseEvent.CLICK,onClick);
                posX[i]=ar[i].x;
                time +=  0.02;
                offset +=  15.25;
            }


            function onClick(e:MouseEvent)
            {
                time = 0.2;
                for (var i:Number = 0; i < ar.length; i++)
                {
                    var tween:Tween = new Tween(ar[i],"x",Sine.easeOut,ar[i].x,posX[i],time,true);      
                    time +=  0.02;
                }
            }

        }

    }
}

And the Frame Code:

import flash.events.MouseEvent;
import fl.transitions.Tween;
import flash.display.MovieClip;
stop();
ofertaBTN.addEventListener(MouseEvent.CLICK, wyskok);
function wyskok(e:MouseEvent)
{
     var vektor:Array =new Array (I,II,III,IV,V,VI,VII,VIII,IX,X,XI,XII);
     var menu:Wyjazd = new Wyjazd(vektor);
}


I can't say for sure with out looking at your .FLA but...

Based on the error your getting you are trying to convert Text (your vektor array(I,II,III,...) to a MovieClip and flash won't let you do that. You can not Tween non-display objects.

I am going to assume that you are trying to target instances that are on the stage whose instance names are I, II, III, IV, V,...

Instead of building the array in the frame try building it in the document class. I built a simple example here that works:

package  {

    import flash.display.MovieClip;
    import flash.events.Event;
    import fl.transitions.Tween;
    import fl.motion.easing.*;


    public class arrayInst extends MovieClip {

        public var allInstanceReferences:Array;

        public function arrayInst() {
            // constructor code

            allInstanceReferences = new Array(I, II, III, IV, V);
            this.addEventListener(Event.ENTER_FRAME, moveAllReferences);
        }

        private function moveAllReferences(e:Event):void{
            for (var i:uint = 0; i < allInstanceReferences.length; i++){
                var tweenThis:Tween = new Tween(allInstanceReferences[i], "x", Sine.easeOut, allInstanceReferences[i].x, 250, 2, true);
            }
        }
    }

}

My allInstanceReference array contained references to a TLF Textfield [I] and a MovieClip[II - V] and all objects moved with out issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号