hello,all
https://f.top4top.net/p_674cv6d21.jpg
hello,all
https://f.top4top.net/p_674cv6d21.jpg
please help
Here's the page to refer to for loadVariables https://help.adobe.com/en_US/as2/ref...c47f-7fec.html
For anything more could you upload your file?
my file
excuse me this is my file
I'm having trouble working swishmax. Could you share all the code in a text file?
the button code isPHP Code:
on (press) {
var i:int = Math.randomRange(1,30)
if ( i ==1){
// my request is when i = 1 , the var which named (question ) load question number 1 from settings.txt and when i = 2 ,question number 2 and so on
question = question1
this.loadVariables("settings.txt");
}else if ( i ==2){
question = question2
this.loadVariables("settings.txt");
}else if ( i ==3){
question = question3
this.loadVariables("settings.txt");
}
}
settings.txt is:
PHP Code:
&question1= put here any question &
&question2= put here any question &
&question3= put here any question &
Hi,
I don't have swishmax but this is one way to do it in as3, perhaps you can get something from it.
PHP Code:
import flash.net.URLLoader;
import flash.net.URLRequest;
var loader:URLLoader = new URLLoader(new URLRequest("settings.txt"));
loader.addEventListener(Event.COMPLETE, varsLoaded);
function varsLoaded(e:Event):void
{
e.target.removeEventListener(Event.COMPLETE, varsLoaded);
var variables:URLVariables = new URLVariables(loader.data);
var minNumber:int = 1;
var maxNumber:int = 30;
var numberRange:int = maxNumber - minNumber;
var i:int = Math.ceil(Math.random() * numberRange) + minNumber;
trace("Question " + i);
var question = variables["question" + String(i)];
trace(question);
myTextField.text = String(question);
}
Code:question1= put here any question 1
&question2= put here any question 2
&question3= put here any question 3
&question4= put here any question 4
&question5= put here any question 5
&question6= put here any question 6
&question7= put here any question 7
&question8= put here any question 8
&question9= put here any question 9
&question10= put here any question 10
&question11= put here any question 11
&question12= put here any question 12
&question13= put here any question 13
&question14= put here any question 14
&question15= put here any question 15
&question16= put here any question 16
&question17= put here any question 17
&question18= put here any question 18
&question19= put here any question 19
&question20= put here any question 20
&question21= put here any question 21
&question22= put here any question 22
&question23= put here any question 23
&question24= put here any question 23
&question25= put here any question 25
&question26= put here any question 26
&question27= put here any question 27
&question28= put here any question 28
&question29= put here any question 29
&question30= put here any question 30
sorry, not working
https://c.top4top.net/p_68902j9e1.jpg
Hi,
I didn't think it would work with swishmax as it is AS3, I don't use swishmax, but it would give you a better way of getting the correct random line for you question.
ok
what is the way to load random questions form external txt file ??????
please attach swishmax file
HI,
I repeat , I do not use or have swishmax, bu you are taking the long way round to choose your random question with all the if statements.
Looking at your original code, there are several issues to look at. First of all, the text you're loading.
This should be this instead:Code:&question1= put here any question &
&question2= put here any question &
&question3= put here any question &
The & symbol is for separating each section into different variables. The only reason I would do it would be to make it more readable. It's still wasteful. Still, having the extra space after the = sign will show up.Code:question1=put here any question1&question2=put here any question2&question3=put here any question3
This is messy in many ways. First of all, the loadVariables function loads all the vars into the object you target. Because of this you should only run it once in this case.Code:on (press) {
var i:int = Math.randomRange(1,30)
if ( i ==1){
// my request is when i = 1 , the var which named (question ) load question number 1 from settings.txt and when i = 2 ,question number 2 and so on
question = question1
this.loadVariables("settings.txt");
}else if ( i ==2){
question = question2
this.loadVariables("settings.txt");
}else if ( i ==3){
question = question3
this.loadVariables("settings.txt");
}
}
The next part is loading external data take a bit. So you need to set up an interval. This is basically a function that keeps activating a target function over the time you set. For exampleCode:on (press) {
this.loadVariables("settings.txt");
var i:int = Math.randomRange(1,30)
if ( i ==1){
// my request is when i = 1 , the var which named (question ) load question number 1 from settings.txt and when i = 2 ,question number 2 and so on
question = question1
}else if ( i ==2){
question = question2
}else if ( i ==3){
question = question3
}
}
This creates a variable to store the interval. It will call the function checkParamsLoaded every 100 milliseconds.Code:var param_interval = setInterval(checkParamsLoaded, 100);
After moving things around, this is what I came up with. First I divided the code into two different areas. One is on the button and the other is on the base timeline. For the button, this is my code:
On the root timeline this is the rest of the code:Code:on (press) {
this.loadVariables("settings.txt");
_root.param_interval = setInterval(_root.tFun, 100);
}
I also added another variable to be loaded from the settings.txt file: "&done=done" This is good for indicating that the file has been loaded.Code:function randRange(min:Number, max:Number):Number {
return Math.floor(Math.random()*(max-min+1))+min;
}
function tFun() {
trace("-=-=-");
trace("-"+btn["question"+randRange(1,3)]+"-");
if (btn.done == "done") {
clearInterval(param_interval);
}
}
var param_interval;
In the end, I used https://help.adobe.com/en_US/as2/ref...c47f-7fec.html as a reference for what I was looking at. I also was using flash instead of swishmax. swishmax is giving me trouble to set up.
i try to understand but i am sorry not working or i don't understand the idea
The last two code areas from my last post is the working code I came up with.