Ultrashock Forums > Flash > Components
Simple Carousel problem

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
Simple Carousel problem
Old 2008-03-28

Hey, I love your simple carousel menu, but I cant seem to get it to actually click thru to anything!

Code:
function mouseDownListener(e:MouseEvent):void
{
	var clip1_mcURL:String  = "http://www.google.com"
	var clip2_mcURL:String  = "http://www.google.com"
	var clip3_mcURL:String  = "http://www.google.com"
	var clip4_mcURL:String  = "http://www.google.com"
	var clip5_mcURL:String  = "http://www.google.com"
	
	var clickthru:URLRequest = new URLRequest(e.target.name+"URL");
	navigateToURL(clickthru);
	trace(e.target.name + " was pressed.");
}
the trace action works fine, but the clickthru always passes "clip1_mcURL" instead of the URL. what am I doing wrong?
postbit arrow 2 comments | 989 views postbit arrow Reply: with Quote   
Registered User
flo_evans is offline
seperator
Posts: 2
2008-02-07
flo_evans lives in United States
seperator

Ultrashock Member Comments:
gusmcq's Avatar gusmcq gusmcq is offline gusmcq lives in United Kingdom Creative Assets 2008-03-28 #2 Old  
Hi Flo, welcome to Ultrashock

The code doesn't do what you want because you're mixing variable names and strings. To be specific, the statement
Code:
new URLRequest(e.target.name+"URL")
will create a url request with the url "clip1_mcURL", not the value of the variable with that name.

Try this instead.

Code:
var clip1_mcURL:String  = "http://www.google.com"
var clip2_mcURL:String  = "http://www.google.com"
var clip3_mcURL:String  = "http://www.google.com"
var clip4_mcURL:String  = "http://www.google.com"
var clip5_mcURL:String  = "http://www.google.com"

function mouseDownListener(e:MouseEvent):void
{
	var clickthru:URLRequest = new URLRequest(this[e.target.name+"URL"]);
	navigateToURL(clickthru);
	trace(e.target.name + " was pressed. URL is " + clickthru.url);
}
By declaring the variables outside the function, Flash creates properties on the object (in this case, the MovieClip). Then we can retrieve their actual values from their name string, using the statement this["propertyName"];

Code:
this[e.target.name+"URL"]
This retrieves the actual value of the property (variable) with the name e.target.name+URL, in this case "http://www.google.com". Now your code should do what you want

HTH.

And I'm glad you like the Carousel. Thanks

Gus (Asset Author)
Reply With Quote  
flo_evans flo_evans is offline flo_evans lives in United States 2008-03-31 #3 Old  
ahha! thanks! Still getting used to AS3 and writing everything as functions. I had gotten used to just relying on button and MC actions :P
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: