A Flash Developer Resource Site

Page 2 of 5 FirstFirst 12345 LastLast
Results 21 to 40 of 89

Thread: Random SharedObject

  1. #21
    Senior Member
    Join Date
    May 2016
    Posts
    451
    that's awesome

    can you add scroll and print function to report

    thanks so mutch

  2. #22
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Hello, I added the scroll bar:

    For the var called question_number_size in script section main you can adjust the scrollbar to be the size of 4 questions max:
    PHP Code:
    var question_number_size=
    For lines 9-12, _root.main.report.content is the container for the cells, _root.main.report.mc is the movieclip to mask size 4 ^ in amount of questions etc..., _root.main.questions.scroll_bg is the scrollbar background & _root.main.questions.scroll_btn is the scrollbar.
    PHP Code:
    var scroll_content=_root.main.report.content
    var scroll_mask=_root.main.report.mc
    var scroll_bar_bg=_root.main.questions.scroll_bg
    var scroll_bar_btn=_root.main.questions.scroll_btn 
    When the table gets updated you can call:
    PHP Code:
    _root.main.updateScrollSettings(_root.main.report.content,_root.main.report.mc);//Give content & mask an update on size change. 
    Set the scrollbar to be in the max position:
    PHP Code:
    _root.main.scrollToMax(); 
    Set the scrollbar to be in the min position:
    PHP Code:
    _root.main.scrollToMin(); 
    So the last thing to notice is that the table content was moved from _root.main.report to _root.main.report.content:
    PHP Code:
    _root.main.report.content["Question"+i].setTextFormat(myformat);//snippet 
    download v14
    Last edited by AS3.0; 11-17-2022 at 02:56 PM.

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




    can you add print report as full A4

  4. #24
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Hello, I added scroll wheel for the scroll bar, I will work on the printing task.

    download v15
    Last edited by AS3.0; 11-17-2022 at 06:24 PM.

  5. #25
    Senior Member
    Join Date
    May 2016
    Posts
    451
    professional

  6. #26
    Senior Member
    Join Date
    May 2016
    Posts
    451
    there is a problem

    if i enable the script in ( Scene_1 ) to Resize my form and this is first open ==> all objects no visible
    but if it is second open it works fine

    Scene_1 script :

    PHP Code:
    onFrame (2) {    
    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
    //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
    main._width Stage.width;
    main._height=Stage.height

    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.
    main._width=Stage.width;
    main._height=Stage.height

    }else if(Stage.height>Stage.width){//if height of stage is greater you have to do the same stretching but based on width instead
        
    main._width=Stage.width;
    main._height=Stage.height
    }

    };


    can you solve this problem

  7. #27
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    This version can print up to 30 questions on A4 paper, but can handle hundreds if you aren't going to print. How many questions do you need to support?

    download v16
    Last edited by AS3.0; 11-19-2022 at 09:19 PM.

  8. #28
    Senior Member
    Join Date
    May 2016
    Posts
    451
    it prints 2 pages the same data repeated

    max questions = 200

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

    In the scripting section called report you can set the amount of questions you want per page.

    So if you answer 50/200 the printout will appear as 1 page with 40 the other with 10, & if you set per_page to a different number you can end up with more pages, but I set it up to have 5 pages max so you should keep it as 40 per page.
    PHP Code:
    var question_num=200;
    var 
    per_page=40 
    If you want per_page to be 15 but still have 200 questions that would mean you would need 14 pages.

    To set it up for 14 pages you would go to the report scripting section & add more sections to this array:
    PHP Code:
    var print_content=[_root.section_1,_root.section_2,_root.section_3,_root.section_4,_root.section_5//add more movieclip names here & duplicate the red dots you see on the stage, call them section_6 etc...
    var print_content_available=[false,false,false,false,false//add more falses per page you want added 
    On lines 161 of the scripting section called main you would need to follow the sequence if you want to add a 6th page etc...:
    PHP Code:
     _root.main.report.print_content_available=[false,false,false,false,false]
    _root.main.report.reset_container(_root.section_1,1,_root.main.report.per_page+1);
    _root.main.report.reset_container(_root.section_2,_root.main.report.per_page+1,(_root.main.report.per_page*2)+1);
    _root.main.report.reset_container(_root.section_3,(_root.main.report.per_page*2)+1,(_root.main.report.per_page*3)+1);
    _root.main.report.reset_container(_root.section_4,(_root.main.report.per_page*3)+1,(_root.main.report.per_page*4)+1);
    _root.main.report.reset_container(_root.section_5,(_root.main.report.per_page*4)+1,(_root.main.report.per_page*5)+1); 
    On lines 241 of the scripting section called main you would need to follow the sequence if you want to add a 6th page etc...:
    PHP Code:
    _root.main.report.reset_container(_root.section_1,1,_root.main.report.per_page);
    _root.main.report.reset_container(_root.section_2,_root.main.report.per_page+1,_root.main.report.per_page*2);
    _root.main.report.reset_container(_root.section_3,(_root.main.report.per_page*2)+1,_root.main.report.per_page*3);
    _root.main.report.reset_container(_root.section_4,(_root.main.report.per_page*3)+1,_root.main.report.per_page*4);
    _root.main.report.reset_container(_root.section_5,(_root.main.report.per_page*4)+1,_root.main.report.per_page*5); 
    On lines 249 of the scripting section called main you would also have to follow the pattern to make a 6th page etc... possible:
    PHP Code:
    _root.section_1._x=0-(_root.section_1._width*2)
    _root.section_1._y=0
    _root
    .section_2._x=0
    _root
    .section_2._y=0-(_root.section_1._width*2)
    _root.section_3._x=0
    _root
    .section_3._y=0-(_root.section_1._width*2)
    _root.section_4._x=0
    _root
    .section_4._y=0-(_root.section_1._width*2)
    _root.section_5._x=0
    _root
    .section_5._y=0-(_root.section_1._width*2
    On line 267 of the scripting section called main you would need to follow the pattern to make a 6th page printable etc...:
    PHP Code:
    var page1;
    var 
    page2;
    var 
    page3;
    var 
    page4;
    var 
    page5;

    if(
    _root.main.report.print_content_available[0]){
    page print_var.addPage(_root.section_1,{xMin:0,xMax:(_root.section_1._width*3),yMin:0,yMax:_root.section_1._height*4});
    }
    if(
    _root.main.report.print_content_available[1]){
    page2 print_var.addPage(_root.section_2,{xMin:0,xMax:(_root.section_2._width*3),yMin:0,yMax:_root.section_2._height*4});
    }
    if(
    _root.main.report.print_content_available[2]){
    page3 print_var.addPage(_root.section_3,{xMin:0,xMax:(_root.section_3._width*3),yMin:0,yMax:_root.section_3._height*4});
    }
    if(
    _root.main.report.print_content_available[3]){
    page4 print_var.addPage(_root.section_4,{xMin:0,xMax:(_root.section_4._width*3),yMin:0,yMax:_root.section_4._height*4});
    }
    if(
    _root.main.report.print_content_available[4]){
    page5 print_var.addPage(_root.section_5,{xMin:0,xMax:(_root.section_5._width*3),yMin:0,yMax:_root.section_5._height*4});
    }
    print_var.send(); 
    download v17
    Last edited by AS3.0; 11-21-2022 at 11:38 PM.

  10. #30
    Senior Member
    Join Date
    May 2016
    Posts
    451



    but resize form still problem ( if it first open before answer any question ===> when you maximize form ===>problem )

  11. #31
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    I fixed a scrolling bug when the list gets to 200.

    download v18
    Last edited by AS3.0; 11-22-2022 at 02:45 PM.

  12. #32
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    I worked on some scaling, it is still missing some performance tweaks & adjustments for the print button.

    The scaling program is inside of the enterframe function at the questions section for now:
    PHP Code:
    modular++;
    if(
    modular%5==0){
    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.
    _root.main.questions.title._width=Stage.height/1.2
    _root
    .main.questions.title._yscale=_root.main.questions.title._xscale
    }else if(Stage.height>Stage.width){//if height of stage is greater you have to do the same stretching but based on width instead
    _root.main.questions.title._width=Stage.width/1.2
    _root
    .main.questions.title._yscale=_root.main.questions.title._xscale
    }
    _root.main.questions.bg._width=Stage.width
    _root
    .main.questions.bg._height=Stage.height
    _root
    .main.questions.bg._x=0
    _root
    .main.questions.bg._y=0
    _root
    .main.questions.title._x=Stage.width/2-_root.main.questions.title._width/2
    _root
    .main.questions.title._y=_root.main.questions.title._height/2

    if(Stage.width/1.7>Stage.height){
    _root.main.questions.text_container._width=Stage.height/3
    _root
    .main.questions.text_container._yscale=_root.main.questions.text_container._xscale
    _root
    .main.questions.text_container._x=Stage.width-_root.main.questions.text_container._width-Stage.width/20
    _root
    .main.questions.text_container._y=Stage.height/2-_root.main.questions.text_container._height/2

    var scroll_pane_height=_root.main.report_container.report.mc._height*(_root.main.report_container._yscale/100);
    _root.main.report_container._xscale=100//_root.main.default_w
    _root.main.report_container._yscale=100//=_root.main.default_h
    while(_root.main.report_container._width<Stage.width/3){
    _root.main.report_container._width*=2
    _root
    .main.report_container._yscale=_root.main.report_container._xscale
    }
    _root.main.report_container._x=int(_root.main.questions.text_container._x/2)-_root.main.report_container._width/2-+(_root.main.report_container.report._width/14.4)
    _root.main.report_container._y=Stage.height/2-scroll_pane_height/2


    _root
    .main.print_btn._x=_root.main.report_container._x+(_root.main.report_container.report._width/11.6)*(_root.main.report_container._yscale/100);//+(_root.main.report_container.report._width/14.4)
    _root.main.print_btn._y=_root.main.report_container._y+scroll_pane_height+_root.main.print_btn._height/3//_root.main.report_container.report._y+scroll_pane_height+_root.main.print_btn._height/3
    } else{

    _root.main.questions.text_container._width=Stage.width/3.5
    _root
    .main.questions.text_container._yscale=_root.main.questions.text_container._xscale
    _root
    .main.questions.text_container._x=Stage.width/2-_root.main.questions.text_container._width/2

        _root
    .main.report_container._xscale=100//_root.main.default_w
    _root.main.report_container._yscale=100//=_root.main.default_h
    var scroll_pane_height=_root.main.report_container.report.mc._height*(_root.main.report_container.report._yscale/100);

    var 
    scroll_pane_width=((_root.main.report_container._width+(_root.main.report_container.report._width/90)))

    _root.main.report_container._x=Stage.width/2-((_root.main.report_container._width+(_root.main.report_container.report._width/7))/2)-Stage.width/140
    //_root.main.report_container._x=Stage.width-((_root.main.report_container._width+(_root.main.report_container.report._width/14.4)))-Stage.width/140
    if(Stage.width<scroll_pane_width){
        
    _root.main.report_container._x=Stage.width-scroll_pane_width-(_root.main.report_container.report._width/14.4)
    }else{

    }
    _root.main.print_btn._x=_root.main.print_btn._width/3
    _root
    .main.print_btn._y=_root.main.report_container._y-_root.main.print_btn._height-_root.main.print_btn._height/3
    _root
    .main.report_container._y=Stage.height-scroll_pane_height-Stage.height/50
    _root
    .main.questions.text_container._y=Stage.height/2-_root.main.questions.text_container._height/2+((_root.main.questions.title._y+_root.main.questions.title._height)/2)-Stage.height/7
    }  

    Some of the movie clips can scale fine with the basic:
    PHP Code:
    if(Stage.width>Stage.height){
    }else if(
    Stage.height>Stage.width){

    Movieclips such as report had another conditional section based off of /1.7 stretching:
    PHP Code:
    if(Stage.width/1.7>Stage.height){
    }else{

    download v19
    Last edited by AS3.0; 11-23-2022 at 01:07 PM.

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

    Thank you soooooooooooooooooooooooooo much

  14. #34
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Alright I worked on the scaling.

    -Happy holidays

    download v20

  15. #35
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Resize bug fix after print:

    download v21

  16. #36
    Senior Member
    Join Date
    May 2016
    Posts
    451



    I added the login form
    and I added code OpenFileDailog


    Load_pic script :

    PHP Code:
    on (press) {  
        
    import flash.net.FileReference;
    var 
    allTypes:Array = new Array();
    var 
    imageTypes:Object = new Object();
    imageTypes.description "Images (*.jpg, *.jpeg, *.png)";
    imageTypes.extension "*.jpg; *.jpeg; *.png";
    allTypes.push(imageTypes);
    var 
    listener:Object = new Object(); 
    listener.onSelect = function(file:FileReference):Void {    
       
    pics.loadMovie(file.name); 
    }
    listener.onCancel = function(file:FileReference):Void {    
    }
    var 
    fileRef:FileReference = new FileReference();
    fileRef.addListener(listener);
    fileRef.browse(allTypes);



    How can this shape be filled with the image ( my image inside this shape )

    and save this pic in SharedObject for next open



    Random SharedObject v22 : https://app.box.com/s/jtgw2av90wo1xn6a42v65pyyy2jufvdm

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

    For the login section, I added the movieclips to an mc called login_container & gave the orange movieclips inside an alpha of 0 to show the initial default image:
    PHP Code:
    _root.login_container.profile_img._alpha=0
    _root
    .login_container.image_mask._alpha=
    When the default image is pressed the button called Load_pic calls the function_root.fileRef thats on the first onFrame(2) section of the script:
    PHP Code:
    _root.fileRef.browse(_root.allTypes); 
    _root.fileRef thats in the onFrame(2) scripting section has a listener called onSelect that will save the file name to array position 21 of the shared object for next startup to attempt to load it:
    PHP Code:
    listener.onSelect = function(file:FileReference):Void {    
    str=file.name
    _root
    .main.questions.open.data.Questions[_root.main.questions.open.data.array[0]][21]=str
    img_loader
    .loadClip(str_root.login_container.profile_img);

    The startup attempt to load the users image is on line 41 of the onFrame(2) scripting section:
    PHP Code:
    var str=_root.main.questions.open.data.Questions[_root.main.questions.open.data.array[0]][21
    line 73 startup attempt to load an image if str turned out to be the last saved item on array section [21]:
    PHP Code:
    img_loader.loadClip(str_root.login_container.profile_img); 
    The onLoadInit event changes the profile_img & image_mask to have an alpha of 100 again since an image was loaded:
    PHP Code:
    loader_listener.onLoadInit = function(e:MovieClip) {

    _root.login_container.profile_img._alpha=100
    _root
    .login_container.image_mask._alpha=100

    e
    ._width=175//Set to size of profile pic.
    e._height=195
    _root
    .login_container.profile_img._x=_root.login_container.image_mask._x-1  //Set to position of profile pic.
    _root.login_container.profile_img._y=_root.login_container.image_mask._y-1
    _root
    .login_container.profile_img.setMask(null)  //Reset mask to be null to have multiple attempts at uploading images.
    _root.login_container.profile_img.setMask(_root.login_container.image_mask)// Set profile_img to have a mask named image_mask.
    _root.resize() //Call resize event to refresh centering.
    }; 
    On lines 86 of the scripting section called onFrame(2) when you click the login_btn to submit your user name it checks if user name length is greater than 0 to proceed.
    Once _root.logged_in is set to true you can call _root.resize so that _root.resize() can make the login form invisible & also make the answering section visible:
    PHP Code:
    _root.login_container.login_btn.onRelease=function(){
    if(
    _root.login_container.name_txt.text.length>0){
    _root.user_name=_root.login_container.name_txt.text
    _root
    .main.questions.open.data.Questions[_root.main.questions.open.data.array[0]][20]=_root.login_container.name_txt.text
    _root
    .logged_in=true
    _root
    .resize()
    }else{
    _root.login_container.data_field.text="Please enter your name to sign in." //If failed to submit a user name, give the user a text notice.
    }

    Inside of the resize function at the onFrame(2) scripting section I set the resize event to update the size & position of the movieclip called login_container that stores the profile image & user name for display:
    PHP Code:
    if(Stage.width>Stage.height){
    _root.login_container._width=Stage.height/2   // If the stage width is greater than the stage height resize based on Stage.height/2.
    _root.login_container._yscale=_root.login_container._xscale
    }else if(Stage.height>Stage.width){
    _root.login_container._width=Stage.width/2  // If the stage width is greater than the stage height resize based on Stage.width/2.
    _root.login_container._yscale=_root.login_container._xscale

    Also at the center of the resize function at the scripting section called onFrame(2) you can see that the centering script is there as well:
    PHP Code:
    _root.login_container._x=Stage.width/2-_root.login_container._width/2   // Get Stage.width/2 which is the half size of the stage and subtract by half size of the login_container with the registration point at the top left.
    _root.login_container._y=Stage.height/2-_root.login_container._height/
    download v23
    Last edited by AS3.0; 11-24-2022 at 08:55 PM.

  18. #38
    Senior Member
    Join Date
    May 2016
    Posts
    451
    I tested the file but the image did not work

  19. #39
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Ok 1 sec, as2 might be limiting certain directories if they aren't specified/same folder.

    We can assign it a specific file path that the image will be in?
    Last edited by AS3.0; 11-25-2022 at 04:47 PM.

  20. #40
    Senior Member
    Join Date
    May 2016
    Posts
    451
    in the same folder but the image did not work

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