Solved

AS3 AttachMovie??

Posted on 2008-06-19
3
1,208 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
  • 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
FLV versus SWF 11 283
What process can I use to achieve this? 5 124
How to block online streaming via TMG2010 ? 2 134
Adobe Flash player - Microsoft Edge 9 177
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
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…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

828 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