-
Random SharedObject
hello all
this is my new project in swishmax
https://board.flashkit.com/board/ima.../2022/10/2.jpg
The file loads randomly questions from a text file
The student answers only 5 questions per day
How to save the questions answered in the report ( textscroll ) by SharedObject method or any
and On the next day, when you open the file again, it completes the questions without repeating the questions that were answered
and add a new data in the report
and so on
the report contains the question and 4 answered and true or false
swishmax file : https://app.box.com/s/0g84psgzvj5ww1cfzn4bhdan1fgbmvw1
thanks for help
-
https://open-flash.github.io/mirrors...redObject.html There are some code examples you can get a start with.
-
thanks swake
I read this but I don't know how to do it
i need your experience to make this project together as you helped me in the past
-
Hello, I added an open day which means if the settings.txt says 11/2/2022 & computer date says 11/1/2022, tomorrow it will be unlocked.
To show a snippet, I just send the openDay function the open date from settings.txt
PHP Code:
function openDay(a){
var temp_month=(a.split(";")[0])
var temp_day=(a.split(";")[1])
var temp_year=(a.split(";")[2]);
//temp_month + " " +temp_day + " " + temp_year + " " +
//_root.questions.data_field3.text=temp_month==(current_month_number) //+ " " +temp_month + " " +temp_day + " " + temp_year + " " + current_month_number+" " + current_day_number + " " + current_year_number
if(temp_year==(current_year_number)&&temp_day==(current_day_number)&&temp_month==(current_month_number)){
return("unlocked");
}
if(temp_year<(current_year_number)){
return("unlocked");
}
if(temp_month<(current_month_number)&&temp_year<=(current_year_number)){
return("unlocked");
}
if(temp_day<=(current_day_number)&&temp_month<=(current_month_number)&&temp_year<=(current_year_number)){
return("unlocked");
}
return("locked");
}
download v2
-
welcome AS3.0
let's start together again
i have an idea
We create an array when the file is run the first time and store the questions numbers in it
Then the questions are called in the following through this array
I made this code, but I need your expertise to complete the code
PHP Code:
onSelfEvent (load) {
var open:SharedObject = SharedObject.getLocal("storedFile");
open.data.array || []; // array to save questions numers
if (open.data.first_run ==undefined){;
trace("first time")
open.data.first_run =0 // to delete load questions again in the next run
// start to load questions and answers from txt file
loadV = new LoadVars();
MyArray = new Array();
loadV.load("settings.txt");
loadV.onData = function(s) {
p = s.split('&');
for(i=1; i < p.length; i++) {
MyArray[i]=p[i].split('@');
}
var numbers: Array = new Array();
for (var i: int = 1; i < p.length; i++) {
numbers.push(i);
}
numbers = numbers.sort(function (a:int, b:int):int { return Math.random() > .5 ? -1 : 1; });
trace(numbers)
}
//end load questions and answers from txt file
// here how to save these random numbers in (open.data.array SharedObject )
// to use it in scand open
}
else if (open.data.first_run ==0){ // if this is the scand open
trace("scand open");
//here how to load and complete the questions
}
open.flush()
//open.clear(); // enable this code to delete all stored data to check your code again
}
onSelfEvent (enterFrame) {
/* // i disable this code until any help about this idea
question.text = MyArray[numbers[num]][1].split("q"+numbers[0]+"=");
wrong1.text = MyArray[numbers[num]][2].split("q"+numbers[0]+"=") ;
wrong2.text = MyArray[numbers[num]][3].split("q"+numbers[0]+"=") ;
wrong3.text = MyArray[numbers[num]][4].split("q"+numbers[0]+"=") ;
true_answer.text = MyArray[numbers[num]][5].split("q"+numbers[0]+"=") ;
total.text=" question No : " add (_root.questions.num+1) add " from " add (_root.questions.p.length-1)
score.text=" your score is : " add (int(_root.questions.scorePOINT)) add " from " add (_root.questions.p.length-1)
*/
}
onFrame (1) {
stop();
}
swishmax file :https://app.box.com/s/c6lc3fd2zsm9ysprswhw9lcrgu0cvq4b
-
hello all
https://board.flashkit.com/board/ima.../2022/11/1.jpg
i have succeeded in :
1- Random numbers are stored
2- load the questions and answers from SharedObject
3- Complete the questions at the last question answered
4- Create a report table.
but
There are still many things that need help:
1- Is there a way to make the report in a professional and easy way?
2- How to change the position of the answers in a random way(This of course will change the position of the answers in the report)
3- After loading the questions and answers in the report, how can the report be printed?
questions script:
PHP Code:
onSelfEvent (load) {
var open:SharedObject = SharedObject.getLocal("storedFile");
open.data.Questions || []; // to save questions and answers
open.data.array || []; // to save random number
if (open.data.first_run ==undefined){;
trace("first time");
open.data.first_run =0 // to delete load questions again in the next run
open.data.QuestionNum= 0 // to save questions answered
open.data.POINT=0;
//trace(open.data.QuestionNum)
// start to load questions and answers from txt file
loadV = new LoadVars();
MyArray = new Array();
loadV.load("settings.txt");
loadV.onData = function(s) {
p = s.split('&');
for(i=1; i < p.length; i++) {
MyArray[i]=p[i].split('@');
}
open.data.Questions=MyArray;
var numbers: Array = new Array();
for (var i: int = 1; i < p.length; i++) {
numbers.push(i);
}
numbers = numbers.sort(function (a:int, b:int):int { return Math.random() > .5 ? -1 : 1; });
//trace(numbers);
open.data.array=numbers;
trace(open.data.array);
trace(open.data.QuestionNum);
}
}
else if (open.data.first_run ==0){ // if this is the scand open
trace("scand open");
//here how to load and complete the questions
trace(open.data.array);
trace(open.data.QuestionNum);
}
open.flush()
//open.clear(); // enable this code to delete all stored data to check your code again
TrueAnswe ()
}
onSelfEvent (enterFrame) {
if(open.data.first_run ==0){TrueAnswe ()}
}
onFrame (1) {
stop();
}
function TrueAnswe () {
question.text = open.data.Questions[open.data.array[open.data.QuestionNum]][1];
wrong1.text = open.data.Questions[open.data.array[open.data.QuestionNum]][2];
wrong2.text = open.data.Questions[open.data.array[open.data.QuestionNum]][3];
wrong3.text = open.data.Questions[open.data.array[open.data.QuestionNum]][4] ;
true_answer.text = open.data.Questions[open.data.array[open.data.QuestionNum]][5] ;
total.text=" question No : " add (open.data.QuestionNum+1) add " from " add (open.data.array.length)
score.text=" your score is : " add (open.data.POINT) add " from " add (open.data.array.length)
}
report script:
PHP Code:
onFrame (1) {
stop();
for( var i:int = 0; i < _root.main.questions.open.data.array.length+1 ; ++i ){
// create question number table
this.createTextField("num"+i, this.getNextHighestDepth(), 50, , 40,22);
this["num"+i]._y=(i*22)+1
this["num"+i].border = true;
this["num"+i].text = String(i);
this["num"+0].text = "Num";
this["num"+i].selectable=false
// create question table
this.createTextField("Question"+i, this.getNextHighestDepth(), 92, , 200,22);
this["Question"+i]._y=(i*22)+1
this["Question"+i].border = true;
this["Question"+i].text = "Loadind...";
this["Question"+0].text = "Question";
this["Question"+i].selectable=false;
// create Answer A table
this.createTextField("answerA"+i, this.getNextHighestDepth(), 293, , 100,22);
this["answerA"+i]._y=(i*22)+1
this["answerA"+i].border = true;
this["answerA"+i].text = "Loadind...";
this["answerA"+0].text = "answer A";
this["answerA"+i].selectable=false
// create Answer A table
this.createTextField("answerB"+i, this.getNextHighestDepth(), 393, , 100,22);
this["answerB"+i]._y=(i*22)+1
this["answerB"+i].border = true;
this["answerB"+i].text = "Loadind...";
this["answerB"+0].text = "answer B";
this["answerB"+i].selectable=false
// create Answer C table
this.createTextField("answerC"+i, this.getNextHighestDepth(), 493, , 100,22);
this["answerC"+i]._y=(i*22)+1
this["answerC"+i].border = true;
this["answerC"+i].text = "Loadind...";
this["answerC"+0].text = "answer C";
this["answerC"+i].selectable=false
// create Answer D table
this.createTextField("answerD"+i, this.getNextHighestDepth(), 593, , 100,22);
this["answerD"+i]._y=(i*22)+1
this["answerD"+i].border = true;
this["answerD"+i].text = "Loadind...";
this["answerD"+0].text = "answer D";
this["answerD"+i].selectable=false
// create Result table
this.createTextField("Result"+i, this.getNextHighestDepth(), 693, , 70,22);
this["Result"+i]._y=(i*22)+1
this["Result"+i].border = true;
this["Result"+i].text = "true or false";
this["Result"+0].text = "Result";
this["Result"+i].selectable=false
var myformat:TextFormat = new TextFormat();
myformat.size=13 ;
myformat.color = 0xFF0000;
myformat.bold=true;
myformat.align="center";
this["Question"+i].setTextFormat(myformat);
this["Question"+0].setTextFormat(myformat);
this["num"+i].setTextFormat(myformat);
this["num"+0].setTextFormat(myformat);
this["answerA"+i].setTextFormat(myformat);
this["answerA"+0].setTextFormat(myformat);
this["answerB"+i].setTextFormat(myformat);
this["answerB"+0].setTextFormat(myformat);
this["answerC"+i].setTextFormat(myformat);
this["answerC"+0].setTextFormat(myformat);
this["answerD"+i].setTextFormat(myformat);
this["answerD"+0].setTextFormat(myformat);
this["Result"+i].setTextFormat(myformat);
this["Result"+0].setTextFormat(myformat);
}
}
Random SharedObject V4 file : https://app.box.com/s/xu0uolljdnp4mkd440of1bb8dmnu2ufd
-
Hello for #2 I added a function called randomizeOrder() that will reorder the x & y coordinates by memorizing the original way they were placed in another array called coordinates.
Inside of the true_answer button you can call this each time, to create a new order.
PHP Code:
_root.main.questions.randomizeOrder();
The randomBetween function is inside of the questions section.
PHP Code:
function randomBetween(a,b){
return(Math.floor(Math.random()*(b-a+1))+a);
}
The randomizeOrder function is inside of the questions section.
PHP Code:
function randomizeOrder(){
var main_array:Array=new Array(wrong1,wrong2,wrong3,true_answer)
var main_array2:Array=new Array(wrong1,wrong2,wrong3,true_answer)
var coordinates:Array=new Array();
var numbers:Array=new Array(0,1,2,3);
var new_order:Array=new Array();
for(var i=0;i<4;i++){
coordinates.push(main_array[i]._x);
coordinates.push(main_array[i]._y);
new_order.push(numbers.splice(randomBetween(0,numbers.length-1),1));
}
var pos=0
for(var i=0;i<4;i++){
main_array[new_order[i]]._x=coordinates[pos]
main_array[new_order[i]]._y=coordinates[pos+1]
pos+=2
}
}
download v5
-
thanks AS3.0
my solution is :
PHP Code:
function postion () {
var i:int=int(Math.randomRange(1,5)) ;
if(i==1){
wrong1._y = 300.05;
wrong2._y =338.95 ;
wrong3._y =377.9 ;
true_answer._y = 416.8 ;
}
else if(i==2){
true_answer._y = 300.05;
wrong3._y =338.95 ;
wrong2._y =377.9 ;
wrong1._y = 416.8 ;
}
else if(i==3){
wrong1._y = 300.05;
true_answer._y =338.95 ;
wrong2._y =377.9 ;
wrong3._y = 416.8 ;
}
else if(i==4){
wrong3._y = 300.05;
wrong1._y =338.95 ;
true_answer._y =377.9 ;
wrong2._y = 416.8 ;
}
}
but your solution is professional
now can you help me to make the report
-
Hello, I have created a solution to fill the report as the questions get answered.
So I took some of the program from the report & used it for the TrueAnswe function at the questions section.
In the TrueAnswe function if _root.attempt==1 & the text field wasn't already set as incorrect, we can put it as correct.
Each button press will increase the _root.attempt number, if it is only 1 attempt we can save the answer as a correct answer.
PHP Code:
if(_root.attempt==1&& _root.main.questions.open.data.Questions[open.data.QuestionNum][6]!="incorrect"){
_root.main.questions.open.data.Questions[open.data.QuestionNum][6]="correct";
_root.main.report["Result"+(open.data.QuestionNum)].text ="correct";
_root.attempt=0 //Once you are on the next question it will reset _root.attempt to equal 0
}else if(_root.attempt>1&&_root.main.report["Result"+(open.data.QuestionNum)].text!="correct"&&_root.main.report["Result"+(open.data.QuestionNum)].text!="Result"){
_root.main.questions.open.data.Questions[open.data.QuestionNum][6]="incorrect";
_root.main.report["Result"+(open.data.QuestionNum)].text ="incorrect";
}
Once we reach the final question:
1.)Should I enlarge the report for printing? btw printing can be done using the flash client. File > Print, or is this for a browser.
2.)Show a percentage?
3.)The report is only supposed to show up once the last question is reached?
download v6
-
I had to fix the order for the report:
[open.data.QuestionNum-1] is 1-10 & increments as you answer each question to retrieve the scrambled array position in order for _root.main.questions.open.data.array, the scrambled array position at this level is for _root.main.questions.open.data.Questions which will give you the correct or incorrect type based on how the question was answered in [6], [6] has "correct", "incorrect" or "null" saved.
PHP Code:
_root.main.questions.open.data.Questions[_root.main.questions.open.data.array[open.data.QuestionNum-1]][6]
download v7
-
Here is a bug fix from v7 that wasn't updating the data properly without the table being visible:
download v8
-
-
Oh, that was unnecessary to place.
If you get to the final question you will see the report.
download v8
-
very good
1-Is it possible for the question to appear in the report immediately after the answer?
2- Can the student’s answer be in a different color?
3- When the wrong choice is made, it moves to the next question
4- can you make a scroll for the report
-
Hi, This answers question 1 & 3.
Inside of report we can go with having the borders set to false if the question is unanswered:
PHP Code:
this["num"+i].border = false; //hide border for unanswered questions
I also sampled the background graphics hex value and set the text to be the same color as the background:
PHP Code:
myformat.color = 0xFFFFCC; //hide color for unanswered questions
As open.data.QuestionNum number increases from selecting choices we can call trueAnswe at the questions section to enable .border to be true as well as set the text color to be red 0xFF0000:
PHP Code:
myformat.color = 0xFF0000; //set the color to red when a question gets answered
_root.main.report["num"+i].border = true; //set the border to be visible when a question gets answered
_root.main.report["Result"+i].border = true;
_root.main.report["answerD"+i].border = true;
_root.main.report["answerC"+i].border = true;
_root.main.report["answerB"+i].border = true;
_root.main.report["answerA"+i].border = true;
_root.main.report["Question"+i].border = true;
For buttons wrong1, wrong2, and wrong3 we can check if the current QuestionNum hasn't exceeded the array length _root.main.questions.open.data.array.length:
PHP Code:
if(_root.main.questions.open.data.QuestionNum< _root.main.questions.open.data.array.length){
_root.main.questions.open.data.QuestionNum +=1; //increase the QuestionNum by one
_root.main.report["Result"+(open.data.QuestionNum)].text ="incorrect"; //set the text as incorrect
_root.main.questions.open.data.Questions[_root.main.questions.open.data.array[open.data.QuestionNum-1]][6]="incorrect"; //save the data as incorrect
_root.main.questions.TrueAnswe () //call TrueAnswe function to enable borders for the increased QuestionNum as well as set the color of the text to red: 0xFF0000
_root.main.questions.randomizeOrder(); //randomize the of the buttons for the next question
_root.attempt=0 //reset the attempt number for the next question to start
}
download v9
-
-
Hello, this version will save the arrangement.
I acquired the order by sorting A,B,C,D by _y coordinate which works just as good, If all the program was in 1 page it would be easier.
download v10
-
-
Hi,
Above the TrueAnswe function at the questions section, I set 0x777788 to be the color of the selected answer.
PHP Code:
var selected_answer_color:Number=0x777788
Inside of the TrueAnswe function at the questions section, this snippet will check all A,B,C, & D for each row on the report, [7] is where the selected answer is stored.
PHP Code:
if(_root.main.report["answerA"+i].text==_root.main.questions.open.data.Questions[_root.main.questions.open.data.array[i-1]][7]){
myformat.color = _root.main.questions.selected_answer_color;
_root.main.report["answerA"+i].setTextFormat(myformat);
}
if(_root.main.report["answerB"+i].text==_root.main.questions.open.data.Questions[_root.main.questions.open.data.array[i-1]][7]){
myformat.color = _root.main.questions.selected_answer_color;
_root.main.report["answerB"+i].setTextFormat(myformat);
}
if(_root.main.report["answerC"+i].text==_root.main.questions.open.data.Questions[_root.main.questions.open.data.array[i-1]][7]){
myformat.color = _root.main.questions.selected_answer_color;
_root.main.report["answerC"+i].setTextFormat(myformat);
}
if(_root.main.report["answerD"+i].text==_root.main.questions.open.data.Questions[_root.main.questions.open.data.array[i-1]][7]){
myformat.color = _root.main.questions.selected_answer_color;
_root.main.report["answerD"+i].setTextFormat(myformat);
}
At the bottom of the script for each button, true_answer, wrong3, wrong2, & wrong1 this script will highlight the latest selected answer, Instead of using a full loop we can find the current selection with parseInt(_root.main.questions.open.data.QuestionNu m)-1.
PHP Code:
if(_root.main.report["answerA"+parseInt(parseInt(_root.main.questions.open.data.QuestionNum))].text==_root.main.questions.open.data.Questions[_root.main.questions.open.data.array[parseInt(_root.main.questions.open.data.QuestionNum)-1]][7]){
myformat.color = _root.main.questions.selected_answer_color;
_root.main.report["answerA"+parseInt(parseInt(_root.main.questions.open.data.QuestionNum))].setTextFormat(myformat);
}
if(_root.main.report["answerB"+parseInt(parseInt(_root.main.questions.open.data.QuestionNum))].text==_root.main.questions.open.data.Questions[_root.main.questions.open.data.array[parseInt(_root.main.questions.open.data.QuestionNum)-1]][7]){
myformat.color = _root.main.questions.selected_answer_color;
_root.main.report["answerB"+parseInt(parseInt(_root.main.questions.open.data.QuestionNum))].setTextFormat(myformat);
}
if(_root.main.report["answerC"+parseInt(parseInt(_root.main.questions.open.data.QuestionNum))].text==_root.main.questions.open.data.Questions[_root.main.questions.open.data.array[parseInt(_root.main.questions.open.data.QuestionNum)-1]][7]){
myformat.color = _root.main.questions.selected_answer_color;
_root.main.report["answerC"+parseInt(parseInt(_root.main.questions.open.data.QuestionNum))].setTextFormat(myformat);
}
if(_root.main.report["answerD"+parseInt(parseInt(_root.main.questions.open.data.QuestionNum))].text==_root.main.questions.open.data.Questions[_root.main.questions.open.data.array[parseInt(_root.main.questions.open.data.QuestionNum)-1]][7]){
myformat.color = _root.main.questions.selected_answer_color;
_root.main.report["answerD"+parseInt(parseInt(_root.main.questions.open.data.QuestionNum))].setTextFormat(myformat);
}
download v12
-
Bug fix for wrong2:
download v13
-
that's awesome
can you add scroll and print function to report
thanks so mutch
-
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=4
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
-
-
Hello, I added scroll wheel for the scroll bar, I will work on the printing task.
download v15
-
-
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
-
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
-
it prints 2 pages the same data repeated
max questions = 200
-
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
-
https://board.flashkit.com/board/ima...2021/01/3.jpeg
but resize form still problem ( if it first open before answer any question ===> when you maximize form ===>problem )
-
I fixed a scrolling bug when the list gets to 200.
download v18
-
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
-
thanks AS3.0
Thank you soooooooooooooooooooooooooo much
-
Alright I worked on the scaling.
-Happy holidays
download v20
-
Resize bug fix after print:
download v21
-
https://board.flashkit.com/board/ima.../2022/11/3.jpg
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
-
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=0
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/2
download v23
-
I tested the file but the image did not work
-
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?
-
in the same folder but the image did not work