A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Variables

  1. #1
    Junior Member
    Join Date
    Jun 2006
    Posts
    9

    Variables

    How can i pass variables from one swf to another?

    I tried this, but it do not work:

    I have two swf files.
    1.swf action
    -----------------------
    var thisdata = "hello world!";
    loadMovieNum("2.swf", 4, "POST");

    2.swf action
    -----------------------
    _root.createTextField("txtfield", 1, 500, 500, 1000, 1000);
    _root.txtfield.text = _root.thisdata

    Thank You,
    Joni

  2. #2
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    These are two seperate SWFs? Are they in the same page? OR are they in the same movie?
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  3. #3
    Junior Member
    Join Date
    Jun 2006
    Posts
    9
    Two separate files, they are in the same movie. First one loads second one.
    If i would not want to send variables it will work nicely.

    I just need a method to pass variables between swf files. I cannot find solution anywhere and im nearly desperate. So, am i in right track here? What is the common way of passing variables?

  4. #4
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    Well I am not sure if this is related, but when you load one movie into another, the root level changes to the movie LOADING the second movie. Hence the code:

    _root.createTextField("txtfield", 1, 500, 500, 1000, 1000);
    _root.txtfield.text = _root.thisdata

    in the second movie would (I believe) actually try to create a texfield in the root timeline of the first movie (since that is now the root). Is this what you are trying to do?

    Also, I am not sure why you are specifying a POST method for loading a movie in:
    loadMovieNum("2.swf", 4, "POST");

    this is generally only done if you are sending variables. Here you are trying to access internal variables.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  5. #5
    Junior Member
    Join Date
    Jun 2006
    Posts
    9
    Thank you, i learned from your post.

    However, I changed my way to solve my problem complitely, because i just realised that passing variables through files is not the right way. Because i load swf files dynamically.

    At present moment I am still in the corner.

    I have two files, "index.swf" and "valikko.swf" (1.swf and 2.swf in previous post). I read database with LoadVars.load to get content for the flash.

    Loading data to "index.swf" works fine but it do not work from "valikko.swf".
    That is the reason i tried to pass variables loaded from db.

    I Thought previously:
    "Damn! This dont work.. OK, loading data wont work from valikko.swf, but it works from index - so do not panic, just pass them to index. "
    -- and then i got new problems

    Now i Thought:
    "Because loading works from index, theres no any good reason why it wont work from another file. Actionscript is same in both files. And this makes me feel odd."

    SCRIPT: (yes, there Is onload evenhandler above)
    ---------------------------------------------------------------------
    try {
    select_lv2.load("http://localhost/flashdata/?site=www.xxx.fi")
    }
    catch (myError:Error) {
    trace("error caught: "+myError);
    }
    finally {
    trace('finally here')
    }
    ---------------------------------------------------------------------

    BUT

    I do not get any apache log - so apache do not ever even get that load command! Flash just prints "finally here" without errors.

    From index.swf it works.

    Thank You,
    Joni

  6. #6
    Junior Member
    Join Date
    Jun 2006
    Posts
    9

    Answer!

    Hey!

    I found the solution. The second swf file had publish setting of actionscript 1.0. Works when set to 2.0..

    Later,

    Joni

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