A Flash Developer Resource Site

Page 3 of 5 FirstFirst 12345 LastLast
Results 41 to 60 of 89

Thread: Random SharedObject

  1. #41
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,368
    4mb png/30kb jpg works another jpg that was 2mb might need a different procedure if it is auto-closing. Is this causing your swf to close? please provide detailed information, file format, size, name.
    Last edited by AS3.0; 11-25-2022 at 05:19 PM.

  2. #42
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,368
    Crash fix for next startup when setting image:

    download v24
    Last edited by AS3.0; 11-25-2022 at 05:50 PM.

  3. #43
    Senior Member
    Join Date
    May 2016
    Posts
    385
    working fine
    can you delete register in second open ( only image appear )

  4. #44
    Senior Member
    Join Date
    May 2016
    Posts
    385
    we forgot adding timer every question

    timer load number from txt external file

  5. #45
    Senior Member
    Join Date
    May 2016
    Posts
    385
    Greetings to you

    You helped me a lot and I learned a lot from you


    I saw some templates found in it

    1- at the first time :


    After logging in, a welcome message appears with the name of the student with his picture.
    When the message is closed, questions appear with the timing.
    When clicking on the answers, a confirmation message appears.
    After choosing the answer, another message appears indicating whether the answer is correct or incorrect.


    2- The second time :

    A welcome message appears with the student's name, but there are two buttons, the first for questions and the second for the report

    I don't know if Actioncript2 is able creating this template

    But I am sure that you are the king of Actioncript2 and you can do it

    good luck

  6. #46
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,368
    Hello, you can clear sharedObject memory by pressing the Report Questions title.

    I removed some spacing issues at the questions scripting section:
    PHP Code:
    function adjustOffset(){
    if(
    _root.main.questions.open.data.QuestionNum<_root.main.question_number_size&&_root.main.report_container.report.content._y==0){
    _root.main.questions.offset_for_print_btn=12
    _root
    .main.questions.offset_for_print_btn_2=0
    }else  if(_root.main.questions.open.data.QuestionNum>=_root.main.question_number_size){
    _root.main.questions.offset_for_print_btn_2=0
    _root
    .main.questions.offset_for_print_btn=0
    }else{
    _root.main.questions.offset_for_print_btn=0
    _root
    .main.questions.offset_for_print_btn_2=12
    }

    At the main(2) scripting section the tryAutoLogin() function attempts to retrieve a username from shared memory to auto login, _root.main.questions.open.data.Questions[_root.main.questions.open.data.array[0]][20]:
    PHP Code:
    function tryAutoLogin(){
    if(
    _root.main.questions.open.data.Questions[_root.main.questions.open.data.array[0]][20]!=undefined){
    _root.login_container.name_txt.text=_root.main.questions.open.data.Questions[_root.main.questions.open.data.array[0]][20]
    _root.user_name=_root.login_container.name_txt.text
    _root
    .logged_in=true
    log_in_pressed
    =true;
    _root.resize()
    }
    }
    setTimeout(tryAutoLogin,1

    At the main(2) scripting section if login_btn gets called by pressing login it stores the username in [20] & next startup will attempt tryAutoLogin:
    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 //Save username to sharedobject if textfield size is > 0.
    _root.logged_in=true
    log_in_pressed
    =true;
    _root.resize()
    }else{
    _root.login_container.data_field.text="Please enter your name to sign in."
    }

    download v25

  7. #47
    Senior Member
    Join Date
    May 2016
    Posts
    385
    that's awesome

  8. #48
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,368
    Hi, This is for the first sign in.

    Once the user clicks login, it will call the function build_first_login() at the scripting section called onFrame(2):
    PHP Code:
    function build_first_login(){
    _root.bg_first_sign_in._width=Stage.width
    _root
    .bg_first_sign_in._height=Stage.height
    _root
    .bg_first_sign_in._x=0
    _root
    .bg_first_sign_in._y=0
    _root
    .first_sign_in_container._alpha=1;
    _root.first_sign_in_container.data_field.text="Welcome, "+_root.main.questions.open.data.Questions[_root.main.questions.open.data.array[0]][20]
    _root.first_sign_in_container.data_field2.text="Your assignment will begin shortly."
    img_loader.loadClip(str_root.first_sign_in_container.profile_picture);
    setTimeout(firstStartOfTest,8000); //Wait 8 seconds for the assignment to start if that is a good wait.

    At the scripting section called _root.main.questions for the enterFrame function I added an alpha increase animation for the first sign in:
    PHP Code:
    var modular:Number=0
    var position:Number=0
    var arr:Array=new Array("",".","..","...");
    onSelfEvent (enterFrame) {
     
    modular++;
    if(
    _root.first_sign_in_container._visible){
    if(
    _root.first_sign_in_container._alpha<100){
    _root.first_sign_in_container._alpha+=3
    }
    if(
    modular%5==0){
    if(
    position<3){
    position++;
    }else{
    position=0;
    }
    _root.first_sign_in_container.data_field2.text="Your assignment will begin shortly"+arr[position]//Waiting animation for the text.
    }
    }              

    For the first start of the test to appear properly in 8 seconds you will need to set _root.first_log_in back to false & _root.logged_in to true as well as _root.bg_first_sign_in._visible to false:
    PHP Code:
    function firstStartOfTest(){
    _root.first_log_in=false
    _root
    .logged_in=true
    _root
    .bg_first_sign_in._visible=false
    _root
    .resize()//Call resize() to update certain sizes & content.

    download v26
    Last edited by AS3.0; 11-27-2022 at 08:11 PM.

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

    In the settings.txt file you will see each question has a start time for array position [8] of the sharedObject memory:
    PHP Code:
    1-&q1=@1+1@9@6@3@2@null@null@0:0:
    Call setTime("0:0:0"); function to set & start the timer in the onFrame(2) scripting section:
    PHP Code:
    var time:String="0:0:00"
    var timer_timeout=null
    function increaseTime(){
    if(
    parseInt(time.split(":")[2])<10){
    time=time.split(":")[0]+":"+time.split(":")[1]+":"+"0"+time.split(":")[2]
    }
    _root.main.timer_mc.timer_text.text=time
    time
    =time.split(":")[0]+":"+time.split(":")[1]+":"+String(parseInt(time.split(":")[2])+1)
    if(
    time.split(":")[2]=="60"){
    time=time.split(":")[0]+":"+time.split(":")[1]+":"+"0"
    time=time.split(":")[0]+":"+String(parseInt(time.split(":")[1])+1)+":"+time.split(":")[2]
    if(
    time.split(":")[1]=="60"){
    time=String(parseInt(time.split(":")[0])+1)+":"+"0"+":"+time.split(":")[2]
    }
    }
    _root.main.questions.open.data.Questions[_root.main.questions.open.data.array[_root.main.questions.open.data.QuestionNum]][8]=String(time)   
    timer_timeout=setTimeout(increaseTime,1000);

    }
    function 
    setTime(a){
    time=a;
    increaseTime();

    The accessor for the timer movieclip & textfield is:
    PHP Code:
    _root.main.timer_mc//Movieclip.
    _root.main.timer_mc.timer_text.text//Textfield. 
    For buttons wrong1, wrong2, wrong3 & true_answer I added a clearTimeout call & set a new time with _root.setTime():
    PHP Code:
    clearTimeout(_root.timer_timeout);//stop the timer.
    _root.setTime(String(_root.main.questions.open.data.Questions[_root.main.questions.open.data.array[_root.main.questions.open.data.QuestionNum]][8]));//start a new timer for the next question. 
    download v27
    Last edited by AS3.0; 11-28-2022 at 04:05 AM.

  10. #50
    Senior Member
    Join Date
    May 2016
    Posts
    385
    hello
    for example
    timer = 20 sec

    when i press

    timer --

    If the timing ends without an answer, the status in the report is unanswered and go to the next question

  11. #51
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,368
    Hi,

    The quickest method to save questions as unanswered was to copy the script from wrong1 & put it inside a function called notAnswered() in the scripting section onFrame(2):
    PHP Code:
    var time:String="0:0:00"
    var timer_timeout=null
    function decreaseTime(){
    timer_timeout=setTimeout(decreaseTime,1000);
    var 
    hours:Number=parseInt(time.split(":")[0])
    var 
    minutes:Number=parseInt(time.split(":")[1])
    var 
    seconds:Number=parseInt(time.split(":")[2])
    if(
    seconds>-1){
    seconds--
    time=hours+":"+minutes+":"+seconds
    if(seconds==-1&&minutes>0){
    minutes--
    seconds=59
    time
    =hours+":"+minutes+":"+seconds
    }else if(seconds==-1&&minutes==0&&hours>0){
    hours--
    minutes=59
    seconds
    =59
    time
    =hours+":"+minutes+":"+seconds
    }
    }

    if(
    seconds<10){
    time=String(hours+":"+minutes+":"+"0"+seconds)
    }
    if(
    hours==0&&minutes==0&&seconds==0){
    time=String(hours+":"+minutes+":"+"00")
    clearTimeout(timer_timeout)
    trace("complete")
    _root.main.scrollToMin()

    notAnswered() //Call notAnsweredFunction
    //clearTimeout(_root.timer_timeout);
    //_root.setTime(String(_root.main.questions.open.data.Questions[_root.main.questions.open.data.QuestionNum+1][8]));
    _root.main.scrollToMax()

    }
    _root.main.questions.open.data.Questions[_root.main.questions.open.data.QuestionNum+1][8]=String(time)
    _root.main.timer_mc.timer_text.text=time



    To clear the previous questions timer & start a new timer for the next question, you would call clearTimeout & also _root.setTime("0:0:20"):
    PHP Code:
    clearTimeout(_root.timer_timeout);
    _root.setTime(String(_root.main.questions.open.data.Questions[_root.main.questions.open.data.QuestionNum+1][8])); 
    download v28
    Last edited by AS3.0; 11-28-2022 at 08:15 PM.

  12. #52
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,368
    I disabled the printing button during the middle of the exam so it doesn't pause the timer with the dialog, but there might be work arounds if you are interested.

    Once you reach the final question the print button goes to 100 alpha & gets enabled.

    download v29
    Last edited by AS3.0; 11-28-2022 at 08:51 PM.

  13. #53
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,368
    Hello,

    You can call set_up_options(true) on the onFrame(2) scripting section at lines 111 to display the 2 button options:
    PHP Code:
    var active_options:Boolean=false;
    function 
    set_up_options(a){
    active_options=a;
    _root.bg_options._x=0//setup grey bg to be at 0 x & 0 y.
    _root.bg_options._y=0
    _root
    .bg_options._width=Stage.width//Set the background to be the stage width and height.
    _root.bg_options._height=Stage.height

    _root
    .view_report._width=Stage.height/3
    _root
    .view_report._yscale=_root.view_report._xscale
    _root
    .view_report._x=Stage.width/4-_root.view_report._width/2
    _root
    .view_report._y=Stage.height/2-_root.view_report._height/2

    _root
    .continue_test._width=Stage.height/3
    _root
    .continue_test._yscale=_root.continue_test._xscale
    _root
    .continue_test._x=Stage.width-_root.continue_test._width-_root.view_report._x
    _root
    .continue_test._y=Stage.height/2-_root.continue_test._height/2

    resize
    ()//Call resize to refresh, the resize event will see _root.active_options is set to true.

    In the same onFrame(2) scripting section I setup an on release event for the continue test button:
    PHP Code:
    _root.continue_test.onRelease=function(){
     
    set_up_options(false);
     
    _root.login_container.name_txt.text=_root.main.questions.open.data.Questions[_root.main.questions.open.data.array[0]][20]
    _root.user_name=_root.login_container.name_txt.text
    _root
    .logged_in=true
    log_in_pressed
    =true;
    img_loader.loadClip(str_root.welcome_notice.profile_picture);
    _root.welcome_notice.data_field.text="Welcome, "_root.user_name
    _root
    .welcome_notice._visible=true
    clearTimeout
    (_root.timer_timeout);
    _root.setTime(String(_root.main.questions.open.data.Questions[_root.main.questions.open.data.QuestionNum+1][8]));
    _root.resize()


    download v30

  14. #54
    Senior Member
    Join Date
    May 2016
    Posts
    385
    It's great that you explain to us what you're doing
    thank you so much

  15. #55
    Senior Member
    Join Date
    May 2016
    Posts
    385
    can you add image to every question ( load from external images folder )

  16. #56
    Senior Member
    Join Date
    May 2016
    Posts
    385
    there is a big problem
    When i change the file name, all data stored in SharedObject is erased

    can you solve it please (very important)

  17. #57
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,368
    Hello,

    In the trueAnswe function at the questions scripting section you can see I added this line to load an image each question, you just have to modify the file path to yours.
    PHP Code:
    _root.img_loader.loadClip("C:\\Users\\Desktop\\Desktop\\photos\\photo_"+String(_root.main.questions.open.data.QuestionNum+1)+".png",_root.question_photo);     //The photo will load into _root.question_photo which is the red square at the bottom of the stage. 
    Inside of the resize function at the onFrame(2) scripting section the question_photo will not be visible if active_options is enabled.
    PHP Code:
    if(_root.active_options){
    _root.question_photo._visible=false//Photo for test is not visible when the 2 buttons are present.
    }else{

    On lines 140 of the scripting section called onFrame(2), once the user selects button called continue_test, the question photo can be visible.
    PHP Code:
    _root.continue_test.onRelease=function(){
    _root.question_photo._visible=true

    Also inside of the resize function at the onFrame(2) scripting section, when stage width is wider than stage height we can put:
    PHP Code:
    _root.question_photo._width=_root.main.questions.text_container._width/1.2
    _root
    .question_photo._yscale=_root.question_photo._xscale
    _root
    .question_photo._x=int(_root.main.questions.text_container._x/2)-_root.question_photo._width/2//-(_root.main.report_container.report._width/14.4)
    _root.question_photo._y=(Stage.height-_root.main.report_container._y)/
    When stage height is greater than stage width we can modify the placement to be a bit different for the question photo to look right.:
    PHP Code:
    _root.question_photo._width=_root.main.questions.text_container._width/1.2
    _root
    .question_photo._yscale=_root.question_photo._xscale
    _root
    .question_photo._x=int(Stage.width-_root.main.questions.text_container._x-_root.main.questions.text_container._width)/2-_root.question_photo._width/2
    _root
    .question_photo._y=(_root.main.questions.text_container._y+_root.main.questions.text_container._height/2)-_root.question_photo._height/
    I don't understand your settings.txt issue, but you have to use the new settings.txt in order for the test to work properly.

    Also you can fix any loading issue by clicking the red title during the test & reloading.


    download v31
    Last edited by AS3.0; 11-30-2022 at 01:54 AM.

  18. #58
    Senior Member
    Join Date
    May 2016
    Posts
    385
    have you any solution to fix if you rename file , all data stored in SharedObject is erased

  19. #59
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,368
    1.)You are on question 5.
    2.)You close the application.
    3.)You rename settings.txt on the desktop to a.txt
    4.)You re-opening the application.
    5.)You are not on question 5 anymore?



    At the questions scripting section you have to set settings.txt to the name of your text file.
    PHP Code:
    var open:SharedObject SharedObject.getLocal("storedFile1");
    loadV.load("settings.txt"); 
    If you are having undefined issues, you can click the red title during the test and restart the application.

    Can you show a screenshot? I don't see your issue.
    Last edited by AS3.0; 11-30-2022 at 04:36 PM.

  20. #60
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,368
    Hi, I worked on some of the report preview section at the main menu:

    On the scripting section called onFrame(2) I added an onRelease event for the button that says view report:
    PHP Code:
    _root.view_report.onRelease=function(){//View report button on release.
    _root.view_report._visible=false//Hide the first button if previewing the report.
    _root.continue_test._visible=false//Hide the second button if previewing the report.
    _root.report_preview._visible=true//Make the container for the report visible.
    _root.main.report_container.report.updateReport(0xFF0000,_root.report_preview,_root.main.questions.open.data.QuestionNum+1//Fill the container of the report with data.
    _root.main.report_container.report.updateColors(_root.report_preview,,  _root.main.questions.open.data.QuestionNum+1); //Fill the container of the report with highlighted selected answers.

    _root.report_preview._xscale=100//Reset x scale & y scale before readjusting size to fit the stage.
    _root.report_preview._yscale=100
    if( _root.report_preview._width*2<Stage.width){
     
    _root.report_preview._width*=2//Multiply the size by 2's to maintain quality.
     
    _root.report_preview._yscale_root.report_preview._xscale//maintain y scale by checking xscale.

    On line 161 of the scripting section called onFrame(2) this is the button listener for the x_preview button.
    PHP Code:
    _root.x_preview.onRelease=function(){//X button for the report viewing section on release.
    _root.main.report_container.report.reset_container(_root.report_preview,1_root.main.questions.open.data.QuestionNum+1);//Reset container to be empty once you click X.
    _root.x_preview._visible=false//Make the x button invisible.

    _root.view_report._visible=true//Make the 2 menu buttons visible again.
    _root.continue_test._visible=true
    _root
    .report_preview._visible=false//Hide the report preview once at the main menu.

    I still need to add a scroll pane for the main menu report preview, would you like a horizontal scroll pane for the test when the stage width is made small?

    download v32
    Last edited by AS3.0; 11-30-2022 at 11:59 PM.

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