Centered placing of a mc onto another via action script

Hello,
i have problems to place a mc object (any rectangle) centered
onto another mc object (any rectangle) via as-code. Via the polar()
method it is possible to translate points with a certain distance
and angle. I tried with that method to place the first rectangle
centered onto the second rectangle. It works fine for an angle of 0
degrees for the second rectangle. But if you change the angle of
the second rectangle the determination is no more correct.
Can someone someone help me?
You just have to create 2 rectangles as movieclips in a flash
document and name them as "draggedObject" and "dropObjects". Then
attach the following as-code and try out:
draggedObject.x = dropObjects.x; // draggedObject is the red
rectangle, dropObjects the blue rectangle
draggedObject.y = dropObjects.y;
var angle1 = dropObjects.rotation;
angle1 = 2 * Math.PI * (angle1 / 360);// angle to Bogenmass
draggedObject.rotation = dropObjects.rotation;
var newPoint = Point.polar(dropObjects.width/2 -
draggedObject.width/2, angle1);
draggedObject.x = draggedObject.x + newPoint.x;
draggedObject.y = draggedObject.y + newPoint.y;

well, there are several ways to align objects on the stage.
1) construct the objects so that thier registration points
are in the center of the object, then either can be aligned to the
center 0,0 of the other, and rotated about that point.
2) if the objects registration point is in the upper left
corner, use the Stage's width and height properties to align the
obects to the center, by setting the _x position of the object by
subtracting the width of the object from the width of the Stage and
dividing the result by two. do this again each time you rotate an
object, as the bounding box is changed to accomidate the entire
bounds of the shape, after rotation occurs.
AS2: draggedObject._x += (Stage.width - draggedObject._width)
/ 2;
AS3: draggedObject.x += (stageWidth - draggedObject.width) /
2;
(I am uncertain if this is the correct method of calling of
the AS3 'stageWidth' property here, as I'm new to AS3)
3) there are more ways to accomplish this, but this should be
enough for now.

