A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: [f6][f7][f8]How to set vars to clip loaded with loadmovie?

  1. #1
    GameBalance
    Join Date
    Apr 2005
    Location
    russia
    Posts
    62

    [f6][f7][f8]How to set vars to clip loaded with loadmovie?

    I load some movieclip using like:
    this.createEmptyMovieClip("gamesnetwork",1000)
    loadMovie("http://gamebalance.com/network/network.swf",gamesnetwork)

    But I not get how to set there variables so when it loads it has some actions it should do depening of variables was set.
    How to set variables to movieclips loaded like that?
    www.gamebalance.com -my site
    Snake Classic - my new game
    - Arseniy Shklyaev

  2. #2
    GameBalance
    Join Date
    Apr 2005
    Location
    russia
    Posts
    62
    Oh great! I found one possible variation but though is not very good.
    Is by set vars using like
    loadMovie("http://gamebalance.com/network/network.swf?topcolor=0xC06040&maincolor=0xF0DDCC", gamesnetwork)
    So I still need help to some more handy way. Also this string has a limit I guess. What if I need to set 50 variables?....
    www.gamebalance.com -my site
    Snake Classic - my new game
    - Arseniy Shklyaev

  3. #3
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    your swf that loads should have some if statements right at the beginning that checks the variables in the main flash and then uses them. In your loaded flash just use something like

    if(_root.myVar==2){
    //what you want to happen
    }

    and your main flash would just set the myVar variable to something.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  4. #4
    GameBalance
    Join Date
    Apr 2005
    Location
    russia
    Posts
    62
    Yeah I use some like
    if(_parent.var==something){do stuff}

    I just was think to go with set em into that loaded object. Is it possible?
    www.gamebalance.com -my site
    Snake Classic - my new game
    - Arseniy Shklyaev

  5. #5
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    yes, if you set a variable in the main movie and use an if to check for the variable in the loaded movie then it will work just fine.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  6. #6
    GameBalance
    Join Date
    Apr 2005
    Location
    russia
    Posts
    62
    Yes I know. I use it already. I ask about if there a way to send vars to clip loaded with loadMovie. Inside it. not to read from it.
    I dunno why. This way is OK to. Just want to know if it possible.
    www.gamebalance.com -my site
    Snake Classic - my new game
    - Arseniy Shklyaev

  7. #7
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    yes, look into loadClip and onLoadInit in the help files
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  8. #8
    GameBalance
    Join Date
    Apr 2005
    Location
    russia
    Posts
    62
    Once again about loadMovie though
    It not want to load variables without thing like
    host = "gamebalance.com"
    if (System.security) {
    if (System.security.allowDomain) {
    System.security.allowDomain("*");
    System.security.allowDomain(host);
    }
    if (System.security.allowInsecureDomain) {
    System.security.allowDomain("*");
    System.security.allowInsecureDomain(host);
    }
    }
    What the hell???
    www.gamebalance.com -my site
    Snake Classic - my new game
    - Arseniy Shklyaev

  9. #9
    GameBalance
    Join Date
    Apr 2005
    Location
    russia
    Posts
    62
    Oh.... I m confused. I t actually not works when I set it to html and load from my site. It works when files loads from local. But that thing above though seems work.
    U see I tested it like that. I set up vars in main movie. When banner loads from site into it with no System.Security it not read _parent.var.
    So it works.
    But when I load vars from html with banner loaded from my site it not works.
    When I load banner from local computer vars from html works...
    What it could be??
    www.gamebalance.com -my site
    Snake Classic - my new game
    - Arseniy Shklyaev

  10. #10
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    That is the security sandbox set up by flash to disallow cross domain access unless you specifically tell it otherwise. Why it isn't allowing stuff from your local domain may have something to do with your server. I would contact who ever manages the server and explain to them that it is not allowing flash to access files on the domain. If you are accessing files that do not reside on the same domain then that is the workaround and the only way to do it. I don't know that using the * to search all domains to allow is a good idea; but this is a security issue. Check out sand box security issues on the adobe/macromedia site for a better explaination.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  11. #11
    GameBalance
    Join Date
    Apr 2005
    Location
    russia
    Posts
    62
    You right! It is something about server issues!
    I dont get why though. I put same .htaccess and crossdomain in both folders but it not let to read vars from new one (network) and let to read from old one(bannernetwork). Geez.. I dunno what to do. Ok. I'll try to ask provider but how could they know.
    www.gamebalance.com -my site
    Snake Classic - my new game
    - Arseniy Shklyaev

  12. #12
    GameBalance
    Join Date
    Apr 2005
    Location
    russia
    Posts
    62
    Also... This make me mad. I think it is BUG....
    You know. When I set there load banner from Bannernetwork folder it start to read vars from _parent it loads in. And in that parent vars loads with html code.
    It's not the first time I have similar bug. Is like flash hold it somewhere in temporary memory or something. I just not get... Cuz now it works. And it is actually same. All I did is tried to put file from other folder and surprised it works. Then I swap it to "Network" folder and it start to work!!
    Geeezz... What the hell is that and how to avoid it??
    It not the first time I have something like that in case of read vars between movies when use loadMovie.
    P.S.
    Oh.. Can you give a tip about that security thing?
    hostname = "gamebalance.com"
    if (System.security.allowDomain) {
    System.security.allowDomain("*");
    System.security.allowDomain(hostname);
    }
    if (System.security.allowInsecureDomain) {
    System.security.allowInsecureDomain("*");
    System.security.allowInsecureDomain(hostname);
    }

    I m not certain what it do. I did copy it from somewhere.
    I need my banner work on other sites as well. I use it to load in my games and on other sites html pages. So I need it work on other sites. So is this allowDomain("*") necessary for that??
    Last edited by rubilon; 07-24-2007 at 03:58 AM.
    www.gamebalance.com -my site
    Snake Classic - my new game
    - Arseniy Shklyaev

  13. #13
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    Flash will store itself in temporary memory. So sometimes when you make changes to something on your machine and upload it you will not be able to see the change until you shut down the computer and reboot. It's just something that happens and there is nothing you can do about it unless you lower the space allowed for the swf to store on, which could then slow down the speed at which you experience the application. If you are accessing files from one domain to the other then you have to use the code that you have there, your server providers will not be able to help you; at least I don't think so. The code you have does this:


    if (System.security.allowDomain) {//This section lets the swf that it resides in access files outside of its own domain
    System.security.allowDomain("*");//allow all domains
    System.security.allowDomain(hostname);//allow a specific domain
    }
    if (System.security.allowInsecureDomain) {//this allows this swf to be accessed by files outside of the domain
    System.security.allowInsecureDomain("*");
    System.security.allowInsecureDomain(hostname);
    }

    The * is not neccessary; and is probably a bad idea. I think the person who posted that code was just trying to give an example of the possibilities. If you know the 2 domains that you are using(which you do) then where it says hostname you should put the name of the domain. Put the top if statement in the swf that is pulling the files from another domain and put the bottom section inside of the swf that is being accessed from the remote domain. Make sure to put the opposite domain name inside of the hostname () for each swf.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  14. #14
    GameBalance
    Join Date
    Apr 2005
    Location
    russia
    Posts
    62
    1. If u mean temporary internet files that not it. I meant it didn't work right in flash program when I press ctrl+enter.

    2. Are you sure? My banner should loads and in games on other sites.
    I set this code not in banner(but there too) but in game itself. or other way it not let to read vars from game so banner react on them to change color to fit game for example.

    Also there is only one domain - gamebalance.com. I specified two derictories not domains.

    P.S.
    Hey thanks BTW! I even didn't know that.
    www.gamebalance.com -my site
    Snake Classic - my new game
    - Arseniy Shklyaev

  15. #15
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    I didn't mean temporary internet files, I meant in RAM. If it didn't work when you hit ctrl+enter then there is likely a problem with the code; or the sandbox is stopping you. I'm fairly sure the code has to be both in the banner and the game. But the entire code that you wrote in the previous posts does not have to be in both, as long as neither of those tries to access anything else. And, if you're in one domain, and only using one server, then you should contact them and see if they can't change the settings. You should only need this code if you are trying to access something cross-domain.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

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