A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 29

Thread: This damn thing is doing my nut! Help please, "if" not working

  1. #1
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320

    This damn thing is doing my nut! Help please, "if" not working

    Hi guys,
    I am totally stumped. In stead of explaining everytrhing i will get straight to the point

    frame 1:
    load image count server
    returns 12. So we have our first var imgCount = result_lv.imgCount

    Frame 2 setup all other needed vars:
    code:

    var imgCount:Number = result_lv.imageCount;
    var nextX:Number = 0;
    var nextY:Number = 0;
    var curCol:Number = 0;
    var counter:Number = 1;


    Frame 3 run setup to display images. This is were the intial problem starts
    The if dosnt run, dosnt do anything.
    code:

    if (counter < imgCount) {
    holder.attachMovie ("imgHolder", "mod" + counter, counter);
    //
    holder["mod" + counter]._y = nextY;
    holder["mod" + counter]._x = nextX;
    //
    holder["mod" + counter].imgUrl = "media/models/" + _parent.new_edit_id + "/model_pics/" + counter + "_thumb.jpg";
    gotoAndPlay (4);
    }



    if i change imgCount from the returned result from the server to a static number then it runs and all is well.
    WTF gives????

    This is really really doing my head in and i have already wasted one day trying to figure it out.

    Please someone put me out of my missery. please......

    Paul
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Is the movie waiting on frame 1 until the variables are loaded? You might also want to use,

    var imgCount:Number = Number(result_lv.imageCount);

  3. #3
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    Yes and it dose got to the second frame. I had every bit of the code every frame with a trace on it.

    Tried this yesterday
    code:

    var imgCount:Number = Number (result_lv.imageCount);


    If i change it to
    code:

    var imgCount:Number =12


    It works a charm.
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  4. #4
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    Any ideas?
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  5. #5
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    so on frame 3 does trace(Number (result_lv.imageCount)); give the number 12?
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  6. #6
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    yes and typeof returns number
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  7. #7
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    that is really weird cant think of what it could be... give this a shot..u never know..

    Code:
    if (counter < Number (result_lv.imageCount)) {
    
    .........
    
    }
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  8. #8
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    lol

    I am a coder of 4 years...

    File is attached. Am stumped.
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  9. #9
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    one of those weird problems!!

    cant open ur file it says unexpected format
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  10. #10
    Member Pepember
    Join Date
    Jul 2001
    Location
    Berlin
    Posts
    886
    i just quickly looked at your test.fla and it didn't seem to be able to load the php, so i'll just guess around:
    after casting result_lv.imageCount to a Number and handing it to imgCount, try this in the if condition (although you probably already tried this):
    if (counter.valueOf() < imgCount.valueOf()){}

    [edit]
    forget it, i'm just too thick to configure my firewall
    so i tried what i suggested and of course it doesn't work. as does nothing else i try...this is driving me crazy...
    Last edited by theTick; 03-01-2006 at 11:41 AM.
    Please sign here

  11. #11
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    lol you not kidding 3 pages of posts sofar over at kirupa. Still trying to figure it out.
    I have it working sort of. But i need to now were the "space" is being generated.

    http://www.kirupa.com/forum/showthread.php?t=210713

    THanks for your time today
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  12. #12
    Grandmaster Flash
    Join Date
    Apr 2004
    Location
    Edinburgh, Scotland
    Posts
    139
    The PHP script seems to be broken:

    %3Cbr%20%2F%3E%0A%3Cb%3EWarning%3C%2Fb%3E%3A%20%20 opendir%28%29%3A%20open%5Fbasedir%20restriction%20 in%20effect%2E%20File%28%2Fmodel%5Fpics%29%20is%20 not%20within%20the%20allowed%20path%28s%29%3A%20%2 8%2Fhome%2Fpferrie%2F%3A%2Fusr%2Flib%2Fphp%3A%2Fus r%2Flocal%2Flib%2Fphp%3A%2Ftmp%29%20in%20%3Cb%3E%2 Fhome%2Fpferrie%2Fpublic%5Fhtml%2Ftest%2FimgList%2 Ephp%3C%2Fb%3E%20on%20line%20%3Cb%3E2%3C%2Fb%3E%3C br%20%2F%3E%0A%3Cbr%20%2F%3E%0A%3Cb%3EWarning%3C%2 Fb%3E%3A%20%20opendir%28%2Fmodel%5Fpics%29%3A%20fa iled%20to%20open%20dir%3A%20Operation%20not%20perm itted%20in%20%3Cb%3E%2Fhome%2Fpferrie%2Fpublic%5Fh tml%2Ftest%2FimgList%2Ephp%3C%2Fb%3E%20on%20line%2 0%3Cb%3E2%3C%2Fb%3E%3Cbr%20%2F%3E%0A%20=&onLoad=%5 Btype%20Function%5D

    Is this meant to return 12?

    Cheers
    If it ain't broke, don't fix it.

  13. #13
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    Sorry thats me tinkering with the file. Sorted now. file is! not the overall problem
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  14. #14
    Grandmaster Flash
    Join Date
    Apr 2004
    Location
    Edinburgh, Scotland
    Posts
    139
    Ok - I can see that retval is returning:

    retval=1%20&imageCount=13&onLoad=%5Btype%20Functio n%5D

    Can you remove the space (URL encoded in the above string in the PHP script). I think that may be your problem. If I do :

    Code:
    loadGal = function () {
    	trace ("check load gallery running?");
    	var result_lv:LoadVars = new LoadVars ();
    	
    	
    	result_lv.onLoad = function (success) {
    		trace ("sucess=" + success);
    		trace(result_lv);
    		if (success) {
    			trace("RV = " + result_lv.retval + "*");
    			trace(Number(result_lv.retval));
    			if (Number(result_lv.retval) == 1) {
    				gotoAndPlay (2);
    			} else {
    				trace ("error 1" + result_lv.errorMsg);
    				return_error = null;
    			}
    		} else {
    			trace ("error 2");
    			return_error = null;
    		}
    	};
    	
    	var list_lv:LoadVars = new LoadVars ();
    	list_lv.model_id = _parent.new_edit_id;
    	list_lv.sendAndLoad (path2php + "imgList.php", result_lv, "POST");
    	
    	success = false;
    };
    loadGal ();
    stop ();
    then trace(Number(result_lv.retval)); returns NaN

    the space is screing it up I think.

    HTH
    If it ain't broke, don't fix it.

  15. #15
    Grandmaster Flash
    Join Date
    Apr 2004
    Location
    Edinburgh, Scotland
    Posts
    139
    Or you could get flash to strip that space:

    Code:
    loadGal = function () {
    	trace ("check load gallery running?");
    	var result_lv:LoadVars = new LoadVars ();
    	
    	
    	result_lv.onLoad = function (success) {
    		trace ("sucess=" + success);
    		trace(result_lv);
    		if (success) {
    			var retv:Number = Number(result_lv.retval.substring(0, result_lv.retval.length-1));
    			if (retv == 1) {
    				gotoAndPlay (2);
    			} else {
    				trace ("error 1" + result_lv.errorMsg);
    				return_error = null;
    			}
    		} else {
    			trace ("error 2");
    			return_error = null;
    		}
    	};
    	
    	var list_lv:LoadVars = new LoadVars ();
    	list_lv.model_id = _parent.new_edit_id;
    	list_lv.sendAndLoad (path2php + "imgList.php", result_lv, "POST");
    	
    	success = false;
    };
    loadGal ();
    stop ();
    Not sure what it's meant to do - but that gets rid of the error.

    Cheers
    If it ain't broke, don't fix it.

  16. #16
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    your right about the "space"
    I have tinkered about some more and i still cant find were the sapce is coming from. Not only that but why is none of my other scripts affected by this and there is a lot. My own website use's this method in 151 files front end 35 back end for the admin system
    This site www.scotlet.com use 20 front end and 15 backend And scanned a lot of them to check the last output line "retval" and all are as:

    echo data&retval=1
    Now i tried this with this script but now the checker requires that i check for "1 " instead of "1" again none of my other files are effected in this way.
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  17. #17
    Grandmaster Flash
    Join Date
    Apr 2004
    Location
    Edinburgh, Scotland
    Posts
    139
    If you post the fragment of PHP that sends the response I can look if you want.
    If it ain't broke, don't fix it.

  18. #18
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    PHP Code:
    if ($handle opendir($_GET['model_id']."/model_pics")) {
    $i=0;
    while (
    false !== ($file readdir($handle))) {
    if (
    $file != "." && $file != "..") {
    if(
    substr_count($file'_main.jpg')==1){
    //
    }else
    if(
    substr_count($file'_popup.jpg')==1){
    //
    }else{
    $i++;
    }
    }
    }
    echo 
    "&retval=1&imageCount=".$i;
    closedir($handle); 
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  19. #19
    Keeper of Useless Information
    Join Date
    Feb 2006
    Posts
    19
    You've probably already thought of this...

    PHP Code:
    echo "&retval=1&imageCount=".$i."&"
    I had a similar problem in the actionscript thread titled "IF/Then problem with ActionScript and PHP".

    If you ever find where the space is coming from, let me know!

    Thanks,
    Digital Gypsy

  20. #20
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    Yes that was suggested and tried and solved the problem but it dosnt explain my other 150+ scripts that run off the same princeple of sending vars back to flash.
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

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