dcsimg
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: [RESOLVED] Dynamic Images using variables

  1. #1
    Junior Member
    Join Date
    Mar 2006
    Location
    Melbourne, Australia
    Posts
    6

    [RESOLVED] Dynamic Images using variables

    Hi, new to the forums, long time flash user, first time action script user

    I'm looking to load pictures into flash using what im assuming would be the loader object. However, as i understand it, this is limited to using a static filename located within the same directory as the flash .exe or .swf. My query is this, is it possible to a) use a full file path i.e. if irrespective of the location of the flash file "d:\documents and settings\user\desktop\file.jpg" and b) is it possible to specify this path with the use of a variable, i.e. store the path in a variable and call it using the appropriate command?

    Any help would be greatly appreciated, or even a shove in the right direction.

    Cheers,

    Alex.


    (Flash Pro v8.0)
    Last edited by aflgenx; 03-01-2006 at 09:31 AM.

  2. #2
    go blues ! audas's Avatar
    Join Date
    Oct 2000
    Location
    london ,piccadily circus!
    Posts
    665
    Hi there Alex. Great to have you on board. Im from melbourne myself (live in London now) and have been using this stuff for 7 years now.
    Wonder if I know you....Im sam.
    Anyway here the deal:

    The loading of files can be complicated as there is a sand-box security feature when loading info across networks or domains. however since you loading locally should be ok.

    Generally it should be ok to load stuff from anywhere on your system at runtime. Yes you can load something from a dynamic variable. There are a couple of different methods however since what you are trying t load is a string "C:\documents and settings" you can jsut set the variable: file="c:\docs\file.swf";
    and then load it

    loadMovieClip(file,20);

    20 represents the level you are loading it into, (it could be a target clip aswell).
    cheers,
    sam.
    peace.

  3. #3
    Junior Member
    Join Date
    Mar 2006
    Location
    Melbourne, Australia
    Posts
    6
    Thank you for the quick reply, however you mentioned that there may be trouble loading the same thing over a network or domain? How difficult is it?

    Cheers for the help so far.

    Alex

  4. #4
    go blues ! audas's Avatar
    Join Date
    Oct 2000
    Location
    london ,piccadily circus!
    Posts
    665
    There is a security sand-box in flash that prevents flash from loading info,swf,images etc over a network or across domains. This is overcome by
    a) Allowing a domain access in the config file of the users flash player (a pop that occurs in player 8) and is undesirable.
    b) placing a cross domain config xml file on the root of your server and then loading this into any cross domain swf's.

    Its in the help.

    cheers,
    sam.
    peace.

  5. #5
    Junior Member
    Join Date
    Mar 2006
    Location
    Melbourne, Australia
    Posts
    6
    Thanks lots mate, I'll check it out, you're a life saver

    Cheers

    Alex

  6. #6
    Junior Member
    Join Date
    Mar 2006
    Location
    Melbourne, Australia
    Posts
    6
    Very odd problem though, when referencing the file path to load the variables using the loadVariables("C:\Documents and Settings\test\text.txt"; _root)

    flash for some reason interprets the file path to be: C:\ocuments and Settings\est\ext.txt

    I assumed that the \ would for some reason exclude the first letter because of its association with comments, so i substituted it for a / and it worked correctly. Then i realized that it was actually // that initiated a comment so im just stumped... oh well

    cheers,

    genx
    Last edited by aflgenx; 03-02-2006 at 09:02 AM.

  7. #7
    go blues ! audas's Avatar
    Join Date
    Oct 2000
    Location
    london ,piccadily circus!
    Posts
    665
    \t is a tab
    \n is a new line
    \r is a carriage return
    etc.
    peace.

  8. #8
    Junior Member
    Join Date
    Mar 2006
    Location
    Melbourne, Australia
    Posts
    6
    ah, rightio, thanks again, you've been a huge help, now if i could possibly ask for one more last favour. I'm trying to load an image into a loader object, even without using a variable by just using:
    instancename.contentPath("c:/documents and settings/alex/desktop/images/test.jpg" ; _root )

    without any luck...

    What am i doing wrong? God i hate being a newbie sigh. I've racked up like 620 posts at fmforums lol. Oh well, thanks again sam and pardon the genx sign off... force of habit.

    Alex

  9. #9
    go blues ! audas's Avatar
    Join Date
    Oct 2000
    Location
    london ,piccadily circus!
    Posts
    665
    Mate no drama.
    To load an image (jpeg or swf only) then there are several ways of doing this.
    create a movie clip on the stage (either programatically mc=new MovieClip() or ctrl F8.

    give this the name mc

    then mc.loadMovie(trgetPath);

    or inside the clip itself

    this.loadMovie(trgetPath);

    or

    loadMovie(trgetPath,mc);

    or load it into a new level

    loadMovie(trgetPath,20);

    cheers,
    sam
    peace.

  10. #10
    Junior Member
    Join Date
    Mar 2006
    Location
    Melbourne, Australia
    Posts
    6
    Cheers sam, you've been awesome, I'll give all this a go tommorow when my headache has hopefully lessened lol.

    Alex

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