Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delegate Class issue 1

Status
Not open for further replies.

Rieekan

Programmer
Apr 2, 2001
737
US
I'm building a small Flash application that will essentially rotate ads for a home page and have run into an issue that I can't seem to get a handle on what's causing it.

I'm dynamically getting the ads that will show up in the player via an XML file, loads the file into a clip and sets a Delegate for the onRelease action to the clip, essentially making that clip become a button with an action to some other content deeper in the site.

I'm running into the problem with the Delegate class. When I call it, setting it to a function that will handle getting the URL to go to and sending the user there, it is immediately executing that code and not waiting on the onRelease to occur first.

Code:
	function _onAdsLoadInit($mc)
	{
		if (_isSmallVersion)
		{
			$mc._yscale = $mc._xscale;
		}
		var _maskNumber = _getRandomNumber(0, 4);
		var _movieClip = $mc._parent.attachMovie("movieMask" + _maskNumber, "mask", 2);
		$mc.setMask(_movieClip);
		var _parentId = $mc._parent.id;
		_carousel[_parentId].isLoaded = true;
		trace("_onAdsLoadInit: $mc._parent = " + $mc._parent);
		$mc._parent.onRelease = com.actionscript.utils.Delegate.create(this, _onClickAds(_parentId));
		if (_intervalElapsed && _parentId == this.__get__nextAd() && _isInited)
		{
			_nextReveal = nextAd;
			this._animateAdOut($mc);
		}
	}

	function _onClickAds($i)
	{
		trace("_onClickAds: $i = " + $i);
		var _webTrendsData = _sendWebTrendsData($i);
		if (com.nationwide.corporate.external.carousel.Constants.__get__IS_IN_BROWSER())
		{
			getURL(_carousel[$i].link);
		}
		else
		{
			trace("_onClickAds: Link = " + _carousel[$i].link);
			trace("_onClickAds: WebTrends = " + _webTrendsData);
		}
	}
	
	function _sendWebTrendsData($i)
	{
		/* TODO - Need to work with Bryan to get correct
		Web Trends information added to application */
		
		var _wtData = "javascript:dcsMultiTrack('DCS.dcsuri','" +
		com.nationwide.corporate.external.carousel.Constants.DCS_URI +
		"', 'WT.ti','" +
		_carousel[$i].wtname +
		"', 'WT.hpadclick','" +
		++$i +
		"');";
		
		return(_wtData);
	}

I hope I've explained this correctly. Any help is greatly appreciated!

- George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top