Skip to main content
Inspiring
January 11, 2013
Answered

How can I attached a drawn obj to a movie-clip?

  • January 11, 2013
  • 1 reply
  • 735 views

Hi,

I am trying to add a drawn obj to a exisiting moving MovieClip.

Can this be done or do I have to draw the obj inside the MovieClip?

 

obj1.onEnterFrame = function()

{

          if (obj1._x < 500)

          {

                    obj1._x += 5;

          }

          else if (obj1._x > 500)

          {

                    obj1._x = 0;

          };

};

createEmptyMovieClip("drawnbox",getNextHighestDepth());

drawnbox.beginFill(0x00FFFF);

drawnbox.moveTo(0,0);

drawnbox.lineTo(50,0);

drawnbox.lineTo(50,50);

drawnbox.lineTo(0,50);

drawnbox.lineTo(0,0);

drawnbox.endFill();

drawnbox.cacheAsBitmap = true;

I tried this but no effect:

obj1.attachMovie("obj2","obj2",_root.obj1.getNextHighestDepth());

Cheers P.

This topic has been closed for replies.
Correct answer Ned Murphy

The attachMovie method is for loading content from the library thru the use of linkage identifiers. 

I do not see the connection in what you show between the movieclip that you create and draw in versus the "obj2" you try to use attachMovie with.

If you want to have the drawing put inside obj1, then create the movieclip inside obj1 and draw into it...

obj1.onEnterFrame = function()

{

          if (obj1._x < 500)

          {

                    obj1._x += 5;

          }

          else if (obj1._x > 500)

          {

                    obj1._x = 0;

          };

};

obj1.createEmptyMovieClip("drawnbox",obj1.getNextHighestDepth());

obj1["drawnbox"].beginFill(0x00FFFF);

obj1["drawnbox"].moveTo(0,0);

obj1["drawnbox"].lineTo(50,0);

obj1["drawnbox"].lineTo(50,50);

obj1["drawnbox"].lineTo(0,50);

obj1["drawnbox"].lineTo(0,0);

obj1["drawnbox"].endFill();

obj1["drawnbox"].cacheAsBitmap = true;

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
January 11, 2013

The attachMovie method is for loading content from the library thru the use of linkage identifiers. 

I do not see the connection in what you show between the movieclip that you create and draw in versus the "obj2" you try to use attachMovie with.

If you want to have the drawing put inside obj1, then create the movieclip inside obj1 and draw into it...

obj1.onEnterFrame = function()

{

          if (obj1._x < 500)

          {

                    obj1._x += 5;

          }

          else if (obj1._x > 500)

          {

                    obj1._x = 0;

          };

};

obj1.createEmptyMovieClip("drawnbox",obj1.getNextHighestDepth());

obj1["drawnbox"].beginFill(0x00FFFF);

obj1["drawnbox"].moveTo(0,0);

obj1["drawnbox"].lineTo(50,0);

obj1["drawnbox"].lineTo(50,50);

obj1["drawnbox"].lineTo(0,50);

obj1["drawnbox"].lineTo(0,0);

obj1["drawnbox"].endFill();

obj1["drawnbox"].cacheAsBitmap = true;

pa-pavelAuthor
Inspiring
January 15, 2013

Ty fir the reply! rly appriciate it! Pavel

Ned Murphy
Legend
January 15, 2013

You're welcome