开发者

not able to position externally loaded swf

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!


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.


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