views:

24

answers:

2

I´m having troubble positioning an externally loaded swf. It simply does not respond to any settings of its x and y values.

The swf I´m loading is a pure as3 project created in FlashDevelop where the main class extends sprite. I´ve even tried modifying the x and y values afterwards using MonsterDebugger but with no luck.

The swf is loaded into a container on the right side of the stage but always end up at the top left corner. The loading is straight forward:

public var targetContainer:Sprite;
public function load(path:string):void {

    loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, successHandler);

    var movie:MovieClip = new MovieClip();
    movie.addChild(loader);
    targetContainer.addChild(movie);

    loader.load(new UrlRequest(pathToSwf));
}
private function successHandler(e:Event):void {    
    //this does nothing for the one file, but affect any other swf i load
    e.target.content.x = 300;
}

I don´t have this problem for other swf-files so I´m guessing it has to do with some code issue in my specific as3 project, I just can´t figure out what???

Thankful for any and every suggestion!

+1  A: 

try movie.x = 300; instead of event.target.content.x = 300. The loader content is the root DisplayObject of the swf you are loading. Inside the loaded swf there is probably some code which also sets (and therefore overrides) the x property of the same DisplayObject at some point.

maxmc
thanks for the answer! I dod not think that this will solve my problem though since I´ve tried to change the x afterwards aswell via MonsterDebugger, both child and parent containers actually... with no effect.Might this happen as a consequence of namespace collisions? I could have some of those...
Tobias
A: 

Once again I had the same problem... conflicting packages and class names... it´d be a great thing If one were warned by such things, but from now on I´ll have long and unrecognizable names that really do tell who they are ;)

Strange thing though that it got the entire loaded swf to, firstly, sit in the top left corner, and , secondly, that it was not possible to change the position even via MonsterDebugger "in game"...

Newb, it´s really in the air!

Tobias