A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Loading/Unloading

  1. #1
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404

    Loading/Unloading

    Hi, so in my game I got frame rate to smoothen out more using some techniques. Problem is it wont help forever because I am planning on making the world huge so im trying to think of a good way to hide/unhide tiles.

    So far I tried alphaing out tiles that are not seen by the vcam that went horrible and turned out really laggy.

    Than I tried making the vcam act as a giant hit test to my tiles making them go to a blank keyframe when not in use. That didn't really help.

    I found how ever that like above ^ making tiles go to empty keyframes helps ALOT, but having the constant hit test uses alot of resources.

    So please I cant go to much into code because its complicated, maybe ill have too but I need some ideas from you guys. Thanks.


    if nothing works I am considering having a "room like design" example: I walk to the edge of the map I am now in the next map while the other one is gone etc. I don't think splitting maps though is a good user experience because in reality having a big map you can walk around in feels way better "I think".

  2. #2
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    I don't understand really well what you are trying to do, or what you really need, but reading your thread I suppose that's fixed removing the tiles movieclip when no using them, and attaching them when using them. attachMovie/removeMovieClip is the only option. Or you can have the tiles as an external .swf and loadMovie/unLoadMovie.
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  3. #3
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    but will they remove and re attach in the same position as they were removed in?

  4. #4
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Yeah, because you specify the last _x _y coordinates with a variable.
    PHP Code:
    //create
    function create(){
    _root.attachMovie("bookMC""bookMC"_root.getNextHighestDepth());
    bookMC._x=lastX
    bookMC
    ._ylastY
    bookMC
    .onPress=function(){
        
        
    startDrag(thisfalse);

        
    trace(bookMC._x);
        
    trace(bookMC._y);

        
    }
    bookMC.onRelease=function(){
        
    this.stopDrag();
            
    lastX=bookMC._x
    lastY
    =bookMC._y
    }
    }

    //remove
    function remove(){
        
    bookMC.removeMovieClip();
    }

    //secondary buttons
    buu.onPress=function(){
        
    remove();
        
    }

    buu2.onPress=function(){
        
    create();

    In that example i made for you, there is 2 buttons, one creates a movieclip and the other removes it. When creating it, i tell flash that the _x and _y coordinates of my movieclip is equal to lastX and lastY.

    Then, on my movieclip press it start Dragging it. When release, it stop dragging it and tell flash that lastX is equal to my movieclip's last _x and lastY is equal to my movieclip's last _y. So , i press the button for removing it, and when pressing the other button to re-attach it, TADA! My movieclip appears exactly where I left it!
    Last edited by angelhdz; 12-11-2012 at 04:57 PM.
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  5. #5
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404

    Cool

    Thanks dude! you are a boss.

  6. #6
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    For some reason its only outputting the books location but not really creating or destroying the book. Idk hmm

  7. #7
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    the function remove(){ bookMC.removeMovieClip();} MUST destroy the movieclip.
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  8. #8
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    They aren't destroying it or creating it im positive I did it correctly, did you try using it?

  9. #9
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    I got it working, thanks angel you the man

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