# Rotating a dynamically-loaded image

**URL:** <https://forum.kirupa.com/t/rotating-a-dynamically-loaded-image/220184>\
**Category:** Uncategorized\
**Created:** [March 23, 2007, 2:49pm UTC](https://forum.kirupa.com/t/rotating-a-dynamically-loaded-image/220184 "2007-03-23T14:49:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dalewb](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/dalewb/32/3029_2.png) [@dalewb](https://forum.kirupa.com/u/dalewb)\
**Post date:** [March 23, 2007, 2:49pm UTC](https://forum.kirupa.com/t/rotating-a-dynamically-loaded-image/220184/1 "2007-03-23T14:49:09Z")

</div>

Will someone please tell me how to rotate about the center an image loaded dynamically through AS? I’ve already asked **[this question](http://www.kirupa.com/forum/showthread.php?t=254713)**, no one answered, I searched, searched some more, looked through my fairly voluminous collection of example flas and have come up with nothing.

The following code does rotate a mc about its center, but only (apparently) if the mc contains something when the swf loads. I’d really appreciate some help here.

```auto

onClipEvent(load){
    this.rotation_speed = 2;
    
    function origin(){
        var bounds = this.getBounds(this._parent);
        return {x:(bounds.xMin+bounds.xMax)/2, y:(bounds.yMin+bounds.yMax)/2};
    }
    this.rotation_origin = origin();
}
onClipEvent(enterFrame){
    this._rotation += rotation_speed;
    var curr_origin = origin();
    this._x += this.rotation_origin.x - curr_origin.x;
    this._y += this.rotation_origin.y - curr_origin.y;
}

```
