dcsimg
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: perl to flash variables.......again

  1. #1
    Senior Member
    Join Date
    Sep 2001
    Posts
    443

    perl to flash variables.......again

    I've spent two days looking through all the previous threads on this topic, but still I can't do anything with variables sent back to Flash from a Perl script, apart from show their "raw" values in a text field.

    My Perl has the following in it:

    Code:
    print "Content-type: text/html\n\n";
    print "_root.pass=true&\n";
    And I have a simple check in the Flash script:

    Code:
    if(_root.pass eq "true"){
    _root.text=_root.pass;
    }
    which has been placed on its own, and within a "waiting" loop using multiple frames with goto's, and within an onClipEvent(enterFrame), without any success of _root.text changing.

    Any thoughts?

    swills
    Last edited by swills; 05-26-2003 at 11:14 AM.

  2. #2
    Senior Member
    Join Date
    Sep 2001
    Posts
    443
    bump

  3. #3
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    would you mind to post an url to your swf file?

    Musicman

  4. #4
    Senior Member
    Join Date
    Sep 2001
    Posts
    443
    I'm not sure whether the swf will make much sense - though I've set it up so that you can see it not working!! Please nobody else click the left hand months until Musicman has a chance to do it first....

    Any way, apart from the greeness, the problem arises from a "month" button being pressed and there not existing a data file to be loaded. The flash calls a Perl script that will make a blank one (no problem), but then the Perl script has:

    print "Content-type: text/html\n\n";
    print "_root.pass=true&\n";

    And the two text boxes in white should show the results. The top one is just the _root.pass value, and the bottom one contains _root.text, , both set to false to start with, which is enclosed in :

    onClipEvent(enterFrame){
    if (_root.pass eq "true") {
    _root.text = "yes";
    }}

    _root.pass text box changes, but _root.text doesn't

    By the way I've set it so that there are only data files for April ,May and June..so click the July one!! If July appears then the button has already been clicked by someone (the same result can be got from clicking a month, (no change in _root.text box) and refresh, click the same button again. You get the idea.

    Sorry about the messy way I check to see if things work!?

    link:

    http://194.131.128.207/calender/calender9.swf

    This method has worked before with a password script - no idea why Flash doesn't process the conditional.

    Thanks

    swills

  5. #5
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    it seems to be a problem with your actionscript.
    You have
    onclipevent(enterframe) {
    _root.text = _root.pass
    if(_root.pass == "true") _root.text = "yes"
    }
    this would be setting the "text" field to the contents of the "pass" field every frame, and also set the "text" field to yes (once every frame)
    I changed names a bit to verify that the enterframe code does its duty - as long s the textfield var is the same as within the enterframe, there is no way to change the lower textbox to anything - not even be feeding it with _root.text=stuff
    Once the names differ (the textbox was texe, and the enterframe tried to copy to texf), I could feed the lower textbox. So obviously the enterframe code is setting it to false all the time - _root.pass must be false and not be changed by reading the text file.
    I have made a small example of what happens here: http://wolfgang.rnsmail.de/weird.swf
    When the movie loads, it reads a text file
    _root.text1=stuff
    and fills the upper text box. The "weird copy" button will copy data to lower text. Next type your own text into the upper box, now the regular copy button will work.
    You can also hit the post button to see which vars are defined and will be sent to the server
    The obvious explanation: the varname associated with a textfield (e.g. _root.text1) is parsed - you can really set a text1 var in the _root, while incoming text with periods and [ in it is not ... it is, however, matched against variable names in text fields.
    BTW: there is similar situation where "array members" become weird var names.

    Musicman

  6. #6
    Senior Member
    Join Date
    Sep 2001
    Posts
    443
    Thanks for looking at this. I think I'm understanding (changed that AS error) - but where then would I change the texe to texf?

    swills

  7. #7
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    I was just doing that for testing, so the textbox name was different from the name in the enterframe script...
    The best solution should be to send data in the text file without a path, and use a code similar to yours to copy the var from the clip to the textfield
    onclipevent(enterframe) {
    _root.pass = this.pass;
    if(_root.pass == "true")
    _root.text = "yes"
    }

    Musicman

  8. #8
    Senior Member
    Join Date
    Sep 2001
    Posts
    443
    Musicman

    Sorry about this, I've looked through your advice and I still can't do anything with the "_root.pass=true" so that other things in the movie can happen. This seems illogical as _root.pass either equals true or it doesn't!?! So why can I "see" that it does, and yet I can't make a conditional out of it?

    Any chance I can see the weird fla to map what variables are changing and when?

    Thanks

    swills

  9. #9
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    there is no weird.fla just a weird.php ...
    What actually happens: the _root.text1 loads from the text file, but it does not really become _root.text1 as one might expect, rather it becomes this['_root.text1'] - the post test does not show a text1 variable
    If you enter text into the field yourself, or if you have some actionscript that sets it, everything works great (and the text1 var is sent back to the server)
    The behaviour of pathed variables in text files is not documented, so I'd say it is pure chance that they work at all with textfields. Probably someone at macromedia asked for the feature, and a quick fix was developed; this behaviour exists in F5 as well
    Probably the only correct solution is to avoid paths in the text file. If you load it into the _root, they do not matter at all, if you load it into the clip, you may have to copy it
    _root.pass = this.pass

    Musicman

  10. #10
    Senior Member
    Join Date
    Sep 2001
    Posts
    443
    All fits into place, and makes sense, and , wait for it....., now works!

    What a slog - what would we do without you! Seriously, I was close to hurting something - and all this for just some mucking-about code!

    Thanks again - I owe you big time.

    swills

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