Similar Messages

  • Another aborted Action Script

    I'm making a slideshow about 18 images in all 9 thumbnails and 9 full size images. The problem I keep running into is the "a script in this movie is causing flash player 9 to run slowly" error. The Flash is set to player 9 and action script 2.0. I have followed the uninstall reinstall tips in other threads and even tried it on another machines, ultimately coming up with the same results. I have read that there could possibly be too much script on the single frame so that said here is the script that is all on that first and only frame.
    this.createEmptyMovieClip("container",1);
    var imagesNumber:Number = 9;
    for (i=1; i<=imagenumber; i++) {
    container.attachMovie ("Cakethumb0"+i, "Cakethumb0"+i+"_mc",i);
    Cakethumb_mc = container ["Cakethumb0"+i+"_mc"];
    Cakethumb_mc._x =(i-1) *Cakethumb_mc._width;
    Cakethumb_mc._y = (Stage.height-Cakethumb_mc.height)/2
    Cakethumb_mc.largerImage = i;
    Cakethumb_mc.onRelease = function() {
    _root.attachMovie ("Cakeimage0"+this.largerImage,"large_mc",2);
    large_mc._x = (Stage.width - large_mc._width)/2;
    large_mc._y = (Stage.height - large_mc. _height)/2;
    large_mc.onRelease = function() {
    this.removeMovieClip();
    container.onEnterFrame = function () {
    this._x += Math.cos((-root._xmouse/Stage.width)*Math.PI)*15;
    if (this._x>0) {
    this._x = 0;
    if (-this._x>(this._width-Stage.width)) {
    this._x = -(this._width-Stage.width);
    I appreciate any help you guys can send my way.

    Is the following a coding error where you declare a variable but misspell it when it gets put to use, or is the variable used somewhere else?
    var imagesNumber:Number = 9;
    for (i=1; i<=imagenumber; i++) {

  • Moving a Layer based on percentages via action scripting.

    Hi,
    I am trying to create an action script that will move a layer 90% to the left or right. Can this be done thru actions or is it something that can only be done via JS Scripting. The reason I need percentages is not all images are the same dimensions.
    TIA

    You should be able to do it with either.
    With an action set you ruler to percent, select all on the layer you want to move and with the move tool move the image. The amount of the move will be recorded in percent.
    With a script use activeDocument.activeLayer.translate( new UnitValue(.9,'%'),undefined) to move to the right or activeDocument.activeLayer.translate( new UnitValue(-.9,'%'),undefined)to move to the left

  • HT201302 Can I tranfer photos from a different computer onto another via an Ipod 5th gen?

    I had saved all of my family photos onto my ipod nano 5th gen. Due to sperstorm sandy I lost my desktop and all of the photos. My ipod is not trasfering the photos from the old computer. Is there really no way to do this? "You can import only photo and video content taken with the built-in camera or captured on the device. You cannot import photo or video content synced from iTunes." - This deeply troubles me. I am able to transfer the videos captured by the Ipod but not my old photos.

    For synced photos you need a third-party program like TouchCopy or PhoneView.

  • How do I transfer my catalog, files and collections into Lightroom 4 onto another computer?

    How do I transfer my catalog, files and collections into Lightroom 4 onto another computer?

    You can copy your image file  from you PC to your Mac over your home network or via DVD/CD.  You can not install you PC CS5.1 version on you Mac. Its not compatible with MAC OS.  You would need a MAC version of CS5.1 and Mac version serial number to activate it.  Adobe no longer markets CS5 so you most likely will not be able to pay for a platform switch media install.

  • How can I send stuff from one iPhone to another via Bluetooth?

    How can I send stuff from one iPhone to another via Bluetooth?

    There are some apps that will let you send photos from one iOS device to another over BT.

  • HT3819 Can I transfer music from one computer to another via home sharing?

    Can I transfer my music from one computer to another via home sharing?

    So long as they are on the same wifi network, yes.
    Have both computers running and have iTunes open on both computers.
    Now, in the iTunes on the computer you want to transfer music to, select the library that you want to transfer music from, as per the following screenshot:
    Once the other library loads, go down to the bottom of the screen and in "Show:" select "Items not in my library":
    If you want to import all of the songs you can now see, head up to the iTunes menu bar and go "Edit > Select all". Then head down to the bottom of the screen again and click the "Import" button in the bottom-right-hand corner.
    If there's a lot of stuff in the library you're transferring from, the transfer may take some time.

  • How do I relocate part of my home folder onto another drive

    Hi all
    I am about to take delivery of my new Mac Pro, but with only 512MB of startup SSD I don't have room for my whole home folder. I have found plenty of info online about moving my whole home folder onto another drive, but as my external drive is only USB3 I don't want to do that. Instead I want to move my Movies and Pictures folders only and then tell my system to forget about the old location and treat the new location as though it is the home folder just for those two bits.
    Sure I can just copy them over and delete the old folder contents, but as soon as I want to do something like save a pic or movie the system defaults to the old empty location.
    It's not the end of the world, but if I can fix it, I'd like to. The plan is to sort this on my current Mac Mini before the new toy arrives, so I can easily set up the new one.
    All guidance gratefully received.
    Regards
    Tim

    Hello,
    You can use some basic unix wizardry to make this happen.  What you will be doing is creating a unix "soft link" from your home directory to the actual location of the directories, wherever they may be.  This link serves as a "behind-the-scenes redirect" to the actual location to which you link.  For example, with the soft link in place, if you
    Here's what you do:
    Use Finder to move your directories of choice from your home directory to the external HDD.  This will require your admin password.  Now you should see the folders on your external HDD, and NOT in your home folder.  For purposes of this procedure, I will assume your external HDD is named "Storage".  Wherever you see "Storage" in the following steps, replace it with the actual name of your external HDD.
    Open the Terminal app.
    From the command prompt, type the following commands (with a <return> after each) to create a soft link (in this example we are using the "Movies" folder.  The "Movies" folder must have been moved in Step 1 to the external HDD):
         cd
         ln -s /Volumes/Storage/Movies Movies
    Repeat the "ln -s" command for each folder that you have moved in Step 1.
    Here's what's happening in Step 3:
    The "cd" command just ensures that you are in your home directory.
    The "ln -s" command creates a link from the external HDD directory, to a directory in your present location (i.e., your home directory)
    There is one side affect that I don't know how to get around.  Once you do this, the icon that shows up for the "Movies" folder in your home directory will no longer be the fancy system icon for the Movies folder.  It will be a vanilla folder icon, with an curved arrow.  The curved arrow is a visual indication that the file/folder is link to somewhere else.
    Hope this helps.

  • My laptop died so I've installed itunes onto another PC and my music is all on an external hardive which is connected to the new PC. How can I sync my ipod with the new itunes and get all the music onto itunes?

    My laptop died so I've installed itunes onto another PC and my music is all on an external hardive which is connected to the new PC. How can I sync my ipod with the new itunes and get all the music onto itunes?

    You might consider itunes match for moving CDs you've copied into your itunes library if you dont have a way to use home sharing.
    iTunes match is an optional service offered by apple that costs about $25 a year.  It scans your music library and if it finds music that is already in apple's itunes catalog it'll automatically "unlock"/"store" these in the cloud for you.  Items that it does not find in the catalog it'll upload and store these in the cloud for you and you can download them on your devices.  See http://www.apple.com/itunes/itunes-match/

  • How to copy an image from a photo onto another photo

    Im trying to figure out how to cut and paste an image from one photo onto another. I tried exporting the main photo to a pages document and then inserting the other image, but cant seem to get it to work. Is there an easy way to do this?

    You'll need an image editor for the job:
    In order of price here are some suggestions:
    Seashore (free)
    _[The Gimp|http://www.gimp.org/macintosh>_ also free
    Graphic Coverter ($45 approx)
    Acorn ($50 approx)
    [Pixelmator|http://www.pixelmator.com> ($60 approx.)
    Photoshop Elements ($75 approx)
    There are many, many other options. Search on MacUpdate.
    You can set Photoshop (or any image editor) as an external editor in iPhoto. (Preferences -> General -> Edit Photo: Choose from the Drop Down Menu.) This way, when you double click a pic to edit in iPhoto it will open automatically in Photoshop or your Image Editor, and when you save it it's sent back to iPhoto automatically. This is the only way that edits made in another application will be displayed in iPhoto.
    Regards
    TD

  • I live in a home with two other people, and one housemate tried to sync up his content from iTunes and iCloud onto another housemate's new iPad. the iTunes library only contains my content. is there any way to retrieve the there person's iCloud?

    i live in a home with two other people, and one housemate tried to sync up his content from iTunes and iCloud onto another housemate's new iPad. the iTunes library only contains my content. is there any way to retrieve the other person's iCloud? Can they go out of my account? Their content is saved on their iPads, but can another iCloud be on the same home computer?

    The syncing of music is one way, computer to phone. See this helpful document from a fellow user. Credit goes to the author.
    https://discussions.apple.com/docs/DOC-3141

  • Copy a group of cost centers from one controlling area to another

    Hello,
    is it possible to copy a group of cost centers from one controlling area to another?
    Or a group of internal orders?
    Thanks
    Jasmina

    No. If you used any upload tools like LSMW, perhaps you may use that for uploading the second controlling area.

  • I have a hard disk drive with data that i want to back up onto another hard disk drive. I tried just copy and it won't let me paste it in the new drive. I have also tried to drag the files across and they won't go across. Does anyone know how to do this?

    I have an external hard disk drive with data that I want to back up onto another extrnal hard disk drive. I have tried to copy and paste but this wont give me a paste option. I have also tried to click and drag but it wont let me either. I have reformatted the external hard drive to accept both mac and pc files and this did not make any difference. Can anyone help me with this?

    How did you reformat the drive? If you formatted it as NTFS, your Mac will not be able to write files to it unless you use a small application such as Paragon's.
    Please reply as to how you formatted the drive.
    Clinton

  • How to copy backup of iTunes library onto another computer?

    My primary laptop with my music library just crashed. I have a older laptop that I plan to use while I get the other repaired. I have a complete backup of my music library on external drive. After installing iTunes on the spare laptop I copied the backup music library to the iTunes music folder. However, when I start itunes, nothing shows up in iTunes. This has probably been discussed but several searches have not found how to recover this. Does anyone know what the process is?
    Thanks

    If you want to backup your iPod onto another computer you can download a program called "iPod to computer transfer" at the following URL:
    http://www.ipod2computer.com/?OVRAW=iPod%20to%20computer%20transfer&OVKEY=ipod%2 0to%20computer%20transfer&OVMTC=standard&OVADID=29342709512&OVKWID=117472586512
    I hope this helps
    GN4GSUS

  • Hi I have two macbook pro, i connected one from another via lan cable , now when i removed it, its showing me some pop up again and again saying server may not exists and there was a problem connecting to ishan's macbook pro

    Hi I have two macbook pro, i connected one from another via lan cable , now when i removed it, its showing me some pop up again and again saying server may not exists and there was a problem connecting to ishan's macbook pro

    If you just reboot it, does the problem go away?

Maybe you are looking for

  • Photoshop CS2 performance...

    A friend of mine who is a optemetric technician (he takes pictures of eyeballs) recently switched from a Thinkpad to a MacBook Pro. He has 2.33Ghz with 512MB RAM. I was helping him setup Photoshop CS2 and we ran into some issues, namely it is slower

  • Can't edit track # in song info

    In my music library, I'm able to edit song info such as artist, song name, album, etc. But I can't figure out how to change the track # of a song. I have the column displayed for track #'s, but clicking inside the track # boxes doesn't allow me to ed

  • New iMAC - How to move data over from PC?

    Hi, Just bought the new iMac 27" to replace my PC. What is the best way to move all my music, videos, and apps to the new iMAC? I have music bought from iTunes and downloaded from CDs - also have apps and videos bought from iTunes.... So far all I ca

  • How is iOS 7.1 on iPhone 4S?

    Hello. Is it safe to download and install 7.1 over 7.0.6 on an iPhone 4S? I read that 4 has speed improvements, but nothing about 4S. Any issues yet? Thank you in advance.

  • Again: Search options in Oracle intermedia

    I can't read the answer to my former question.... I may have some problems with my browser. Can the one who answered me write again? Thank you very much Annalisa