A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 36 of 36

Thread: Loading Variables from Perl and JS - For real Flash experts!!!

  1. #21
    Member
    Join Date
    Aug 2000
    Posts
    32

    success

    I have modified about 12 of my perl scripts now and they all return to flash flawlessly using the aforementioned methods. In some instances the script returns about 5 different variables and Flash displays all of them via multiple textfields. Before reading this thread i was having perl write to text files then loading the variables from the file. Thanks again to NetBreed and MasterShin for this much more efficient method.

  2. #22
    Moderator
    Join Date
    Aug 2000
    Posts
    1,455
    Hi again foley!

    I wonder. I'm thinking of setting up a website to help others having problems with integrating CGI and Flash. What scripts do you have and, if any, which would you be willing to submit to a public archive?

    If there's enough interest in this topic then I'll move this project off of the back burner and get the ball rolling. I see it as being less of a competitor to FLashKit and more of an extension! Let me know what you think!

    NETbreed

  3. #23
    Last Ju-Jitsu Warrior
    Join Date
    Aug 2000
    Posts
    655
    NetBreed,

    I am willing to give away Perl & Flash scripts to the public for learining use - only.

    I know Perl, and Flash... So I can be a good help.
    If you want someting, just ask...

  4. #24
    Moderator
    Join Date
    Aug 2000
    Posts
    1,455
    Thanx MasterShin!

    The more I think about this idea the better it seems. If it does go ahead I will certainly need some help - I've got a degree and an ever expanding web design business to keep running.

    Maybe some of the moderators can give their opinion on the idea and, if I'm really lucky, set up a poll on the news page to gauge average user response!

    NETbreed

  5. #25
    Junior Member
    Join Date
    Jun 2000
    Posts
    14

    Exclamation

    The PERL method of print "$varname=$varvalue" works great in Flash and is the way to go.

    This is also possible in ASP with Response.Write. Just a change in syntax.

    As for JavaScript, you cannot load variables from it, unless, you call a function that instead of "returning" a string &varname=value it will instead use FlashMovieName.SetVariable(). The thing is that this method would have to be called individually for each variable instead of joining it into a string.

  6. #26
    Member
    Join Date
    Aug 2000
    Posts
    32

    Absolutely!

    NetBreed,

    Good idea. I would be willing to share/post specific techniques and/or scripts. It would be nice to have a specific forum for this. Without this thread I would be using an inferior method.

    foley

  7. #27
    Moderator
    Join Date
    Aug 2000
    Posts
    1,455
    Hi foley!

    Thanx for the support. As I told MasterShin, if this thing does go ahead I will need help. We'll just have to see how things pan out!

    NETbreed

  8. #28
    Junior Member
    Join Date
    Jun 2000
    Posts
    14

    help!

    I tried installing the FlashDB PERL script but I cant for anytning get the Flash movie to read from the .pl file. I access it fine inputting the url into IE as in http://www.myserver.com/cgi-bin/Flas...l?filename=bec
    and it returns counter=3&state=done which is right...but when I connect with Load Variables with the same url..flash doesnt read it...

    Any ideas?

  9. #29
    Moderator
    Join Date
    Aug 2000
    Posts
    1,455
    Hiya!

    In the LoadMovie ActionScript code on the button (or whatever), try changing the Location from Level to Target and leave it blank. It worked for me!

    Hope this helps!

    NETbreed

  10. #30
    Senior Member unicycle's Avatar
    Join Date
    Mar 2000
    Posts
    254

    proof

    This is proof of loading variables from cgi:
    http://www.unicycle.to/testdir/flashlog.cgi

    And this is loading variables from a javascript into flash:
    http://www.unicycle.to/testdir/flashclock.html

    I did not put preloaders on ite yet, but the same clock tells me I sit for too many hours behind the keyboard, and it's time to wake up, while I still need to go to bed.

    Later

    unicycle

  11. #31
    Senior Member
    Join Date
    Jul 2000
    Posts
    266

    Clock !

    Unicycle,

    like your graphical clock, however it doesn't update every second.

    try adapting my script to suit your movie, it will fire the time into the movie every second so you have a realtime working clock.

    (if you want to!)

    you'll need to replace the 'YOURMOVIE' with whatever you have in <OBJECT ID='YOURMOVIE'....> and <EMBED NAME='YOURMOVIE'...>

    Dan.

    <SCRIPT LANGUAGE='JavaScript'>
    <!-- shields up!
    /* written by: Daniel Humphrey
    * http://www.technomedia.co.uk
    */

    function findObj(n, d) { //v3.0
    var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
    }

    function controlFlash(objStr,x,cmdName,frameNum) { //v3.0
    var obj=MM_findObj(objStr);
    if (obj) eval('obj.'+cmdName+'('+((cmdName=='GotoFrame')?fr ameNum:'')+')');
    }


    var timerID = null;
    var timerRunning = false;

    function stopclock (){
    if(timerRunning)
    clearTimeout(timerID);
    timerRunning = false;
    }

    function showtime () {
    var now = new Date();
    var hours = now.getHours();
    var minutes = now.getMinutes();
    var seconds = now.getSeconds()
    var timeValue = "" + ((hours >12) ? hours -12 :hours)
    if (timeValue == "0") timeValue = 12;
    timeValue += ((minutes < 10) ? ":0" : ":") + minutes
    timeValue += ((seconds < 10) ? ":0" : ":") + seconds
    timeValue += (hours >= 12) ? " P.M." : " A.M."

    var obj = findObj('YOURMOVIE');

    obj.SetVariable("clock", timeValue);
    timerID = setTimeout("showtime()",1000);
    timerRunning = true;
    }
    function startclock() {
    stopclock();
    showtime();
    }
    // down shields! -->
    </SCRIPT>

    <BODY bgcolor="#FFFFFF" Onload="startclock();controlFlash('YOURMOVIE','',' Play')">

  12. #32
    Senior Member unicycle's Avatar
    Join Date
    Mar 2000
    Posts
    254

    Re: Clock !

    Thanks again Dan!

    I found a script which was basicly the same somewhere on this site,
    But I can not find it back.
    So I put the .zip on http://www.unicycle.to/download/clock.html

    But in your script you can control the movie with java?
    Thats cool! (..and opens lots of possibilitys) I did not knew that was possible. I've don my grapical clock with form-validation.

    Leo.

  13. #33
    Senior Member
    Join Date
    Jul 2000
    Posts
    266

    Glad to help !

    Hi unicycle,

    glad I could help !

    Dan.

  14. #34
    Senior Member unicycle's Avatar
    Join Date
    Mar 2000
    Posts
    254
    After a long while I use this method again:
    Code:
    function MM_findObj(n, d) {
       var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
       if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
       for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
       }
    function koekkoek() {
       var t=new Date();
    // ---------------------------- 1 way  MSIE eat it:
    // window.document.unicycle.TGotoFrame("_level2/airport/clock/groot", t.getMinutes());
    // window.document.unicycle.TGotoFrame("_level2/airport/clock/klein", t.getHours());
    
    // ---------------------------- another way MSIE eat it to:
    // eval('window.document.unicycle.TGotoFrame("_level2/airport/clock/groot", t.getMinutes())');
    
    // ---------------------------- till now this looks the best to me
       var obj=MM_findObj("unicycle");
       if (obj) eval('obj.TGotoFrame("_level2/airport/clock/groot", t.getMinutes())');
       }
    but how would I force netscape & mozilla to do it???

  15. #35
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    I have got this one which works on Mozilla and seems to work on IE as well:
    window.document.MOVIENAME.SetVariable('var1', value);
    window.document.MOVIENAME.SetVariable('vr2', value);
    window.document.MOVIENAME.TPlay('/CLIPNAME')

    Musicman

  16. #36
    Senior Member unicycle's Avatar
    Join Date
    Mar 2000
    Posts
    254
    So okay, I tried some other function
    window.document.unicycle.SetVariable("_level2/airport/clock/klein:test", "help..!");

    have a look at it at http://www1.unicycle.net/mozilla_test.php,
    1st with explorer then mozilla... it still just doesn't work!
    (click on the movie, press <s>, then <enter> to skip intro).
    Can it be Mozilla can't reach into multiple swf's?

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