views:

22

answers:

1

Hi everyone!
I'm a new mem of as3. Today i make a work but i was stacked. pls help me:
My example:

• I have a Symbol in Library with linkage name: box_mc

import flash.display.MovieClip;
import flash.events.Event;
import Src.smoothAnimate;

var box_is:MovieClip = new box_mc();
box_is.name = 'box_na';
addChild(box_is);

var box_is:smoothAnimate = new smoothAnimate();  // ERROR 1151 HERE

• i have a custom class :

package Src
    {
    import flash.display.*;
    import flash.events.Event;

    /**
     * ...
     * @author Trunglvt
     */
    public class smoothAnimate extends MovieClip
    {
        private var currentW:Number;
        private var currentH:Number;
        private var endX:Number;
        private var endY:Number;
        private var sp:Number;
        function smoothAnimate() {
            trace('trace');
        }

        public function changeSize(speed:Number, newW:Number, newH:Number) {
            trace('test');
            this.endX = newW;   // get new size
            this.endY = newH;
            this.sp = speed;

            this.addEventListener(Event.ENTER_FRAME, onFrame);  
        }
        private function onFrame(e:Event) {
            e.target.currentW = e.target.width;
            e.target.currentH = e.target.height;

            e.target.width += (e.target.endX - e.target.currentW) * e.target.sp;
            e.target.height += (e.target.endY - e.target.currentH) * e.target.sp;

            if (Math.floor(e.target.width) == Math.floor(e.target.endX) ||
                Math.floor(e.target.height) == Math.floor(e.target.endY)) {
                //stop function enterFrame here;
                removeEventListener(Event.ENTER_FRAME, onFrame);
            }
        }
    }
}

but when run is make error:

1151: A conflict exists with definition box_is in namespace internal.

i want when flash run, the box_is will be add in stage, resize by function changesize.

Pls help me. Thank you.

+2  A: 

When you say:

var box_is:smoothAnimate = new smoothAnimate();

This declaration will error. You previously declared box_is when you said:

var box_is:MovieClip = new box_mc();

Two var cannot have the same name in the same scope.

If you want to reuse the box_is symbol, don't use var. Just reassign box_is:

box_is = new smoothAnimate();
Gunslinger47
thankyou for edited my incorrect question :).and thankyou for you answer :). i done!. thank you.
Rueta