开发者

How to manipulate with symbol on stage from document class without creating a new instance

开发者 https://www.devze.com 2023-04-05 11:34 出处:网络
So I have one movie clip on stage rect_mc and document class Main.as ... I can import movie clip to document class with

So I have one movie clip on stage rect_mc and document class Main.as ... I can import movie clip to document class with

import rect_mc;

and create a new instance

public var rect:rect_mc = new rect_mc();
addChild(rect);
开发者_开发知识库

but is there any way to manipulate rect_mc without craating new instance and attaching it to a stage with addChild()


I am note sure what your question is. If you have the MovieClip on stage you can access it by its instance name. You dont need to create a new instance.

package
{
    import flash.display.MovieClip;
    import flash.display.Sprite;

    public class Test extends Sprite
    {

        // you need to define a variable for the MovieClip 
        public var myRect : MovieClip; 

        public function Test()
        {
            super();

            // Access the MovieClip any way you want by its instance name.
            myRect.scaleX = 3.8; 
        }


    }
}

If you are not going to instantiate any more instances of the MovieClip then you can get rid of the linkage and export properties for the MovieClip.


You can't manipulate rect_mc without creating an instance of it, but you don't actually have to add it to the stage before you do anything. You can still position/scale/rotate/whatever, you just won't see it

0

精彩评论

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

关注公众号