Solved

AS3 AttachMovie??

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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 last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
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 select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now