A Flash Developer Resource Site

Page 3 of 3 FirstFirst 123
Results 41 to 52 of 52

Thread: Random SharedObject

  1. #41
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,289
    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,289
    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
    307
    working fine
    can you delete register in second open ( only image appear )

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

    timer load number from txt external file

  5. #45
    Senior Member
    Join Date
    May 2016
    Posts
    307
    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,289
    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
    307
    that's awesome

  8. #48
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,289
    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; Yesterday at 08:11 PM.

  9. #49
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,289
    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; Today at 04:05 AM.

  10. #50
    Senior Member
    Join Date
    May 2016
    Posts
    307
    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,289
    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; Today at 08:15 PM.

  12. #52
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,289
    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; Today at 08:51 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