A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: If and else fault maybe?!

  1. #1
    Junior Member
    Join Date
    Jun 2002
    Posts
    21
    My code won't work.. and i don't know why..
    Code:
    onClipEvent(load)
    {
        if(_root.mySO.data.stored)
        {
        text = _root.mySo.data.tex;
    	} else {
            	_root.mySO.data.stored = true;
    		text = texmex;		
    		}
    }
    
    onClipEvent(enterFrame)
    {
        _root.mySO.data.tex = text;
    }
    variables text and texmex is both in the MC that this code is in.

    But this doesn't work!? is anything wrong? i just want text to be replaced with texmex if text hasn't been leaded before..

    plz help me! =)

    thx in advance

  2. #2
    Senior Member
    Join Date
    Jun 2002
    Posts
    145
    if(_root.mySO.data.stored) if what?

  3. #3
    Senior Member
    Join Date
    May 2002
    Location
    Seattle WA
    Posts
    171
    onClipEvent(load)
    {
    if(_root.mySO.data.stored)
    {
    text = _root.mySo.data.tex;//_root.texttitle.text = "...";
    } else {
    _root.mySO.data.stored = true;
    text = texmex;// _root.texttitle.text = "texmex";
    }
    }

    onClipEvent(enterFrame)
    {
    _root.mySO.data.tex = text;//"text";
    }
    i could be completely wrong i'm no guru but maybe.

  4. #4
    Senile member! :)
    Join Date
    Dec 2001
    Location
    Saunaswamp (transl)
    Posts
    2,296
    what is the location of textmex and text variables? are they in the same MC? also note that (load) event is fired when the MC "first" appears on the stage...



    dave toland.com
    If you test if something is true you can ommit the == true. The code assosiated with the if statement will be run if the expression inside the parentesis is equal to true.

    Code:
    if(true)
    {
        //this always code block is always executed...
    }
    
    if(false)
    {
        //... whil this is never executed!
    }
    /mirandir

  5. #5
    Senior Member
    Join Date
    Jun 2002
    Posts
    145
    ok, point taken

  6. #6
    Junior Member
    Join Date
    Jun 2002
    Posts
    21
    Both textboxes is inside the MC that holds this Code.

  7. #7
    Senile member! :)
    Join Date
    Dec 2001
    Location
    Saunaswamp (transl)
    Posts
    2,296
    textmex is of type inputtext I presume. is text that too? or is it just a dynamic textfield?

    anyways you can do it something like this:

    change text from being a variable to be the instance name of the textfield.

    then on your Mc put this code:

    Code:
    onClipEvent(load)
    {
        if(_root.mySO.data.stored)
        {
            text.text = _root.mySo.data.tex;
        } else 
        {
           	_root.mySO.data.stored = true;
    	text.variable = texmex;		
        }
    }
    
    onClipEvent(enterFrame)
    {
        _root.mySO.data.tex = text.text;
    }
    changes are in bold.

    /Mirandir

  8. #8
    Junior Member
    Join Date
    Jun 2002
    Posts
    21
    http://www.edsberg.nu/tmp/tmp/

    check this out.. you can have a quicklook at the swf.. then download the FLA and tell what i have done wrong.. i'm not that good at flash but it this gave me a real brain-teaser..

    Thx for you help!

  9. #9
    Senile member! :)
    Join Date
    Dec 2001
    Location
    Saunaswamp (transl)
    Posts
    2,296
    I'm not sure if the fla I got is a "compressed" version. but I was missing the initiation of the shared object. If you did forget it put this code on the first frame of the .fla file:

    Code:
    var mySO = SharedObject.getLocal("text");
    Also! My code erlier is not quite correct. The text.variable = texmex line is wrong!

    textfield.variable wants the name of the variable as a string. So the statement should be:

    Code:
    text.variable = "texmex";
    /Mirandir

  10. #10
    Junior Member
    Join Date
    Jun 2002
    Posts
    21
    it worked!!! thank you very much!!
    [Edited by Bjurstrom on 07-03-2002 at 03:39 AM]

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