Note that there are some explanatory texts on larger screens.

plurals
  1. POchanging Strings
    primarykey
    data
    text
    <p>well guys i have a little problem here, i have 3 containers and an XML with n nodes... i want to put in the containers, any value of the XML, this value cannot be one old value and in the containers shouldn't have the same value... i have this code in as3 but it doesn't work :S</p> <pre><code>package { import flash.display.MovieClip; import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; import flash.text.TextField; public class Pruebas extends Sprite { public var arr:Array = new Array("valor0","valor1","valor2","valor3","valor4","valor5") public var str1:String=arr[0]; public var str2:String=arr[1]; public var str3:String=arr[2]; public var te1:TextField = new TextField(); public var te2 :TextField = new TextField(); public var te3 :TextField = new TextField(); public var btn :MovieClip = new MovieClip(); public function Pruebas() { te1.text = str1; te2.text = str2; te3.text = str3; addChild(te1); addChild(te2); addChild(te3); te2.x = 50;te3.x=100; btn.graphics.beginFill(0xff00ff); btn.graphics.drawCircle(151,150,15); addChild(btn); btn.addEventListener(MouseEvent.CLICK,cambiar); } public function cambiar(e:Event):void{ var minLimit:uint = 0; var maxLimit:uint = arr.length-1; var range:uint = maxLimit - minLimit; var someNum:Number = Math.ceil(Math.random()*range) + minLimit; if(str1 == arr[someNum]){ while(str1 == arr[someNum]){ someNum = Math.ceil(Math.random()*range) + minLimit; } str1 = arr[someNum]; }else{ str1 = arr[someNum]; } someNum= Math.ceil(Math.random()*range) + minLimit; if(str2 == arr[someNum]){ while(str2 == arr[someNum]){ someNum = Math.ceil(Math.random()*range) + minLimit; } str2 = arr[someNum]; }else{ str2 = arr[someNum]; } someNum= Math.ceil(Math.random()*range) + minLimit; if(str3 == arr[someNum]){ while(str3 == arr[someNum] || str3 ==str1 || str3 == str2){ someNum = Math.ceil(Math.random()*range) + minLimit; } str3 = arr[someNum]; }else{ str3 = arr[someNum]; } te1.text = str1; te2.text = str2; te3.text = str3; } } } </code></pre> <hr> <p>Eduardo Check this code that this code I did</p> <pre><code>if(imgactual == myXML.internas.item[someNum].@numero){ while(imgactual == myXML.internas.item[someNum].@numero){ someNum = Math.ceil(Math.random()*range) + minLimit; } imgactual = myXML.internas.item[someNum].@numero }else{ imgactual = myXML.internas.item[someNum].@numero } someNum= Math.ceil(Math.random()*range) + minLimit; if((imgpostactual == myXML.internas.item[someNum].@numero) || (imgpostactual == imgactual) ){ while(imgpostactual == myXML.internas.item[someNum].@numero || imgpostactual == imgactual){ someNum = Math.ceil(Math.random()*range) + minLimit; } imgpostactual = myXML.internas.item[someNum].@numero }else{ imgpostactual = myXML.internas.item[someNum].@numero } someNum= Math.ceil(Math.random()*range) + minLimit; if((imgpreactual == myXML.internas.item[someNum].@numero) || (imgpostactual == imgpreactual) || (imgpreactual == imgactual)){ while((imgpreactual == myXML.internas.item[someNum].@numero) || (imgpostactual == imgpreactual) || (imgpreactual == imgactual)){ someNum = Math.ceil(Math.random()*range) + minLimit; } imgpreactual = myXML.internas.item[someNum].@numero; }else{ imgpreactual = myXML.internas.item[someNum].@numero; } trace(imgactual); trace(imgpreactual); trace(imgpostactual); </code></pre> <p>the bad with this code is that always the loop while takes a long time :S and i think that it doesnt work :S</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload