?
Solved

AS3 AttachMovie??

Posted on 2008-06-19
3
Medium Priority
?
1,220 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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

777 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