Solved

AS3 AttachMovie??

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
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…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
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.
Suggested Courses

740 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