A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: Modify X,Y Coordinates of an SWF?

  1. #1
    Member
    Join Date
    Mar 2009
    Posts
    82

    Modify X,Y Coordinates of an SWF?

    If a swf loads multiple swfs that each have multiple layers of content, can the X and Y coordinates of them be modified?

    The flies were created at different times so the positioning is different between each file once they play.

  2. #2
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    Are you wanting to change the x, y coords of the loaded swf? or the content within them?

  3. #3
    Member
    Join Date
    Mar 2009
    Posts
    82
    the swf, unless its possible to change the coords of all the content at once.

  4. #4
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    Oh yeah, you can do that easily with your loader object.

    var xCoord:Number = 0;
    var yCoord:Number = 0;

    loaderObject.x = xCoord;
    loaderObject.y = yCoord;

  5. #5
    Member
    Join Date
    Mar 2009
    Posts
    82
    and that goes in each swf?

  6. #6
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    No, what happens is when you load your swf into your main file you have a complete event listener. In that listener is where you would position your completely loaded files.

  7. #7
    Member
    Join Date
    Mar 2009
    Posts
    82
    So that makes the swfs load to the x and y of the main?

  8. #8
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    Yes, if you want it at x50 and y50, it would be that of the main.

  9. #9
    Member
    Join Date
    Mar 2009
    Posts
    82
    It seems to make no difference, previously I had simply:

    Actionscript Code:
    myLoader2.x = -155
    myLoader2.y = -355

    But I guess the problem lies in the individual SWFs.

    My main and SWF1 are aligned with this, but SWF2,3,4,5 and 6 are another 30 down the Y axis. Do you have any advice?

  10. #10
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    Could you attach source? Seems there is some factor here acting wierd.

  11. #11
    Member
    Join Date
    Mar 2009
    Posts
    82
    yea of course, how I attach source? You want the menu or an individual swf?

  12. #12
    Member
    Join Date
    Mar 2009
    Posts
    82
    My code is very simple, this is all have on the menu

    Actionscript Code:
    import flash.display.Loader;
    import flash.net.URLRequest;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.events.ProgressEvent;
    import flash.text.TextField;

    var myLoader:Loader = new Loader();
    var myLoader2:Loader = new Loader();

    function buttonClick(event:MouseEvent):void
    {  
        //trace("target name: "+event.target.name);
        myLoader.load(new URLRequest(event.target.name + ".swf"));
        myLoader.x = -155
        myLoader.y = -355
        addChild(myLoader);
    }

    myLoader.contentLoaderInfo.addEventListener(Event.OPEN,showPreloader);
    myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,showProgress);
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,showLoadResult);

    var loadProgress_txt:TextField = new TextField();

    function showPreloader(evt:Event):void {
        addChild(loadProgress_txt);
    }

    function showProgress(evt:ProgressEvent):void {
        loadProgress_txt.text = "loaded:"+evt.bytesLoaded+" from "+evt.bytesTotal;
    }

    function showLoadResult(evt:Event):void {
        removeChild(loadProgress_txt);
        addChild(myLoader);
    }

    1.addEventListener(MouseEvent.CLICK, buttonClick);
    2.addEventListener(MouseEvent.CLICK, buttonClick);
    3.addEventListener(MouseEvent.CLICK, buttonClick);
    4.addEventListener(MouseEvent.CLICK, buttonClick);
    5.addEventListener(MouseEvent.CLICK, buttonClick);
    6.addEventListener(MouseEvent.CLICK, buttonClick);

  13. #13
    Member
    Join Date
    Mar 2009
    Posts
    82
    Does anyone have any suggestions?

  14. #14
    Member
    Join Date
    Mar 2009
    Posts
    82
    How do I set defferent x, y values for the different swfs?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center