Skip to content

Commit

Permalink
Added some fixes to the Dash Media Player to allow the teaser to cont…
Browse files Browse the repository at this point in the history
…rol the node with regard to voting and other operations.
  • Loading branch information
Travis Tidwell committed May 9, 2010
1 parent 17db946 commit d113b45
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 157 deletions.
1 change: 1 addition & 0 deletions com/tmtdigital/dash/config/Variables.as
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ package com.tmtdigital.dash.config
public var taglinkcolor:uint = 0x6666FF;
public var tagplaylist:String = '';
public var teaserplay:Boolean = false;
public var teaserselect:Boolean = true;
public var termlinks:Boolean = true;
public var termspacing:Number = 5;
public var theme:String = "default";
Expand Down
2 changes: 1 addition & 1 deletion com/tmtdigital/dash/display/node/Teaser.as
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/** * Copyright 2008 - TMTDigital LLC * * Author: Travis Tidwell (www.travistidwell.com) * Version: 1.0 * Date: June 9th, 2008 * * Description: The teaser class is a dynamically created element that * is added to the Playlist. It represents a single node in the Dash Player. * **/package com.tmtdigital.dash.display.node{ import com.tmtdigital.dash.display.node.NodeBase; import com.tmtdigital.dash.events.DashEvent; import com.tmtdigital.dash.config.Params; import flash.events.*; import flash.display.*; import fl.transitions.*; import fl.transitions.easing.*; import flash.net.*; public class Teaser extends NodeBase { public function Teaser( _skin:MovieClip, _index:Number ) { index = _index; super( _skin ); } public override function setSkin( _skin:MovieClip ) { type = "teaser"; super.setSkin( _skin ); // Set the teaser control bar. if( fields && fields.media.skin ) { fields.media.setControlBar( "teaser" ); } skin.buttonMode = true; skin.mouseChildren = false; skin.addEventListener( MouseEvent.MOUSE_OVER, onOver ); skin.addEventListener( MouseEvent.MOUSE_OUT, onOut ); skin.addEventListener( MouseEvent.MOUSE_DOWN, onDown ); skin.addEventListener( MouseEvent.MOUSE_UP, onUp ); if (rootSkin.onTeaserInit is Function) { rootSkin.onTeaserInit( this ); } visible = false; } public function setTeaserButton( buttonMC:MovieClip, selectable:Boolean ) { if (buttonMC) { buttonMC.buttonMode = false; buttonMC.mouseChildren = true; buttonMC.removeEventListener( MouseEvent.MOUSE_OVER, onOver ); buttonMC.removeEventListener( MouseEvent.MOUSE_OUT, onOut ); buttonMC.removeEventListener( MouseEvent.MOUSE_DOWN, onDown ); buttonMC.removeEventListener( MouseEvent.MOUSE_UP, onUp ); if (selectable) { buttonMC.buttonMode = true; buttonMC.mouseChildren = false; buttonMC.addEventListener( MouseEvent.MOUSE_OVER, onOver ); buttonMC.addEventListener( MouseEvent.MOUSE_OUT, onOut ); buttonMC.addEventListener( MouseEvent.MOUSE_DOWN, onDown ); buttonMC.addEventListener( MouseEvent.MOUSE_UP, onUp ); } } } public override function loadNode( _node:* = null ):Boolean { if( fields ) { fields.selected = false; } selected = false; return super.loadNode( _node ); } public override function onNodeLoad( _node:Object ) { super.onNodeLoad( _node ); visible = true; } public function setSelect( select:Boolean ) { if( fields ) { fields.selected = select; } selected = select; setTeaserButton( skin, (!selected || !Params.flashVars.teaserplay)); if (rootSkin.onTeaserSelect is Function) { rootSkin.onTeaserSelect( this, selected ); } } public function onOver( e:MouseEvent ) { if (rootSkin.onTeaserOver is Function) { rootSkin.onTeaserOver( this ); } } public function onOut( e:MouseEvent ) { if (rootSkin.onTeaserOut is Function) { rootSkin.onTeaserOut( this ); } } public function onDown( e:MouseEvent ) { if (rootSkin.onTeaserDown is Function) { rootSkin.onTeaserDown( this ); } } public function onUp( e:MouseEvent = null ) { if (rootSkin.onTeaserUp is Function) { rootSkin.onTeaserUp( this ); } loadTeaser(); } public function loadTeaser() { if (Params.flashVars.pagelink && node) { var path:String = Params.baseURL; path += node.path ? ("/" + node.path) : (Params.flashVars.pagelinkarg + node.nid); path += "/" + page + "/" + index; navigateToURL(new URLRequest( path ), "_self"); } else { dispatchEvent( new DashEvent( DashEvent.TEASER_CLICK ) ); } } public var index:uint; public var page:uint; private var selected:Boolean; }}
/** * Copyright 2008 - TMTDigital LLC * * Author: Travis Tidwell (www.travistidwell.com) * Version: 1.0 * Date: June 9th, 2008 * * Description: The teaser class is a dynamically created element that * is added to the Playlist. It represents a single node in the Dash Player. * **/package com.tmtdigital.dash.display.node{ import com.tmtdigital.dash.display.node.NodeBase; import com.tmtdigital.dash.events.DashEvent; import com.tmtdigital.dash.config.Params; import flash.events.*; import flash.display.*; import fl.transitions.*; import fl.transitions.easing.*; import flash.net.*; public class Teaser extends NodeBase { public function Teaser( _skin:MovieClip, _index:Number ) { index = _index; super( _skin ); } public override function setSkin( _skin:MovieClip ) { type = "teaser"; super.setSkin( _skin ); // Set the teaser control bar. if( fields && fields.media.skin ) { fields.media.setControlBar( "teaser" ); } if( (!Params.flashVars.teaserplay && Params.flashVars.teaserselect) ) { skin.buttonMode = true; skin.mouseChildren = false; skin.addEventListener( MouseEvent.MOUSE_OVER, onOver ); skin.addEventListener( MouseEvent.MOUSE_OUT, onOut ); skin.addEventListener( MouseEvent.MOUSE_DOWN, onDown ); skin.addEventListener( MouseEvent.MOUSE_UP, onUp ); } if (rootSkin.onTeaserInit is Function) { rootSkin.onTeaserInit( this ); } visible = false; } public function setTeaserButton( buttonMC:MovieClip, selectable:Boolean ) { if (buttonMC) { buttonMC.buttonMode = false; buttonMC.mouseChildren = true; buttonMC.removeEventListener( MouseEvent.MOUSE_OVER, onOver ); buttonMC.removeEventListener( MouseEvent.MOUSE_OUT, onOut ); buttonMC.removeEventListener( MouseEvent.MOUSE_DOWN, onDown ); buttonMC.removeEventListener( MouseEvent.MOUSE_UP, onUp ); if (selectable) { buttonMC.buttonMode = true; buttonMC.mouseChildren = false; buttonMC.addEventListener( MouseEvent.MOUSE_OVER, onOver ); buttonMC.addEventListener( MouseEvent.MOUSE_OUT, onOut ); buttonMC.addEventListener( MouseEvent.MOUSE_DOWN, onDown ); buttonMC.addEventListener( MouseEvent.MOUSE_UP, onUp ); } } } public override function loadNode( _node:* = null ):Boolean { if( fields ) { fields.selected = false; } selected = false; return super.loadNode( _node ); } public override function onNodeLoad( _node:Object ) { super.onNodeLoad( _node ); visible = true; } public function setSelect( select:Boolean ) { if( fields ) { fields.selected = select; } selected = select; setTeaserButton( skin, (!selected || (!Params.flashVars.teaserplay && Params.flashVars.teaserselect))); if (rootSkin.onTeaserSelect is Function) { rootSkin.onTeaserSelect( this, selected ); } } public function onOver( e:MouseEvent ) { if (rootSkin.onTeaserOver is Function) { rootSkin.onTeaserOver( this ); } } public function onOut( e:MouseEvent ) { if (rootSkin.onTeaserOut is Function) { rootSkin.onTeaserOut( this ); } } public function onDown( e:MouseEvent ) { if (rootSkin.onTeaserDown is Function) { rootSkin.onTeaserDown( this ); } } public function onUp( e:MouseEvent = null ) { if (rootSkin.onTeaserUp is Function) { rootSkin.onTeaserUp( this ); } loadTeaser(); } public function loadTeaser() { if (Params.flashVars.pagelink && node) { var path:String = Params.baseURL; path += node.path ? ("/" + node.path) : (Params.flashVars.pagelinkarg + node.nid); path += "/" + page + "/" + index; navigateToURL(new URLRequest( path ), "_self"); } else { dispatchEvent( new DashEvent( DashEvent.TEASER_CLICK ) ); } } public var index:uint; public var page:uint; private var selected:Boolean; }}
Expand Down
155 changes: 1 addition & 154 deletions com/tmtdigital/dash/display/voter/DashVoter.as
Original file line number Diff line number Diff line change
@@ -1,154 +1 @@
/**
* Copyright 2008 - TMTDigital LLC
*
* Author: Travis Tidwell (www.travistidwell.com)
* Version: 1.0
* Date: June 9th, 2008
*
* Description: The DashVoterBase is used as a base class for any
* voting widgets that are contained in the Dash Player. It is also
* used to just display the votes of any current node in the players playlist.
*
**/

package com.tmtdigital.dash.display.voter
{
import com.tmtdigital.dash.DashPlayer;
import com.tmtdigital.dash.net.Service;
import com.tmtdigital.dash.utils.Resizer;
import com.tmtdigital.dash.utils.LayoutManager;
import com.tmtdigital.dash.display.voter.TagVoter;
import com.tmtdigital.dash.display.Skinable;
import com.tmtdigital.dash.events.DashEvent;
import com.tmtdigital.dash.utils.Utils;
import com.tmtdigital.dash.net.Gateway;
import com.tmtdigital.dash.config.Params;

import flash.utils.*;
import flash.events.*;
import flash.display.*;
import fl.transitions.*;
import fl.transitions.easing.*;

public class DashVoter extends Skinable
{
public function DashVoter( _skin:MovieClip, _type:String )
{
type = _type;
var _skinPath:String = "";

if( Params.flashVars.voter && Params.flashVars.votingenabled ) {
_skinPath = Params.getRootPath();
_skinPath += "/plugins/voters/" + Params.flashVars.voter + "/voter.swf";
}

super( _skin, _skinPath );
}

public override function getSkin( newSkin:MovieClip ) : MovieClip
{
if( rootSkin && (rootSkin.getVoter is Function) ) {
return rootSkin.getVoter( type );
}

return newSkin;
}

public override function setSkin( _skin:MovieClip )
{
super.setSkin( _skin );

if( skin ) {
submitted = skin.submitted;
submit = skin.submit;

if( skin.tags ) {
tags = new Object();
var i:int = skin.tags.numChildren;
while (i--)
{
var tag:* = skin.tags.getChildAt(i);
var newTag:TagVoter = new TagVoter( tag );
newTag.setTag( tag.name );
newTag.addEventListener( DashEvent.VOTE_SET, voteHandler );
newTag.addEventListener( DashEvent.VOTE_DELETE, voteHandler );
newTag.addEventListener( DashEvent.PROCESSING, voteHandler );
tags[tag.name] = newTag;
}
}

visible = Params.flashVars.votingenabled;
}
}

public function setVote( vote:Object )
{
if( vote && vote.tag ) {
if( tags && tags[vote.tag] ) {
tags[vote.tag].setVote( vote );
}
}
}

// Show the loader when votes are being processed, nothing otherwise.
private function voteHandler( event:DashEvent )
{
if( event.type == DashEvent.VOTE_SET ) {
if (submitted) {
submitted.visible = true;
}

Gateway.setPlaylistVote( nodeId, event.args, Params.flashVars.disableplaylist );
}

DashPlayer.dash.node.spinner.visible = (event.type == DashEvent.PROCESSING);
}

// Loads the voter.
public function loadVoter( node:Object )
{
alpha = 0;
nodeId = node.nid;
setFieldsMC( nodeId );
}

// Sets the voter fields.
protected function setFieldsMC( nodeId:Number )
{
var shouldCache:Boolean = false;

if (submit) {
shouldCache = true;
submit.buttonMode = true;
submit.mouseChildren = false;
submit.gotoAndStop("_up");
submit.removeEventListener( MouseEvent.MOUSE_UP, onVoteSubmit );
submit.addEventListener( MouseEvent.MOUSE_UP, onVoteSubmit );
}

if (submitted) {
submitted.visible = false;
}

for each( var tag:TagVoter in tags ) {
tag.getVotes( nodeId, shouldCache );
}
}

// Called when the user presses the submit key.
protected function onVoteSubmit( e:MouseEvent )
{
// We want to process all votes here...
for each( var tag:TagVoter in tags ) {
tag.processVotes();
}
}

public var submitted:Sprite;
public var submit:MovieClip;
public var tags:Object;

private var type:String;
private var nodeId:Number;
}
}
/** * Copyright 2008 - TMTDigital LLC * * Author: Travis Tidwell (www.travistidwell.com) * Version: 1.0 * Date: June 9th, 2008 * * Description: The DashVoterBase is used as a base class for any * voting widgets that are contained in the Dash Player. It is also * used to just display the votes of any current node in the players playlist. * **/package com.tmtdigital.dash.display.voter{ import com.tmtdigital.dash.DashPlayer; import com.tmtdigital.dash.net.Service; import com.tmtdigital.dash.utils.Resizer; import com.tmtdigital.dash.utils.LayoutManager; import com.tmtdigital.dash.display.voter.TagVoter; import com.tmtdigital.dash.display.Skinable; import com.tmtdigital.dash.events.DashEvent; import com.tmtdigital.dash.utils.Utils; import com.tmtdigital.dash.net.Gateway; import com.tmtdigital.dash.config.Params; import flash.utils.*; import flash.events.*; import flash.display.*; import fl.transitions.*; import fl.transitions.easing.*; public class DashVoter extends Skinable { public function DashVoter( _skin:MovieClip, _type:String ) { type = _type; var _skinPath:String = ""; if( Params.flashVars.voter && Params.flashVars.votingenabled ) { _skinPath = Params.getRootPath(); _skinPath += "/plugins/voters/" + Params.flashVars.voter + "/voter.swf"; } super( _skin, _skinPath ); } public override function getSkin( newSkin:MovieClip ) : MovieClip { if( rootSkin && (rootSkin.getVoter is Function) ) { return rootSkin.getVoter( type ); } return newSkin; } public override function setSkin( _skin:MovieClip ) { super.setSkin( _skin ); if( skin ) { submitted = skin.submitted; submit = skin.submit; if( skin.tags ) { tags = new Object(); var i:int = skin.tags.numChildren; while (i--) { var tag:* = skin.tags.getChildAt(i); var newTag:TagVoter = new TagVoter( tag ); newTag.setTag( tag.name ); newTag.addEventListener( DashEvent.VOTE_GET, voteHandler ); newTag.addEventListener( DashEvent.VOTE_SET, voteHandler ); newTag.addEventListener( DashEvent.VOTE_DELETE, voteHandler ); newTag.addEventListener( DashEvent.PROCESSING, voteHandler ); tags[tag.name] = newTag; } } visible = Params.flashVars.votingenabled; } } public function setVote( vote:Object ) { if( vote && vote.tag ) { if( tags && tags[vote.tag] ) { tags[vote.tag].setVote( vote ); } } } // Show the loader when votes are being processed, nothing otherwise. private function voteHandler( event:DashEvent ) { if( event.type == DashEvent.VOTE_SET ) { if (submitted) { submitted.visible = true; } Gateway.setPlaylistVote( nodeId, event.args, Params.flashVars.disableplaylist ); } DashPlayer.dash.node.spinner.visible = (event.type == DashEvent.PROCESSING); // Call our hook for this operation. if ((rootSkin.onVote is Function) && event && event.args) { rootSkin.onVote( this, {type:event.type, vote:event.args} ); } } // Loads the voter. public function loadVoter( node:Object ) { alpha = 0; nodeId = node.nid; setFieldsMC( nodeId ); } // Sets the voter fields. protected function setFieldsMC( nodeId:Number ) { var shouldCache:Boolean = false; if (submit) { shouldCache = true; submit.buttonMode = true; submit.mouseChildren = false; submit.gotoAndStop("_up"); submit.removeEventListener( MouseEvent.MOUSE_UP, onVoteSubmit ); submit.addEventListener( MouseEvent.MOUSE_UP, onVoteSubmit ); } if (submitted) { submitted.visible = false; } for each( var tag:TagVoter in tags ) { tag.getVotes( nodeId, shouldCache ); } } // Called when the user presses the submit key. protected function onVoteSubmit( e:MouseEvent ) { // We want to process all votes here... for each( var tag:TagVoter in tags ) { tag.processVotes(); } } public var submitted:Sprite; public var submit:MovieClip; public var tags:Object; private var type:String; private var nodeId:Number; }}
Expand Down
2 changes: 2 additions & 0 deletions com/tmtdigital/dash/display/voter/TagVoter.as
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@

// Set up our voters.
vote = new Voter( _skin.vote );
vote.addEventListener( DashEvent.VOTE_GET, voteHandler );
vote.addEventListener( DashEvent.VOTE_SET, voteHandler );
vote.addEventListener( DashEvent.VOTE_DELETE, voteHandler );
vote.addEventListener( DashEvent.PROCESSING, voteHandler );

uservote = new Voter( _skin.uservote, true );
uservote.addEventListener( DashEvent.VOTE_GET, voteHandler );
uservote.addEventListener( DashEvent.VOTE_SET, voteHandler );
uservote.addEventListener( DashEvent.VOTE_DELETE, voteHandler );
uservote.addEventListener( DashEvent.PROCESSING, voteHandler );
Expand Down
4 changes: 2 additions & 2 deletions com/tmtdigital/dash/display/voter/Voter.as
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@
private function onVoteSet( vote:Object )
{
// Set the selected fill width
setVote( {value: (userMode ? voteValue : vote.value)} );
dispatchEvent( new DashEvent( DashEvent.VOTE_SET, vote ) );
setVote( {value: (userMode ? voteValue : vote.value)} );
dispatchEvent( new DashEvent( DashEvent.VOTE_SET, vote ) );
}

private function onVoteDelete( vote:Object )
Expand Down

0 comments on commit d113b45

Please sign in to comment.