A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: flash button to open url from a text file

  1. #1
    Junior Member
    Join Date
    Sep 2005
    Posts
    28

    flash button to open url from a text file

    Hi Guys:

    I have a requirement please guide me. I have a button in flash which opens an URL. and this URL may change weekly or monthly so I just dont want to go and open .fla and change the URL.

    So my question is how can I create a button like this.?

    please help.

    I have attached what I did.

    Thanx in advance.
    Attached Files Attached Files

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    you would use loadVar object. to load the text file...

    here is an example:
    Code:
    newURL = new LoadVars();
    newURL.onLoad = function(success) {
    	if (!success) {
    		trace("FAILED TO LOAD");			
    	}else{
    		//do whatever you want to happen IF successful
    	        trace(newURL.link);  //newURL = your textFile & link = variable in text file
    		webSite = newURL.link;
    		//set button code
    		button1.onPress = function() {
    			getURL(webSite);
    		}
    	}
    };
    newURL.load("someTextFile.txt");
    alternately.. you could aready have your button actions assigned:
    Code:
    on(press){
        getURL(webSite);
    }
    the text file should look like this on the inside:

    link=http://www.nike.com

  3. #3
    Junior Member
    Join Date
    Sep 2005
    Posts
    28

    thanx

    Hey Thanx a lot its working.

    But one problem here. I m having more than 20 buttons on the same screen and I want to have it for each button.

    and if i m using the same action for other buttons after changing the button name and text file name in the script its not working.

    what to do ?

  4. #4
    Junior Member
    Join Date
    Sep 2005
    Posts
    28

    attachment

    here is the fla what i did.
    Attached Files Attached Files
    Last edited by vishal.sonar; 01-10-2007 at 05:24 AM.

  5. #5
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    you can use the SAME code as above.. AND the same text file.. just need to ADD some more to it..

    in the SAME text file..add another flashVar

    so it looks like:

    link=http://www.nike.com&link2=http://www.yahoo.com&link3=http://www.msn.com

    then you just add to the code.. to set the actions for your other buttons.

    button1.onPress = function() {
    getURL(webSite);
    }
    button2.onPress = function() {
    getURL(newURL.link2);
    }
    button3.onPress = function() {
    getURL(newURL.link3);
    }


    etc..etc.. you could even just set up a loop to do ALL thel inks & buttons at the same time.. but all buttons would need to be named something like button1 button2 button3..and then the vars in the text file would need to be link1 link2 link3..etc..etc.. so you could run a for loop on them,..

  6. #6
    Junior Member
    Join Date
    Sep 2005
    Posts
    28

    thanx

    Hey Thanx,

    Its working fine. Thanx a lot.

  7. #7

  8. #8
    Junior Member
    Join Date
    Sep 2005
    Posts
    28

    issue again

    Hey... its working fine. But why its that I have to click twice (double click) to open the url. Because if I click just once its not opening anything.

    what could be the reason ??

  9. #9
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    not sure.

    are you using Internet Explorer? Does it do this in FireFox?

    Are you using SWF Object to embed it or anything?

  10. #10
    Junior Member
    Join Date
    Sep 2005
    Posts
    28

    interne explorer

    I am using internet explorer. And I am wondering why its happening. I am still double clicking to open the link.



    And I just wanted to ask you can you help me on creating like the flash piece like it is there in http://www.pg.com.

    To make it easy to understand: here the functionality is something like... there are 4 animations for 4 links which are playing simultaneously. Now, when I am taking my mouse to the other links, here its playing the animation corresponding to that particular link and the same for all four animations and links.

    Now I am stuck. Can you help me on this.

  11. #11
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    does this happen in FireFox browser?..if NOT.. I suspect it the way you have embedded the Flash movie into your HTML page...

  12. #12
    Junior Member
    Join Date
    Sep 2005
    Posts
    28
    I am using Macromedia Dreamweaver to embed the flash. I dont know if this gives any problem. I am not using FireFox browser, I dont know if it gives the same problem there also.

  13. #13
    Junior Member
    Join Date
    Dec 2006
    Posts
    14
    If you change the "onPress" to "onRelease" does that solve the problem?

  14. #14
    Designer
    Join Date
    Apr 2006
    Posts
    3
    Sorry to bring back this thread from the dead, but have you found a solution to the double click problem? It has nothing to do with the IE click to enable.

    I am using CS3, my code is the same as whispers. I see you are no longer having this problem on pg.com vishal.sonar, did you go a different route or did you find a solutions?

    Thanks!

  15. #15
    Member
    Join Date
    Jul 2006
    Posts
    95

    any work around this dlb click issue?

    Wow this is kind of an old post, but I'm having the same double click issue and am wondering if anyone knows a work-around???

  16. #16
    Designer
    Join Date
    Apr 2006
    Posts
    3
    I solved the problem i was having, it was so long ago. I believe I replaced the onPress with onRelease to solve the double clicking but I can't be sure.

    Good luck!

  17. #17
    Member
    Join Date
    Jul 2006
    Posts
    95
    no, its not that. I tried that first thing. If you remember what you did do, please let me know. thanks

  18. #18
    Banned
    Join Date
    Jun 2008
    Posts
    2
    useful,thank u...

  19. #19
    Junior Member
    Join Date
    Jun 2010
    Posts
    1
    whispers, you are the (wo)man! I signed up for this board just so I could thank you.

  20. #20

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