+ Reply to Thread
Results 1 to 9 of 9

Thread: Simple Actionscript Syntax question

  1. #1
    ryanmm is offline x10Hosting Member ryanmm is an unknown quantity at this point
    Join Date
    Sep 2010
    Posts
    36

    Simple Actionscript Syntax question

    just trying to pass some variables from flash to php with getURL

    getURL("CompSummary.php?url3=" + url3, "_self");

    url3 keeps coming back as undefined

    However I printed out url3 using dynamic text in the flash movie just to check it and it does indeed exist, and is defined.

    I also tried creating a string and passing that to getURL

    var path = "CompSummary.php?url3=" + url3;
    getURL(path, "_self");

    still no luck.

    ideas?

  2. #2
    vv.bbcc19's Avatar
    vv.bbcc19 is offline Community Advocate vv.bbcc19 is just really nice
    Join Date
    Jun 2010
    Location
    India
    Posts
    1,505

    Re: Simple Actionscript Syntax question

    Some Basic tutorial.Hope this helps.
    <?
    $first="this";
    $second = "that";

    echo "myfirst=$first&mysecond=$second";
    exit;
    ?>

    Flash Actionscript:

    var lvSend = new LoadVars();
    var lvReceive = new LoadVars();
    lvSend.SendAndLoad("www.domain.com/script.php",lvReceive,"POST");

    lvReceive.onLoad = function(bSuccess) {
    if(bSuccess == true) {
    trace(this.myfirst);
    trace(this.mysecond);
    }
    }
    BCV | Community Support Representative
    █ x10Hosting - Giving Away Hosting Since 2004
    Premium Hosting | VPS Services

  3. #3
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Simple Actionscript Syntax question

    Is the undefined variable problem in the Flash movie, or in the PHP script? If the latter, why have you not shown sample PHP code?
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  4. #4
    ryanmm is offline x10Hosting Member ryanmm is an unknown quantity at this point
    Join Date
    Sep 2010
    Posts
    36

    Re: Simple Actionscript Syntax question

    no the problem is with the actionscript.

    The variable DOES exist in the movie and IS set to the right value.

    I set some dynamic text to = the value of url 3 just to test this very thing.

    when the movie is launched, right there at the top of the screen, it says "url3 = 123456"

    i got this simply by coding:

    _root.myDynText = url3;

    so url3 is defined and has a value in the movie.

    however when I try to use getURL to reload the page based on url3
    getURL("CompSummary.php?url3=" + url3, "_self");
    it doesnt work, url3 isn't being passed
    I would guess this really is a syntax problem with
    getURL("CompSummary.php?url3=" + url3, "_self");

    I tired using a string:

    var path = "CompSummary.php?url3=" + url3;
    getURL(path, "_self");

    this didnt work either.

    however, if i do this:
    _root.myDynText = path;

    CompSummary.php?url3=123456
    prints out just fine

    its like getURL just wont accept variables
    Last edited by ryanmm; 03-31-2011 at 01:25 PM.

  5. #5
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Simple Actionscript Syntax question

    Quote Originally Posted by ryanmm View Post
    url3 keeps coming back as undefined

    ....

    ideas?
    Undefined where ? In your PHP script? If show, please show the PHP script.
    Nothing is always absolutely so.

  6. #6
    ryanmm is offline x10Hosting Member ryanmm is an unknown quantity at this point
    Join Date
    Sep 2010
    Posts
    36

    Re: Simple Actionscript Syntax question

    Here's the php. it works like a gem with everything except this flash

    PHP Code:
    $_SESSION['url3'] = $_GET['url3'];

    //if url3 doesnt exist, exit
    if(!isset($_SESSION['url3']))
    {
        
    PrintError('Sorry, url3 doesn\'t exist.','index.php');
        exit;


  7. #7
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Simple Actionscript Syntax question

    Quote Originally Posted by ryanmm View Post
    Here's the php. it works like a gem with everything except this flash
    How do you know? Do you mean if you browse to "CompSummary.php?url3=123456" in a browser, you don't get the message that url3 doesn't exist?

    You apparently haven't read my sig, nor the site from a previous link on posting sample code as you haven't written a complete sample. After filling out the scraps posted thus far into a complete example, there's no issue I see with undefined values.

    get.as (compiled with mtasc):
    Code:
    class GetTest extends MovieClip {
        static var base:String = 'CompSummary.php';
        static var url3:String = '123456';
    
        public function onLoad () {
             this.getURL(base + '?url3=' + url3, '_self');
        }
    }
    getter.xml (compiled with swfmill):
    Code:
    <?xml version="1.0" encoding="iso-8859-1" ?>
    <movie version="8" width="80" height="16" framerate="12">
      <background color="#FFFFFF"/>
      <frame>
        <library>
          <clip id="getst" import="build/get.swf" class="GetTest" />
        </library>
        <place id="getst" name="getter" depth="1" />
      </frame>
    </movie>
    CompSummary.php:
    PHP Code:
    <?php
    header
    ('Content-type: text/plain');

    function 
    PrintError($msg$file) {
        echo 
    $msg;
    }

    # even without calling session_start(), this works
    $_SESSION['url3'] = $_GET['url3']; 

    if(!isset(
    $_SESSION['url3'])) {
        
    PrintError('Sorry, url3 doesn\'t exist.','index.php'); 
        exit; 


    echo 
    "url3: $_SESSION[url3]\n";
    index.html
    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
      <head><title></title></head>
      <body>
        <object data="getter.swf" type="application/x-shockwave-flash" id="getter" height="50" width="200">
          <param value="sameDomain" name="allowScriptAccess" />
          <param value="high" name="quality" />
          <param value="#FFFFFF" name="bgcolor" />
        </object>
      </body>
    </html>
    Opening index.html results in the loading of page "CompSummary.php?url3=123456".
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  8. #8
    ryanmm is offline x10Hosting Member ryanmm is an unknown quantity at this point
    Join Date
    Sep 2010
    Posts
    36

    Re: Simple Actionscript Syntax question

    The problem is in the flash actionscript, not the php.
    I have solved the problem a different way by making a new php file that the flash refers to.
    instead of "compsummary.php?id=123456" its now "ReloadFromFlash.php" Then I use a session var to get "123456"
    Your code looks excellent, btw. Thank you for trying to help me.
    Last edited by ryanmm; 03-31-2011 at 10:46 PM.

  9. #9
    mayzar2395 is offline x10Hosting Member mayzar2395 is an unknown quantity at this point
    Join Date
    Nov 2010
    Location
    Mataram
    Posts
    8

    Re: Simple Actionscript Syntax question

    nice

+ Reply to Thread

Similar Threads

  1. Quick question: PHP/Javascript syntax problem
    By gottaloveit in forum Programming Help
    Replies: 3
    Last Post: 06-22-2010, 08:57 PM
  2. Very simple Actionscript help
    By Teensweb in forum Programming Help
    Replies: 3
    Last Post: 10-12-2008, 05:14 AM
  3. simple actionscript problem
    By stalkio in forum Programming Help
    Replies: 2
    Last Post: 08-19-2008, 06:18 PM
  4. PHP Syntax Question
    By gamerdude in forum Programming Help
    Replies: 5
    Last Post: 06-01-2008, 03:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers