- rename swfSlideLoader to just slideLoader

- add comments on the functions to at least help in explaining how it's used.
This commit is contained in:
Richard Alam 2010-06-28 11:24:32 -04:00
parent a6730c24b3
commit 09384df99d
2 changed files with 141 additions and 78 deletions

View File

@ -433,7 +433,7 @@
private function clearPresentation(e:UploadEvent):void{
slideView.visible = false;
slideView.swfSlideLoader.source = null;
slideView.slideLoader.source = null;
slideView.selectedSlide = 0;
btnSlideNum.label = "";
displaySlideNavigationControls(false);

View File

@ -106,9 +106,9 @@
private var dispatcher:Dispatcher = new Dispatcher();
private function onCreationComplete():void{
swfSlideLoader.width = this.width;
swfSlideLoader.height = this.height;
private function onCreationComplete():void {
slideLoader.width = this.width;
slideLoader.height = this.height;
cursor = new Shape();
cursor.graphics.lineStyle(6, 0xFF0000, 0.6);
@ -123,135 +123,172 @@
this.setChildIndex(thumbnailView, this.numChildren - 1);
}
public function setSlides(slides:ArrayCollection):void{
public function setSlides(slides:ArrayCollection):void {
this.slides = slides;
thumbnailView.dataProvider = this.slides.toArray();
}
private function changeSlide():void{
private function changeSlide():void {
dispatchEvent(new PresenterCommands(PresenterCommands.GOTO_SLIDE, thumbnailView.selectedIndex));
thumbnailView.visible = false;
showOverlayCanvas(true);
dispatchEvent(new Event(THUMBNAILS_CLOSED));
}
private function changeIndex(e:ListEvent):void{
private function changeIndex(e:ListEvent):void {
dispatchEvent(e);
}
private function onMouseDown(e:MouseEvent):void{
/**
* Triggered when the presenter clicks on the slides with the intent of moving it.
*/
private function onMouseDown(e:MouseEvent):void {
canvasMouseXOnMouseDown = this.mouseX;
canvasMouseYOnMouseDown = this.mouseY;
loaderXOnMouseDown = swfSlideLoader.x;
loaderYOnMouseDown = swfSlideLoader.y;
loaderXOnMouseDown = slideLoader.x;
loaderYOnMouseDown = slideLoader.y;
addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
}
/**
* Triggered when the mouse had been clicked and dragged to move the slide.
*/
private function onMouseMove(e:MouseEvent):void {
// Compute the change in mouse position from where the mouse was clicked.
var deltaCanvasMouseX:Number = this.mouseX - canvasMouseXOnMouseDown;
var deltaCanvasMouseY:Number = this.mouseY - canvasMouseYOnMouseDown;
swfSlideLoader.x = loaderXOnMouseDown + deltaCanvasMouseX;
swfSlideLoader.y = loaderYOnMouseDown + deltaCanvasMouseY;
// Now we move the slide by the amount of mouse location change.
slideLoader.x = loaderXOnMouseDown + deltaCanvasMouseX;
slideLoader.y = loaderYOnMouseDown + deltaCanvasMouseY;
// Move the slide within the loader.
fitSlideToLoader();
notifyOtherParticipantsOfSlideMoving();
}
/**
* Send a message to other participants indicating the presenter has moved the slide.
*/
private function notifyOtherParticipantsOfSlideMoving():void {
var presentEvent:PresenterCommands = new PresenterCommands(PresenterCommands.MOVE);
presentEvent.xOffset = swfSlideLoader.x/swfSlideLoader.width;
presentEvent.yOffset = swfSlideLoader.y/swfSlideLoader.height;
presentEvent.slideToCanvasWidthRatio = swfSlideLoader.width/this.width;
presentEvent.slideToCanvasHeightRatio = swfSlideLoader.height/this.height;
presentEvent.xOffset = slideLoader.x/slideLoader.width;
presentEvent.yOffset = slideLoader.y/slideLoader.height;
presentEvent.slideToCanvasWidthRatio = slideLoader.width/this.width;
presentEvent.slideToCanvasHeightRatio = slideLoader.height/this.height;
dispatchEvent(presentEvent);
}
/**
* Triggered when the presenter releases the mouse button.
*/
private function onMouseUp(e:MouseEvent):void{
removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
}
/**
* Triggered when the presenter has dragged the cursor outside the presetation window.
*/
private function onMouseOut(e:MouseEvent):void{
removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
}
/**
* Handles the resizing of the presenter's window. This is for the presenter resizing
* his/her window.
*/
private function handleWindowResizeEvent(event:WindowResizedEvent):void {
this.width = event.width;
this.height = event.height;
resizeAndMoveLoaderInRelationToCanvas();
}
/**
* Resize and moves the slide loader within the canvas container.
*/
private function resizeAndMoveLoaderInRelationToCanvas():void {
swfSlideLoader.width = this.width * presentersLoaderCanvasWidthRatio;
swfSlideLoader.height = this.height * presentersLoaderCanvasHeightRatio;
slideLoader.width = this.width * presentersLoaderCanvasWidthRatio;
slideLoader.height = this.height * presentersLoaderCanvasHeightRatio;
swfSlideLoader.x = swfSlideLoader.width * presentersLoaderXOffsetFromCanvas;
swfSlideLoader.y = swfSlideLoader.height * presentersLoaderYOffsetFromCanvas;
slideLoader.x = slideLoader.width * presentersLoaderXOffsetFromCanvas;
slideLoader.y = slideLoader.height * presentersLoaderYOffsetFromCanvas;
fitSlideToLoader();
}
/**
* Fit the slide inside the loader.
*/
private function fitSlideToLoader():void {
if (noSlideContentLoaded()) return;
swfSlideLoader.content.x = swfSlideLoader.x;
swfSlideLoader.content.y = swfSlideLoader.y;
swfSlideLoader.content.width = swfSlideLoader.width;
swfSlideLoader.content.height = swfSlideLoader.height;
slideLoader.content.x = slideLoader.x;
slideLoader.content.y = slideLoader.y;
slideLoader.content.width = slideLoader.width;
slideLoader.content.height = slideLoader.height;
zoomCanvas(swfSlideLoader.width, swfSlideLoader.height);
zoomCanvas(slideLoader.width, slideLoader.height);
}
private function fitLoaderToCanvas():void{
if (noSlideContentLoaded()) return;
swfSlideLoader.width = this.width;
swfSlideLoader.height = this.height;
swfSlideLoader.x = this.x;
swfSlideLoader.y = this.y;
slideLoader.width = this.width;
slideLoader.height = this.height;
slideLoader.x = this.x;
slideLoader.y = this.y;
fitSlideToLoader();
}
/**
*
*/
private function resizeAndMoveLoaderBy(percent:Number):void {
// Save the old loader dimensions. We need these to calculate
// the new position of the loader;
var oldLoaderHeight:int = swfSlideLoader.height;
var oldLoaderWidth:int = swfSlideLoader.width;
var oldLoaderHeight:int = slideLoader.height;
var oldLoaderWidth:int = slideLoader.width;
swfSlideLoader.width = this.width * percent/100;
swfSlideLoader.height = this.height * percent/100;
slideLoader.width = this.width * percent/100;
slideLoader.height = this.height * percent/100;
swfSlideLoader.x = calculateNewLoaderX(oldLoaderWidth);
swfSlideLoader.y = calculateNewLoaderY(oldLoaderHeight);
slideLoader.x = calculateNewLoaderX(oldLoaderWidth);
slideLoader.y = calculateNewLoaderY(oldLoaderHeight);
fitSlideToLoader();
}
/**
* Determines the new y coordinate of the loader. This determines if the location has
* changed because the slide was resized or moved.
*/
private function calculateNewLoaderY(oldLoaderHeight:int):int {
var deltaPercentHeight:Number = (swfSlideLoader.height - oldLoaderHeight) /oldLoaderHeight;
var deltaPercentHeight:Number = (slideLoader.height - oldLoaderHeight) /oldLoaderHeight;
var newLoaderY:int = (swfSlideLoader.y/swfSlideLoader.height) * deltaPercentHeight;
var newLoaderY:int = (slideLoader.y/slideLoader.height) * deltaPercentHeight;
if (newLoaderY == 0) {
newLoaderY = swfSlideLoader.y - (deltaPercentHeight * 100);
newLoaderY = slideLoader.y - (deltaPercentHeight * 100);
} else {
newLoaderY = swfSlideLoader.y - newLoaderY;
newLoaderY = slideLoader.y - newLoaderY;
}
return newLoaderY;
}
/**
* Determines the new y coordinate of the loader. This determines if the location has
* changed because the slide was resized or moved.
*/
private function calculateNewLoaderX(oldLoaderWidth:int):int {
var deltaPercentWidth:Number = (swfSlideLoader.width - oldLoaderWidth) / oldLoaderWidth;
var newLoaderX:int = (swfSlideLoader.x/swfSlideLoader.width) * deltaPercentWidth;
var deltaPercentWidth:Number = (slideLoader.width - oldLoaderWidth) / oldLoaderWidth;
var newLoaderX:int = (slideLoader.x/slideLoader.width) * deltaPercentWidth;
if (newLoaderX == 0) {
newLoaderX = swfSlideLoader.x - (deltaPercentWidth * 100);
newLoaderX = slideLoader.x - (deltaPercentWidth * 100);
} else {
newLoaderX = swfSlideLoader.x - newLoaderX;
newLoaderX = slideLoader.x - newLoaderX;
}
return newLoaderX;
@ -278,6 +315,9 @@
notifyOthersOfZoomEvent();
}
/**
* Triggered when the presenter uses the mouse wheel to zoom in/out of the slide.
*/
private function onMouseWheelZoomEvent(e:MouseEvent):void {
if (presenterIsZoomingOut(e.delta)) {
zoomPercentage -= ZOOM_STEP;
@ -297,10 +337,10 @@
private function notifyOthersOfZoomEvent():void {
var presentEvent:PresenterCommands = new PresenterCommands(PresenterCommands.ZOOM);
presentEvent.xOffset = swfSlideLoader.x/swfSlideLoader.width;
presentEvent.yOffset = swfSlideLoader.y/swfSlideLoader.height;
presentEvent.slideToCanvasWidthRatio = swfSlideLoader.width/this.width;
presentEvent.slideToCanvasHeightRatio = swfSlideLoader.height/this.height;
presentEvent.xOffset = slideLoader.x/slideLoader.width;
presentEvent.yOffset = slideLoader.y/slideLoader.height;
presentEvent.slideToCanvasWidthRatio = slideLoader.width/this.width;
presentEvent.slideToCanvasHeightRatio = slideLoader.height/this.height;
dispatchEvent(presentEvent);
}
@ -309,43 +349,58 @@
return delta < 0;
}
/**
* Handles notification from presenter that the slide has moved.
*/
private function handleMoveEvent(e:MoveEvent):void{
savePresentersSettings(e.xOffset, e.yOffset, e.slideToCanvasWidthRatio, e.slideToCanvasHeightRatio);
if (!isPresenter) {
resizeAndMoveLoaderInRelationToCanvas();
}
moveCanvas(swfSlideLoader.x, swfSlideLoader.y);
moveCanvas(slideLoader.x, slideLoader.y);
}
/**
* Handle notification from presenter that the slide has been zoomed.
*/
private function handleZoomEvent(e:ZoomEvent):void {
savePresentersSettings(e.xOffset, e.yOffset, e.slideToCanvasWidthRatio, e.slideToCanvasHeightRatio);
if (!isPresenter) {
resizeAndMoveLoaderInRelationToCanvas();
}
zoomCanvas(swfSlideLoader.width, swfSlideLoader.height);
zoomCanvas(slideLoader.width, slideLoader.height);
}
/**
* Handle notification from loader that a slide has been loaded.
*/
private function handleSlideLoadedEvent(e:SlideEvent):void{
swfSlideLoader.source = e.slide;
slideLoader.source = e.slide;
}
/**
* Handle the event where this presenter becomes a viewer because another attendee became presenter.
*/
private function handleSwitchToViewerEvent(e:MadePresenterEvent):void{
participantIsNowPresenter(false);
removeEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheelZoomEvent);
swfSlideLoader.removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
swfSlideLoader.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
swfSlideLoader.removeEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
slideLoader.removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
slideLoader.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
slideLoader.removeEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
removeEventListener(MouseEvent.MOUSE_MOVE, mouseCursorUpdateListener);
}
/**
* Makes the attendee the presenter.
*/
private function handleSwitchToPresenterEvent(e:MadePresenterEvent):void{
participantIsNowPresenter(true);
addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheelZoomEvent);
swfSlideLoader.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
swfSlideLoader.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
swfSlideLoader.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
slideLoader.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
slideLoader.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
slideLoader.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
addEventListener(MouseEvent.MOUSE_MOVE, mouseCursorUpdateListener);
}
@ -353,11 +408,17 @@
this.isPresenter = presenter;
}
/**
* Listen for mouse events to track the cursor.
*/
public function mouseCursorUpdateListener(e:MouseEvent):void{
if (noSlideContentLoaded()) return;
notifyOthersOfPresentersCursorPosition(this.mouseX, this.mouseY);
}
/**
* Broadcast to other participants the location fo the mouse cursor.
*/
private function notifyOthersOfPresentersCursorPosition(cursorXPosition:int, cursorYPosition:int):void {
var command:PresenterCommands = new PresenterCommands(PresenterCommands.SEND_CURSOR_UPDATE);
command.xPercent = cursorXPosition / this.width;
@ -365,6 +426,9 @@
dispatchEvent(command);
}
/**
* Handle notification from presenter about the location of the mouse cursor.
*/
private function handleUpdateCursorEvent(e:CursorEvent):void{
if (noSlideContentLoaded()) return;
@ -379,9 +443,12 @@
}
private function noSlideContentLoaded():Boolean {
return swfSlideLoader.content == null
return slideLoader.content == null
}
/**
* Keep track of the presenter's x,y coordinates and the size of his/her presentation window.
*/
private function savePresentersSettings(xOffset:Number, yOffset:Number, widthRatio:Number, heightRatio:Number):void {
presentersLoaderXOffsetFromCanvas = xOffset;
presentersLoaderYOffsetFromCanvas = yOffset;
@ -389,20 +456,16 @@
presentersLoaderCanvasHeightRatio = heightRatio;
}
/******************************************************
* Helper functions to determine offsets
******************************************************/
/*
* Fire an event when a single slide has been loaded.
*/
private function listenForSlideLoadedCompleteEvent():void {
swfSlideLoader.addEventListener(Event.COMPLETE, handleSlideLoadedCompleteEvent);
slideLoader.addEventListener(Event.COMPLETE, handleSlideLoadedCompleteEvent);
}
private function handleSlideLoadedCompleteEvent(event:Event):void {
var slideRealWidth:int = swfSlideLoader.content.width;
var slideRealHeight:int = swfSlideLoader.content.height;
var slideRealWidth:int = slideLoader.content.width;
var slideRealHeight:int = slideLoader.content.height;
fitLoaderToCanvas();
dispatchNewSlideDisplayedEvent(slideRealWidth, slideRealHeight);
}
@ -448,8 +511,8 @@
}
public function moveCanvas(x:int, y:int):void{
overlayChildrenHolder.x = swfSlideLoader.x * 2;
overlayChildrenHolder.y = swfSlideLoader.y * 2;
overlayChildrenHolder.x = slideLoader.x * 2;
overlayChildrenHolder.y = slideLoader.y * 2;
if (overlayCanvas != null) overlayCanvas.moveCanvas(overlayChildrenHolder.x, overlayChildrenHolder.y);
}
@ -457,7 +520,7 @@
public function zoomCanvas(width:int, height:int):void{
overlayChildrenHolder.width = width;
overlayChildrenHolder.height = height;
moveCanvas(swfSlideLoader.x, swfSlideLoader.y);
moveCanvas(slideLoader.x, slideLoader.y);
if (overlayCanvas != null) overlayCanvas.zoomCanvas(width, height);
}
@ -472,7 +535,7 @@
]]>
</mx:Script>
<mx:SWFLoader id="swfSlideLoader" width="100%" height="100%" creationComplete="listenForSlideLoadedCompleteEvent()"
<mx:SWFLoader id="slideLoader" width="100%" height="100%" creationComplete="listenForSlideLoadedCompleteEvent()"
scaleContent="false" maintainAspectRatio="true" showBusyCursor="true" completeEffect="Fade"/>
<mx:HorizontalList id="thumbnailView" itemRenderer="org.bigbluebutton.modules.present.views.Thumbnail" itemRollOver="changeIndex(event)"