A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: how to make resizable

  1. #1
    Senior Member
    Join Date
    May 2016
    Posts
    451

    how to make resizable

    hello all

    How can i make automatic resizing of movie clip contents to any screen

    thanks
    Last edited by kofa; 01-25-2022 at 10:00 AM.

  2. #2
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Download as2 swish basic scaling: download

    This is the way I stretch for everything to fit any device.

    If it is landscape mode you should stretch everything based on stage height, but if it is portrait mode, you should stretch everything based on stage width. Learning this method for all stretching will be good for all devices, mobile or desktop, or webpage scaling & good for orientation change on mobile.

    //if landscape mode, else if it is portrait mode stretch everything from condition 1 in condition 2 but based on stage width
    if(Stage.width>Stage.height){//stretch based on stage height for landscape

    }else if(Stage.height>Stage.width){//stretch based on stage width for mobile or portrait

    }

    PHP Code:
    onFrame (1) {
    Stage.scaleMode "noScale";//don't stretch movieclips when resizing stage.

    Stage.align "TL";//align the start point of the stage to the top left of the window.

    var scaleObject = new Object();//create empty object
    Stage.addListener(scaleObject);//make empty object a stage listener for resize things
    scaleObject.onResize();//since it is a stage listener, give it onResize function to get values when stage resizes, starting this after the function is better on startup

    scaleObject.onResize = function() {//on resize will update when window is stretched so you can access Stage.width & Stage.height
    mc._x=0;//start mc at 0 x
    mc._width=Stage.width-1;//stretch mc to be width of stage on resize.

    if(Stage.width>Stage.height){//do this for all stage resizes, a condition on how it will stretch if stage width is larger and the same for if height is larger to base it on height.
    mc._y=0;//start mc at 0 y
    mc._height=Stage.height/8;//divide by height if width of stage is larger
    /////////////height ^ insead of width

    btn._height=mc._height/1.3;//good size to make the height of the button based on the bar
    btn._xscale=btn._yscale;//scale the button horizontal to equal the height we just scaled it equally, this way it wont look stretched.


    btn._y=mc._y mc._height/btn._height/2//btn y coord equals starting point of bar y + bar height in half - btn height in half
    btn._x=btn._y//make the distance of btn _x to be symmetrical with where its difference is from y

    }else if(Stage.height>Stage.width){//if height of stage is greater you have to do the same stretching but based on width instead
        
    mc._y=0;//start mc at 0 y
    mc._height=Stage.width/8;//divide by width if height of stage is larger
    /////////////width ^ insead of height

    btn._height=mc._height/1.3;//good size to make the height of the button based on the bar
    btn._xscale=btn._yscale;//scale the button horizontal to equal the height we just scaled it equally, this way it wont look stretched.

    btn._y=mc._y mc._height/btn._height/2//btn y coord equals starting point of bar y + bar height in half - btn height in half
    btn._x=btn._y//make the distance of btn _x to be symmetrical with where its difference is from y
    }


    };




    //Stretch the window up and down when width of stage is smaller & you will see the movieclip height wont change, only width which is good for mobile displays on portrait mode.

    //Stretch the window left & right when the width is greater than the height of the stage and you will see it is good for landscape mode & wont affect the height of the movieclip.

    Last edited by AS3.0; 01-27-2022 at 09:48 PM.

  3. #3
    Senior Member
    Join Date
    May 2016
    Posts
    451

  4. #4
    Senior Member
    Join Date
    May 2016
    Posts
    451
    hello AS3.0
    i downloaded your scalling wish file
    and i added menu movie clip to your file
    how can i resizable this movie clip with screen

    https://app.box.com/s/6hsiuualaiacs75l69wihnwmxmd09ctr

  5. #5
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    This works pretty good, we should add a scrollpane for that though.
    PHP Code:
    onFrame (1) {
    menu.setMask(myMask);    
    stop();
    Stage.scaleMode "noScale";//don't stretch movieclips when resizing stage.

    Stage.align "TL";//align the start point of the stage to the top left of the window.

    var scaleObject = new Object();//create empty object
    Stage.addListener(scaleObject);//make empty object a stage listener for resize things

    scaleObject.onResize = function() {//on resize will update when window is stretched so you can access Stage.width & Stage.height
    mc._x=0;//start mc at 0 x
    mc._width=Stage.width-1;//stretch mc to be width of stage on resize.

    if(Stage.width>Stage.height){//do this for all stage resizes, a condition on how it will stretch if stage width is larger and the same for if height is larger to base it on height.
    mc._y=0;//start mc at 0 y
    mc._height=Stage.height/8;//divide by height if width of stage is larger
    /////////////height ^ insead of width

    btn._height=mc._height/1.3;//good size to make the height of the button based on the bar
    btn._xscale=btn._yscale;//scale the button horizontal to equal the height we just scaled it equally, this way it wont look stretched.

    btn._y=mc._y mc._height/btn._height/2//btn y coord equals starting point of bar y + bar height in half - btn height in half
    btn._x=btn._y//make the distance of btn _x to be symmetrical with where its difference is from y

    menu._width=Stage.height
    menu
    ._yscale=menu._xscale;
    menu._x=Stage.width/2-menu._width/2
    menu
    ._y=Stage.height/2-menu._height/2

    myMask
    ._width=menu._width*2
    myMask
    ._height=menu._height*2
    myMask
    ._x=menu._x
    myMask
    ._y=menu._y
    }else if(Stage.height>Stage.width){//if height of stage is greater you have to do the same stretching but based on width instead
        
    mc._y=0;//start mc at 0 y
    mc._height=Stage.width/8;//divide by width if height of stage is larger
    /////////////width ^ insead of height

    btn._height=mc._height/1.3;//good size to make the height of the button based on the bar
    btn._xscale=btn._yscale;//scale the button horizontal to equal the height we just scaled it equally, this way it wont look stretched.

    btn._y=mc._y mc._height/btn._height/2//btn y coord equals starting point of bar y + bar height in half - btn height in half
    btn._x=btn._y//make the distance of btn _x to be symmetrical with where its difference is from y

    menu._width=Stage.width
    menu
    ._yscale=menu._xscale;
    menu._x=Stage.width/2-menu._width/2
    menu
    ._y=Stage.height/2-menu._height/2

    myMask
    ._width=menu._width*2
    myMask
    ._height=menu._height*2
    myMask
    ._x=menu._x
    myMask
    ._y=menu._y
    }


    };

    scaleObject.onResize();//since it is a stage listener, give it onResize function to get values when stage resizes, starting this after the function is better on startup




    //Stretch the window up and down when width of stage is smaller & you will see the movieclip height wont change, only width which is good for mobile displays on portrait mode.

    //Stretch the window left & right when the width is greater than the height of the stage and you will see it is good for landscape mode & wont affect the height of the movieclip.

    Last edited by AS3.0; 01-29-2022 at 03:51 PM.

  6. #6
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    I fixed the scaling when the slide is open:

    PHP Code:
    onFrame (1) {
    menu.setMask(myMask);    
    stop();
    Stage.scaleMode "noScale";//don't stretch movieclips when resizing stage.

    Stage.align "TL";//align the start point of the stage to the top left of the window.

    var scaleObject = new Object();//create empty object
    Stage.addListener(scaleObject);//make empty object a stage listener for resize things

    scaleObject.onResize = function() {//on resize will update when window is stretched so you can access Stage.width & Stage.height
    mc._x=0;//start mc at 0 x
    mc._width=Stage.width-1;//stretch mc to be width of stage on resize.

    if(Stage.width>Stage.height){//do this for all stage resizes, a condition on how it will stretch if stage width is larger and the same for if height is larger to base it on height.
    mc._y=0;//start mc at 0 y
    mc._height=Stage.height/8;//divide by height if width of stage is larger
    /////////////height ^ insead of width

    btn._height=mc._height/1.3;//good size to make the height of the button based on the bar
    btn._xscale=btn._yscale;//scale the button horizontal to equal the height we just scaled it equally, this way it wont look stretched.

    btn._y=mc._y mc._height/btn._height/2//btn y coord equals starting point of bar y + bar height in half - btn height in half
    btn._x=btn._y//make the distance of btn _x to be symmetrical with where its difference is from y

    myMask._width=Stage.height
    myMask
    ._yscale=myMask._xscale
    myMask
    ._x=Stage.width/2
    myMask
    ._y=Stage.height/2

    menu
    ._height=myMask._height
    menu
    ._xscale=menu._yscale

    menu
    ._x=myMask._x-myMask._width/2
    menu
    ._y=myMask._y-myMask._height/2

    }else if(Stage.height>Stage.width){//if height of stage is greater you have to do the same stretching but based on width instead
        
    mc._y=0;//start mc at 0 y
    mc._height=Stage.width/8;//divide by width if height of stage is larger
    /////////////width ^ insead of height

    btn._height=mc._height/1.3;//good size to make the height of the button based on the bar
    btn._xscale=btn._yscale;//scale the button horizontal to equal the height we just scaled it equally, this way it wont look stretched.

    btn._y=mc._y mc._height/btn._height/2//btn y coord equals starting point of bar y + bar height in half - btn height in half
    btn._x=btn._y//make the distance of btn _x to be symmetrical with where its difference is from y


    myMask._width=Stage.width
    myMask
    ._yscale=myMask._xscale
    myMask
    ._x=Stage.width/2
    myMask
    ._y=Stage.height/2

    menu
    ._height=myMask._height
    menu
    ._xscale=menu._yscale

    menu
    ._x=myMask._x-myMask._width/2
    menu
    ._y=myMask._y-myMask._height/2
    }


    };

    scaleObject.onResize();//since it is a stage listener, give it onResize function to get values when stage resizes, starting this after the function is better on startup




    //Stretch the window up and down when width of stage is smaller & you will see the movieclip height wont change, only width which is good for mobile displays on portrait mode.

    //Stretch the window left & right when the width is greater than the height of the stage and you will see it is good for landscape mode & wont affect the height of the movieclip.


  7. #7
    Senior Member
    Join Date
    May 2016
    Posts
    451
    thanks AS3.0

    I tried to apply this code to a new slider movie clip but it failed
    when i maximize my file the slider width not = Stage.width
    Can you check this file to make a new slider movie clip work properly?
    Is it possible to make a code that works with any other add-ons?


    https://app.box.com/s/23pymceasxlrqb75c3794ot9fxw9a89c

  8. #8
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Ok, I applied some changes but I think its easier to work with having most of the program on
    the main timeline so thats where I put the horizontal scrolling function as well:

    download 0.4

    Yes I could do this add on thing where you just call a function like:

    addToPage(clip_name, maskName, distanceFromLastItemAdded)

    But the thing is, if you are going to keep the mask outside for the first item,
    & the mask inside for the second item its not logical to be doing 2 different ways,
    I would just keep the mask outside & the side scroller can be way faster if you just
    load items when you need them but you can keep it like that for a bit if you need to visualize it still.
    Last edited by AS3.0; 01-31-2022 at 01:21 PM.

  9. #9
    Senior Member
    Join Date
    May 2016
    Posts
    451
    I made the mask out of the movie clip but it didn't work
    Can you check this file please
    https://app.box.com/s/mu27wkb87xc3pln9lv8x21ty4zpmtqcg

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

    Ok on line 247 you can use this line to add more items from the library that have a linkage like
    "menu_item" or "myMask" at content > MovieClips/Shapes

    You have 3 operators to separate from the last item added to page: *, +, or /
    PHP Code:
    addToPage("menu_item","myMask","*",0.2)//add menu_item with mask myMask using operator * to give a separation of 0.2 the height of menu_item passed the last item

    addToPage("menu_item","myMask","+",50)//add menu_item with mask myMask using operator + to give a separation of 50 pixels height passed the last item added

    addToPage("menu_item","myMask","/",4)//add menu_item with mask myMask using operator / to give a separation of 1/4th the height of the item just added passed the last item 
    So now you can try to add more items using addToPage: addToPage("new_movieclip","new_mask_that_fits","/",4)

    Should I re-add the horizontal slider... try some stuff out first & I implemented scroll wheel, unless you prefer scrollpane.
    Last edited by AS3.0; 02-01-2022 at 12:22 PM.

  11. #11
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    This will add 50 items, & fixed scrolling: download 0.6(1)

    PHP Code:
    for(var i=0;i<50;i++){
    addToPage("menu_item","myMask","*",0.2)

    Last edited by AS3.0; 02-01-2022 at 12:37 PM.

  12. #12
    Senior Member
    Join Date
    May 2016
    Posts
    451
    i add slider movie clip to library
    and i add a new mask1 to library

    and i add this code

    PHP Code:
    addToPage("slider","Mask1","+",0)
    addToPage("slider","Mask1","/",20)
    addToPage("slider","Mask1","*",0.2

    but the slider not working

    Can you check this file please
    https://app.box.com/s/shbi40s4qjnahjaerpp1y204vh0ts6ha

  13. #13
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Ok, I still need to make it work for multiple sliders, this is for just 1:


    download 0.9

    PHP Code:
    addToPage("menu_item","myMask","+",0)
    addToPage("box_container","Mask1","*",0.2//slider
    addToPage("menu_item","myMask","*",0.15)
    addToPage("menu_item","myMask","+",0
    Sorry it took a while its that I don't write much as2.0 & I was doing some other stuff,
    but on the good side it should be pretty efficient.
    Last edited by AS3.0; 02-16-2022 at 03:11 PM.

  14. #14
    Senior Member
    Join Date
    May 2016
    Posts
    451
    It is good to reach this point, but we want to reach a professional file

    1- how can you move left and right ?

    2- if you notice that the speed of moving is related to the size of the file, but we want to control the speed through the slider’s mouse coordinates

    3- how can I add a button event to these boxes( slider ) ?

    good luck

  15. #15
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    To answer question number 3:

    I added a rolloverEvent to change the alpha to 50% on line 45. (everything that gets attached for the sliders is in the reset_array() function.

    On line 356 we must set the alpha back to 100% & move the box to the other side to be reused.

    PHP Code:
    onFrame (1) {
    //menu.setMask(myMask);    
    //slider.setMask(Mask1);   
    stop();
    Stage.scaleMode "noScale";//don't stretch movieclips when resizing stage.

    Stage.align "TL";//align the start point of the stage to the top left of the window.

    _root["mask_var"]._width=Stage.width
    _root
    ["mask_var"]._height=Stage.height/3.5

    var image_ids=[0,1,2,3,4]

    _root["box_container"].attachMovie("boxes","boxes_1",getNextHighestDepth())
    //_root["box_container"].setMask(_root["mask_var"]);

    var first_item=0
    var last_item=0
    var mode="left"
    var offset=0;
    var 
    box_contain=[];
    var 
    original_height=0;
    var 
    original_width=0
    var pos=0
    var depth=0


    function reset_array(){
    for(
    i in _root["box_container"]){
    _root["box_container"][i].removeMovieClip();
    }

    var 
    temp_first=first_item
    box_contain
    =[]
    pos=0+offset
    if(pos>image_ids.length){
    pos=0
    }else if(pos<0){
    pos=image_ids.length-1
    }
    for(var 
    i=0;i<Stage.width+_root["mask_var"]._height*3;i+=_root["mask_var"]._height+(_root["mask_var"]._height/4)){
    depth++
    _root["box_container"].attachMovie("boxes","box_var"+depth,_root["box_container"].getNextHighestDepth())
    mc2=_root["box_container"]["box_var"+depth]
    mc2.onRollOver=function(){
    this._alpha=50
    }

    mc2._height=_root["mask_var"]._height
    mc2
    ._xscale=mc2._yscale
    mc2
    ._x=i-(mc2._width+mc2._width/4)
    mc2._y=0
    mc2
    .cacheAsBitmap true;
    _root["box_container"].object_type="box"
    if(mode=="left"){
    _root["box_container"]._x=mc2._height
    }else{
    _root["box_container"]._x=0
    }
    box_contain.push(mc2)//
    mc2.data_field.text=temp_first++
    if(
    mc2.data_field.text>image_ids.length-1){
    temp_first=1
    mc2
    .data_field.text=0
    }
    pos++
    }
    original_height=_root["mask_var"]._height
    original_width
    =_root["mask_var"]._width
    _root
    ["box_container"]._y=_root["mask_var"]._y+_root["mask_var"]._height/2
    }


    var 
    mouseListener:Object = new Object();

    Mouse.addListener(mouseListener);
    var 
    scroll_height=0;
    var 
    scrollwheel:Object = new Object();
    Mouse.addListener(scrollwheel);
    mouseListener.onMouseWheel = function(e) { 
    mc.swapDepths(getNextHighestDepth());
    btn.swapDepths(getNextHighestDepth());

    if(
    e>1){
    scroll_height=Stage.height/15
    }else{
    scroll_height=-Stage.height/15
    }  
    for(var 
    i=0;i<page_items.length;i++){
    page_items[i]._y+=scroll_height
    mask_items
    [i]._y+=scroll_height
    }

    };

    //reset_array()

    var scaleObject = new Object();//create empty object
    Stage.addListener(scaleObject);//make empty object a stage listener for resize things
    var start_point=Stage.height/2;


    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    scaleObject.onResize = function() {//on resize will update when window is stretched so you can access Stage.width & Stage.height
    mc.swapDepths(getNextHighestDepth());
    btn.swapDepths(getNextHighestDepth());
    start_point=Stage.height/2;
    mc._x=0;//start mc at 0 x
    mc._width=Stage.width-1;//stretch mc to be width of stage on resize.

    if(Stage.width>Stage.height){//do this for all stage resizes, a condition on how it will stretch if stage width is larger and the same for if height is larger to base it on height.
    mc._y=0;//start mc at 0 y
    mc._height=Stage.height/8;//divide by height if width of stage is larger
    /////////////height ^ insead of width
    btn._height=mc._height/1.3;//good size to make the height of the button based on the bar
    btn._xscale=btn._yscale;//scale the button horizontal to equal the height we just scaled it equally, this way it wont look stretched.
    btn._y=mc._y mc._height/btn._height/2//btn y coord equals starting point of bar y + bar height in half - btn height in half
    btn._x=btn._y//make the distance of btn _x to be symmetrical with where its difference is from y



    for(var i=0;i<page_items.length;i++){

    if(
    mask_items[i].obj_type=="scroller"){
    mask_items[i]._x=0
    }else{
    mask_items[i]._x=Stage.width/2-mask_items[i]._width/2
    }

    page_items[i]._x=Stage.width/2-page_items[i]._width/2
    page_items
    [i].setMask(mask_items[i]);

    mask_items[i]._width=Stage.height
    mask_items
    [i]._yscale=mask_items[i]._xscale

    if(operator_items[i]=="/"){
    mask_items[i].spacing=(mask_items[i]._height/fraction_items[i])
    }else if(
    operator_items[i]=="*"){
    mask_items[i].spacing=(mask_items[i]._height*fraction_items[i])
    }else if(
    operator_items[i]=="+"){
    mask_items[i].spacing=(fraction_items[i])
    }
    if(
    mask_items[i].obj_type=="scroller"){
    mask_items[i].spacing=  mask_items[i].spacing- (mask_items[i]._height/4)
    }
    if(
    mask_items[i-1].obj_type=="scroller"){
    mask_items[i].spacing=  mask_items[i].spacing+ (mask_items[i-1]._height/4)
    }

    if(
    mask_items[i].obj_type=="scroller"){
    mask_items[i]._x=0
    }else{
    mask_items[i]._x=Stage.width/2
    }

    if(
    i>0){
    mask_items[i]._y=(mask_items[i]._height/2)+(mask_items[i-1]._y+mask_items[i]._height/2)+mask_items[i].spacing
    }else{
    mask_items[i]._y=mc._height+1+(mask_items[i]._height/2)

    }
    if(
    mask_items[i].obj_type=="scroller"){
    page_items[i]._xscale=100
    page_items
    [i]._yscale=100
    }else{
    page_items[i]._height=mask_items[i]._height
    page_items
    [i]._xscale=page_items[i]._yscale

    }
    page_items[i]._x=(mask_items[i]._x-mask_items[i]._width/2)

    page_items[i]._y=(mask_items[i]._y-mask_items[i]._height/2)

    }




    }else if(
    Stage.height>Stage.width){//if height of stage is greater you have to do the same stretching but based on width instead
        
    mc._y=0;//start mc at 0 y
    mc._height=Stage.width/8;//divide by width if height of stage is larger
    /////////////width ^ insead of height
    btn._height=mc._height/1.3;//good size to make the height of the button based on the bar
    btn._xscale=btn._yscale;//scale the button horizontal to equal the height we just scaled it equally, this way it wont look stretched.
    btn._y=mc._y mc._height/btn._height/2//btn y coord equals starting point of bar y + bar height in half - btn height in half
    btn._x=btn._y//make the distance of btn _x to be symmetrical with where its difference is from y

    for(var i=0;i<page_items.length;i++){
    mask_items[i]._x=Stage.width/2-mask_items[i]._width/2
    page_items
    [i]._x=Stage.width/2-page_items[i]._width/2
    page_items
    [i].setMask(mask_items[i]);
    mask_items[i]._width=Stage.width
    mask_items
    [i]._yscale=mask_items[i]._xscale
    if(operator_items[i]=="/"){
    mask_items[i].spacing=(mask_items[i]._height/fraction_items[i])
    }else if(
    operator_items[i]=="*"){
    mask_items[i].spacing=(mask_items[i]._height*fraction_items[i])
    }else if(
    operator_items[i]=="+"){
    mask_items[i].spacing=(fraction_items[i])
    }
    if(
    mask_items[i].obj_type=="scroller"){
    mask_items[i].spacing=  mask_items[i].spacing- (mask_items[i]._height/4)
    }
    if(
    mask_items[i-1].obj_type=="scroller"){
    mask_items[i].spacing=  mask_items[i].spacing+ (mask_items[i-1]._height/4)
    }
    mask_items[i]._x=Stage.width/2
    if(mask_items[i].obj_type=="scroller"){
    mask_items[i]._x=Stage.width/2-mask_items[i]._width/2
    }
    if(
    i>0){
    mask_items[i]._y=(mask_items[i]._height/2)+(mask_items[i-1]._y+mask_items[i]._height/2)+mask_items[i].spacing
    }else{
    mask_items[i]._y=mc._height+1+(mask_items[i]._height/2)
    }
    if(
    mask_items[i].obj_type=="scroller"){
    page_items[i]._xscale=100
    page_items
    [i]._yscale=100
    }else{
    page_items[i]._height=mask_items[i]._height
    page_items
    [i]._xscale=page_items[i]._yscale
    }

    page_items[i]._x=(mask_items[i]._x-mask_items[i]._width/2)
    page_items[i]._y=(mask_items[i]._y-mask_items[i]._height/2)

    }
    }
    };
    //attachMovie('menu_item','menu_item',50);


    var depth_pos=5
    var page_items=[]
    var 
    mask_items=[]
    var 
    operator_items=[]
    var 
    fraction_items=[]


    function 
    addToPage(a,b,c,d){
    depth_pos++

    if(
    b=="Mask1"){
    attachMovie(b,"mask_var",getNextHighestDepth());
    createEmptyMovieClip("box_container"getNextHighestDepth());
    page_items.push(_root["box_container"])
    mask_items.push(_root["mask_var"])
    operator_items.push(c)
    fraction_items.push(d)
    _root["mask_var"].obj_type="scroller"
    }else{
    attachMovie(b,b+depth_pos,getNextHighestDepth());
    attachMovie(a,a+depth_pos,getNextHighestDepth());
    page_items.push(_root[a+depth_pos])
    mask_items.push(_root[b+depth_pos])
    operator_items.push(c)
    fraction_items.push(d)
    }

    for(var 
    i=0;i<page_items.length;i++){ 
    if(
    page_items.length>1){
    mask_items[i]._x=Stage.width/2-mask_items[i]._width/2
    mask_items
    [i]._y=mask_items[i-1]._y+mask_items[i-1]._height
    page_items
    [i]._x=Stage.width/2-page_items[i]._width/2
    mask_items
    [i]._width=Stage.height
    mask_items
    [i]._yscale=mask_items[i]._xscale
    //page_items[i].setMask(mask_items[i]);
    if(operator_items[i]=="/"){
    mask_items[i].spacing=(mask_items[i]._height/fraction_items[i])
    }else if(
    operator_items[i]=="*"){
    mask_items[i].spacing=(mask_items[i]._height*fraction_items[i])
    }else if(
    operator_items[i]=="+"){
    mask_items[i].spacing=(fraction_items[i])
    }

    mask_items[i]._x=Stage.width/2
    if(mask_items[i].obj_type=="scroller"){
    mask_items[i]._x=0
    }

    mask_items[i]._y=(mask_items[i]._height/2)+(mask_items[i-1]._y+mask_items[i]._height/2)+mask_items[i].spacing
    page_items
    [i]._height=mask_items[i]._height
    page_items
    [i]._xscale=page_items[i]._yscale
    page_items
    [i]._x=(mask_items[i]._x-mask_items[i]._width/2)
    page_items[i]._y=(mask_items[i]._y-mask_items[i]._height/2)

    }else{

    mask_items[0]._width=Stage.height
    mask_items
    [0]._yscale=mask_items[0]._xscale
    if(operator_items[i]=="/"){
    mask_items[i].spacing=(mask_items[i]._height/fraction_items[i])
    }else if(
    operator_items[i]=="*"){
    mask_items[i].spacing=(mask_items[i]._height*fraction_items[i])
    }else if(
    operator_items[i]=="+"){
    mask_items[i].spacing=(fraction_items[i])
    }
    mask_items[0]._x=Stage.width/2
    mask_items
    [0]._y=mc._height+1+(mask_items[0]._height/2)+mask_items[i].spacing
    page_items
    [0]._height=mask_items[0]._height
    page_items
    [0]._xscale=page_items[0]._yscale
    page_items
    [0]._x=mask_items[0]._x-mask_items[0]._width/2
    page_items
    [0]._y=mask_items[0]._y-mask_items[0]._height/2
    //page_items[0].setMask(mask_items[0]);
    }
    }

    }
    addToPage("menu_item","myMask","+",0)
    addToPage("box_container","Mask1","*",0.2)
    addToPage("menu_item","myMask","*",0.15)
    addToPage("menu_item","myMask","+",0)
    reset_array()
    //attachMovie("Mask1","mask_var",getNextHighestDepth())
    //createEmptyMovieClip("box_container", getNextHighestDepth());



    scaleObject.onResize();//since it is a stage listener, give it onResize function to get values when stage resizes, starting this after the function is better on startup


    }
    //Stretch the window up and down when width of stage is smaller & you will see the movieclip height wont change, only width which is good for mobile displays on portrait mode.

    //Stretch the window left & right when the width is greater than the height of the stage and you will see it is good for landscape mode & wont affect the height of the movieclip.



    onSelfEvent (enterFrame) {

    _root["mask_var"]._width=Stage.width
    if(original_height!=_root["mask_var"]._height||original_width!=_root["mask_var"]._width){
    reset_array()
    }



    //begin left scroll
    mode="left"
    for(var i=0;i<box_contain.length;i++){
    box_contain[i]._x-=box_contain[i]._width/10
    box_contain
    [i]._height=_root["mask_var"]._height
    box_contain
    [i]._xscale=box_contain[i]._yscale
    if(box_contain[0]._x<0-box_contain[0]._width*2){
    offset++
    if(
    offset>image_ids.length-1){
    offset=0
    }
    box_contain[i].data_field.text=Number(box_contain[box_contain.length-1].data_field.text)+1
    if(Number(box_contain[box_contain.length-1].data_field.text)>image_ids.length-2){
    box_contain[i].data_field.text=
    }     
    //last_item=Number(box_contain[i].data_field.text)
    first_item=Number(box_contain[1].data_field.text)
    box_contain[i]._alpha=100
    box_contain
    [i]._x=box_contain[box_contain.length-1]._x+(box_contain[i]._width)
    box_contain.push(box_contain.shift())

    }
    }
    //end left scroll

    /*
    //begin right scroll
    mode="right"
    for(var i=0;i<box_contain.length;i++){
    box_contain[i]._x+=box_contain[i]._width/10
    box_contain[i]._height=_root["mask_var"]._height
    box_contain[i]._xscale=box_contain[i]._yscale
    if(box_contain[i]._x>Stage.width+box_contain[i]._width+box_contain[i]._width/4){
    offset--
    if(offset<0){
    offset=image_ids.length-1
    }
    box_contain[i].data_field.text=Number(box_contain[0].data_field.text)-1
    if(Number(box_contain[0].data_field.text)-1<0){
    box_contain[i].data_field.text=image_ids.length-1   
    }           
    first_item=Number(box_contain[i].data_field.text)
    box_contain[i]._x=(box_contain[0]._x-box_contain[0]._width)
    box_contain.unshift(box_contain.pop())
    }
    }
    //end right scroll
     */
      


  16. #16
    Senior Member
    Join Date
    May 2016
    Posts
    451
    thanks my friend

  17. #17
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    See if someone else can help you move left & right,

    If you comment out //begin left scroll & uncomment //begin right scroll it will go the other way.

    If this is to build a website, the best builder would be done in AS3.0 for me.

  18. #18
    Senior Member
    Join Date
    May 2016
    Posts
    451
    Thank you
    Let's meet in a new file and new ideas soon
    Anyway, thank you, my friend

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