Solved

AS3 AttachMovie??

Posted on 2008-06-19
3
1,210 Views
Last Modified: 2012-05-05
Hi Folks,

I have a button the library and I want to attach it dynamically to the position x:100, y:100. How do we do it in AS3

Any sample is greatly appreciated

Thanks

RG
0
Comment
Question by:rgarimella
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Expert Comment

by:ugeb
ID: 21827567
Hi,

I'n not exactly sure what you mean by "attach dynamically to the position".  Do you mean move the button to that position?

If so, it's simply:

mybutton.x = 100;
mybutton.y = 100;

where mybutton is your instance name.  If you mean something else, please clarify.

HTH
Gene




0
 

Author Comment

by:rgarimella
ID: 21827581
Hi

I have a button in the library named CA

I wanted it to attach it dynamically from the library to the position

In AS2 attachMoveClip was used dont know how to do in AS3

RG
0
 
LVL 11

Accepted Solution

by:
ugeb earned 500 total points
ID: 21827631
Okay, I understand.  Your terminology is a little confusing, though.

In AS3, you use the addChild() method to attach movie clips, buttons, etc.

attachChild(CA);

will add the button CA as a child of the main timeline, but you could add it as a child of whatever you want.  

Then, after adding it, use the above code to position it:

CA.x = 100;
CA.y = 100;

This assumes CA already exists as an instance.  If CA is a class in the library, then you have to instantiate the class, and do what I showed above:

mybutton = new CA();
addChild(mybutton);
mybutton.x = 100;
mybutton.y = 100;

Note that you must export CA to actionscript to be able to use it in AS.  In the library, click on CA, then click on the library menu and choose linkage,  in the popup choose 'export to actionscript'.





0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to record live broadcast.

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question