www.webdeveloper.com
Results 1 to 4 of 4

Thread: [FLASH Actionscript] Simple getURL in function doesn't work

  1. #1
    Join Date
    Aug 2009
    Posts
    17

    [FLASH Actionscript] Simple getURL in function doesn't work

    I'm modifying an mp3 player by flabell, and try to get some buttons to work. However, I can't seem to get the getURL to work, even though it works in other parts of the script. This is my code:

    Code:
    mc.rate1.onRelease = function() {
    				trace(this.ID);
    				getURL("http://www.google.com","_blank"); 
        		};
    The trace goes through fine.

    If I change the code to this:

    Code:
    getURL("http://www.google.com","_blank"); 
    			
    			mc.rate1.onRelease = function() {
    				
    				
    				trace(this.ID);
        		};
    '

    It works. It's only inside the function, it doesn't work.




    Here is the original code that works:

    Code:
    private function downloadRelease(mc : MovieClip) : Void
    	{
    		var title : String = mc._name;
    		var index : Number = Number(title.substring(title.lastIndexOf("n")+1,title.length));
    		getURL(songsSource[index], Main.getInstance().mcAlbums.linksTarget);
    	}

    I have tested it online as well, it doesn't work.


    I've tried making a function, with a getURL:
    Code:
    private function visitPage(url : String) : Void
    	{
    		
    		getURL(url,"_blank");
    trace("in");
    }
    If I run the function in the onRelease event, the 'in' trace does not occur.

    So something is not working, but I'm not enough of a flash expert, to see why. Help please! This is driving me insane.

  2. #2
    Join Date
    Feb 2008
    Location
    NW Washington State
    Posts
    1,856
    There is nothing wrong with the code as far as the getURL goes:
    Code:
    mc.rate1.onRelease = function() {
    		trace(this.ID);
    		getURL("http://www.google.com","_blank"); 
        	};
    The problem is that most likely you did not give "rate1" an instance name (in the properties panel) and/or mc an instance name.
    Reading the code goes like this...
    Inside the symbol "mc", (movie clip or whatever) there is another symbol, "rate1", and onRelease, do the function.
    But when you drill down like that, both symbols must have instance names.
    Best wishes,
    Eye for Video
    www.cidigitalmedia.com

  3. #3
    Join Date
    Aug 2009
    Posts
    17
    Quote Originally Posted by Eye for Video View Post
    There is nothing wrong with the code as far as the getURL goes:
    Code:
    mc.rate1.onRelease = function() {
    		trace(this.ID);
    		getURL("http://www.google.com","_blank"); 
        	};
    The problem is that most likely you did not give "rate1" an instance name (in the properties panel) and/or mc an instance name.
    Reading the code goes like this...
    Inside the symbol "mc", (movie clip or whatever) there is another symbol, "rate1", and onRelease, do the function.
    But when you drill down like that, both symbols must have instance names.
    Best wishes,
    Eye for Video
    www.cidigitalmedia.com
    Well, for once the trace works fine, so the instance names should be fine. I checked anyway, and they look fine. The movieclip was created thusly (code not written by me):

    Code:
    var mc : MovieClip = mcContent.attachMovie("mcPlaylistButton", "mcPlaylistButton" + i, i);
    Then this code is added by me:
    Code:
    		
    		mc.rate1.ID = "./update_rating.php?r=1&id="+mp3Ids[i];
    		mc.rate2.ID = "./update_rating.php?r=2&id="+mp3Ids[i];
    		mc.rate3.ID = "./update_rating.php?r=3&id="+mp3Ids[i];
    		mc.rate4.ID = "./update_rating.php?r=4&id="+mp3Ids[i];
    		mc.rate5.ID = "./update_rating.php?r=5&id="+mp3Ids[i];
    		mc.rate6.ID = "./update_rating.php?r=6&id="+mp3Ids[i];
    		mc.rate7.ID = "./update_rating.php?r=7&id="+mp3Ids[i];
    		mc.rate8.ID = "./update_rating.php?r=8&id="+mp3Ids[i];
    		mc.rate9.ID = "./update_rating.php?r=9&id="+mp3Ids[i];
    		mc.rate10.ID = "./update_rating.php?r=10&id="+mp3Ids[i];
    			
    			
    			mc.rate1.onRelease = function() {
    				getURL("http://www.google.com","_blank"); 
    				trace(this.ID);
        		};
    			mc.rate2.onRelease = function() {
    				getURL("http://www.google.com","_blank"); 
    				
        			trace(this.ID);
    			};
    			mc.rate3.onRelease = function() {
    				getURL("http://www.google.com","_blank"); 
    				
        			trace(this.ID);
    			};
    			mc.rate4.onRelease = function() {
    				getURL("http://www.google.com","_blank"); 
    				
        			trace(this.ID);
    			};
    			mc.rate5.onRelease = function() {
    				getURL("http://www.google.com","_blank"); 
    				
        			trace(this.ID);
    			};
    			mc.rate6.onRelease = function() {
    				getURL("http://www.google.com","_blank"); 
    				
        			trace(this.ID);
    			};
    			mc.rate7.onRelease = function() {
    				getURL("http://www.google.com","_blank"); 
    				
        			trace(this.ID);
    			};
    			mc.rate8.onRelease = function() {
    				getURL("http://www.google.com","_blank"); 
    				
        			trace(this.ID);
    			};
    			mc.rate9.onRelease = function() {
    				getURL("http://www.google.com","_blank"); 
    				
        			trace(this.ID);
    			};
    			mc.rate10.onRelease = function() {
    				getURL("http://www.google.com","_blank"); 
    				trace(this.ID);
    			};
    All the traces work perfectly, displaying the url to be used, but the getURL returns nothing, not even an error.

  4. #4
    Join Date
    Aug 2009
    Posts
    17
    Here is the project I'm working on.
    http://rcpt.yousendit.com/738344035/...b277a483f32a25

    The two files I'm having trouble with (and have edited the most) is the product.fla and playlist.as.

    In the product.fla, my buttons are in the movieclip mcPlaylistButton.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles