A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Actionscript2 load an external .swf using a variable instead of url

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    2

    Actionscript2 load an external .swf using a variable instead of url

    Hello,

    in my movie I can load another .swf by using the url:

    loadMovie('htpp://www.example.com/example.swf', 1);

    I would like to replace the url with a string variable

    loadMovie('example-variable', 1);

    but am not having much luck.

    Thanks in advance for any solutions.

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Having quotes around your variable makes Flash interpret is as just another string, so omit those quotes to make Flash recognize it as a variable. Also, a variable cannot have a dash/minus sign in its name, as dash/minus sign is interpreted as a Mathematical sign used to subtract values. Replace it with an underscore. Fixed code:

    Actionscript Code:
    loadMovie(example_variable, 1);
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Junior Member
    Join Date
    Jun 2012
    Posts
    2
    Thank you Nig,
    I tried your way earlier today and again just now, it doesn't work for me.
    I have finally solved it using:

    var url:String = example_variable;
    var movieClip:MovieClip = createEmptyMovieClip("movieClip", 0);
    movieClip.loadMovie(url);

  4. #4
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    I just pointed out the error made in the particular code you posted, and would've understood your problem in greater depth if you had posted your full contextual code, but I'm glad you've sorted it out
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

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