A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Positioning a movie clip using external variables.

  1. #1
    Junior Member
    Join Date
    Aug 2002
    Location
    LDN, UK, EU
    Posts
    24

    Positioning a movie clip using external variables.

    Hi,

    I'm trying to position a movie clip inside a flash movie using variables stored in a text file.

    I'm using a php file to write and then read from a text file. This all works fine and my flash movie is able to do both these things.

    However when I try to use the variables to position the X and Y values of the movie clip, I'm unable to do so. the movie just wont pick up the variables that are in the movie (I can see the values of one_xpos and one_ypos in text fields in the movie so they ARE being read and ARE in the movie).


    The first thing I've been doing is loading the variables 'one_xpos' and 'one_ypos' using a php file:

    loadVariablesNum("http://www.website.com/folder/messageboards/php_text.php", 0);

    I've then made sure the variables are numbers:
    one_xpos = Number(one_xpos);
    one_ypos = Number(one_ypos);

    I've then tried to use these two variables to set the position of the movie clip:

    setProperty("01", _x, one_xpos);
    setProperty("01", _y, one_ypos);


    this doesn't work for some reason.

    When I don't load the variables but instead give one_xpos and give one_ypos values inside the movie it works and moves my movie clip!!

    This is so frustrating please help.

    Cheers
    Ben.
    Last edited by aitukltd2; 10-29-2002 at 11:22 AM.

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Hi,
    2 things:

    1)You need to make sure the variables are loaded before calling them.
    You can use onClipEvent(data) but you are loading on _level0 so, unless you work with MX (where you can use the onData function for _level0) that would mean changing where the vars are loaded.
    Or you can add a variable on the external file (for example: &loaded=true& ) and check whether that var exists.

    2) to convert the string back to a number use parseInt:
    one_xpos = parseInt(one_xpos);
    one_ypos = parseInt(one_ypos);

    gparis

  3. #3
    Junior Member
    Join Date
    Aug 2002
    Location
    LDN, UK, EU
    Posts
    24
    Bonjour Paris,

    merci beaucoup!! c'est bon!!! It works thank you SO, SO, SO, SO much.
    I used both your suggestions and they both work perfectly. My work mate and I had been struggling with this one for quite some time.

    Thanks again.

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Bienvenue / You're welcome

    gparis

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