Author Message

Posted: Tue Nov 12, 2013 7:48 am   Post subject: vertical align slide into loader

Hello
i would like to vertical align slides: i have a 4/3 loader, which is sometimes loading 16/9 slides. i would like them to be at y=0, as so far slides are vertically centered into the player when the slide height is inferior to loader height

i made this:

Code:
var contentInfo:LoaderInfo = LoaderInfo(e.target);
var content:DisplayObject = contentInfo.content;
content.x = 0;
content.y = 0;


without result. any clue ?

thank you !


Profile profile test

Posted: Tue Nov 12, 2013 1:52 pm   Post subject: Re: vertical align slide into loader

Do you create your own preloader or use one of the built-in ones? Could you please send us a working sample of your project?


Profile profile test

Posted: Tue Nov 12, 2013 2:26 pm   Post subject: Re: vertical align slide into loader

hello and thx 4 your reply

i'm using a mix of one the sample as3 player with some custom settings and functions:

Code:
/*******************************************************************************
 * Copyright (c) iSpring Solutions, Inc.
 * All rights reserved. This source code and the accompanying materials are made
 * available under the terms of the iSpring Public License v1.0 which accompanies
 * this distribution, and is available at:
 * http://www.ispringsolutions.com/legal/public-license-v10.html
 *
 *******************************************************************************/

package com.xxx.visiov4.views
{
   import flash.display.DisplayObject;
   import flash.display.Loader;
   import flash.display.LoaderInfo;
   import flash.display.MovieClip;
   import flash.display.StageAlign;
   import flash.display.StageScaleMode;
   import flash.errors.IOError;
   import flash.events.Event;
   import flash.events.IOErrorEvent;
   import flash.events.MouseEvent;
   import flash.events.ProgressEvent;
   import flash.external.ExternalInterface;
   import flash.net.URLRequest;
   import flash.system.ApplicationDomain;
   import flash.system.LoaderContext;
   import flash.system.Security;
   import flash.system.SecurityDomain;
   import flash.text.TextField;
   import flash.text.TextFieldAutoSize;
   
   import fl.controls.Button;
   
   import ispring.presenter.IPresentationPlayer;
   import ispring.presenter.IPresentationPlayerContainer;
   import ispring.presenter.PlayerContainerEvent;
   import ispring.presenter.player.IPresentationPlaybackController;
   import ispring.presenter.player.clock.IPresentationClock;
   import ispring.presenter.player.clock.PresentationClockEvent;
   import ispring.presenter.player.events.PresentationPlaybackEvent;
   import ispring.presenter.player.events.PresentationStartupEvent;
   import ispring.presenter.presentation.ITimestamp;
   import ispring.presenter.presentation.slides.ISlides;
   
   public class Ispring extends MovieClip
   {
      private static const BUTTONS_BOTTOM_MARGIN:Number = 50;
      private static const CONTENT_PADDINGS:Number = 20;
      
      private var m_playButton:Button;
      private var m_nextSlideButton:Button;
      private var m_prevSlideButton:Button;
      private var m_nextStepButton:Button;
      private var m_prevStepButton:Button;
      
      private var m_slideLabel:TextField;
      private var m_timeLabel:TextField;
      
      private var m_playerContainer:IPresentationPlayerContainer;
      private var m_player:IPresentationPlayer;
      private var m_playbackController:IPresentationPlaybackController;
      private var m_clock:IPresentationClock;
      private var m_slides:ISlides;
      
      private var loader:Loader;
      private var _file:String;
      private var context:LoaderContext;
      private var sWidth:int;
      private var sHeight:int;
      private var _sWidth:int;
      private var _sHeight:int;
      private var sPos:int;   
      private var _sPos:int;   
      private var m_width:int;
      private var m_height:int;
      private var _isAdmin:String;
      private var _baseURL:String;
      private var _currentStep:String;
      
      public function Ispring(file:String, sWidth:int, sHeight:int, sPos:int, isAdmin:String, baseURL:String)
      {
         trace("newISpring: "+file+sWidth+"/"+sHeight+"/"+sPos);
         this.addEventListener(Event.ADDED_TO_STAGE,startapp);
         Security.allowDomain("*");
         _file = file;
         sWidth = sWidth;
         sHeight = sHeight;
         _sWidth = sWidth;
         _sHeight = sHeight;
         sPos = sPos;
         _sPos = sPos;
         _isAdmin = isAdmin;
         //_baseURL = baseURL;
         _baseURL = "http://www.xxx.com";
         loader = new Loader();
         //_currentStep = timeStamp;
         
         /*
         To be able to communicate with iSpring Pro generated presentation it must be
         loaded into the application domain derived from the current application domain.
         
         It is also possible to load the presentation into the application domain of the
         current SWF file, however it is not recommended because it may cause class definition
         conflicts when loading multiple iSpring presentations within one application
         */
         var appDomain:ApplicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
         context = new LoaderContext(false, appDomain);
         context.securityDomain = SecurityDomain.currentDomain;
         loader.contentLoaderInfo.addEventListener(Event.INIT, onMovieLoaded);
         loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
         loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
      }
      
      private function startapp(e:Event):void  {
         trace("ispring has been added");
         loader.load(new URLRequest(_baseURL+"/librairy/"+_file), context);
      }
      
      public function loadSlide(file:String):void  {
         trace("ispring slide has been loaded");
         loader.load(new URLRequest(_baseURL+"/librairy/"+file), context);
      }
      
      public function unloadSlide():void  {
         loader.unload();
         loader.close();
      }
      
      private function onError(e:IOErrorEvent):void  {
         trace("error ispring: "+e.errorID);
      }
      private function onStageResize(e:Event):void
      {
         //updateLayout();
         if(m_player!=null)  {
            m_player.skin.window.resize(stage.stageWidth, stage.stageHeight);
         }
      }
      
      private function onMovieLoaded(e:Event):void
      {
         trace("ISpring movie Loaded"+e.target);
         var contentInfo:LoaderInfo = LoaderInfo(e.target);
         var content:DisplayObject = contentInfo.content;
         trace("content X: "+content.x);
         // Query IPresentationPlayerContainer interface of the loaded SWF file
         m_playerContainer = content as IPresentationPlayerContainer;
         if (m_playerContainer == null)
         {
            // The loaded file is not an iSpring presentation
            throw new Error("The loaded SWF file is not a presentation created with iSpring Pro");
         }
         
         // Wait for the player to initilize
         m_playerContainer.addEventListener(PlayerContainerEvent.PLAYER_IS_AVAILABLE, onPlayerAvailable);
         
         content.x = 0;
         content.y = 0;
         // Add the presentation to stage
         trace("adding ISpring child");
         addChild(content);
      }
      
      private function onPlayerAvailable(e:PlayerContainerEvent):void
      {
         // Store the player and the playback controller references
         m_player = m_playerContainer.player;
         m_playbackController = m_player.presentationView.playbackController;
         // Listen to the slide change event
         m_playbackController.addEventListener(PresentationPlaybackEvent.SLIDE_CHANGE, onSlideChanged);
         //m_playbackController.addEventListener(PresentationStartupEvent.PRESENTATION_STARTUP,showStartUp);
         m_slides = m_player.presentation.slides;
         m_width = m_player.presentation.slideWidth;
         m_height = m_player.presentation.slideHeight;
         trace("presentation dimensions: "+m_width+"/"+m_height);
         trace("stage dimensions: "+_sWidth+"/"+_sHeight);
         // Store the presentation clock reference and listen to its events
         m_clock = m_player.presentationView.playbackController.clock;
         m_clock.addEventListener(PresentationClockEvent.TICK, onClockTick);
         m_clock.addEventListener(PresentationClockEvent.STATE_CHANGED, onClockStateChanged);
         
         // Build the UI
         if(_isAdmin=="ok")  {
            //buildUI();
         }
         
         m_player.skin.window.maximized = false;
         m_player.skin.window.resize(stage.stageWidth, stage.stageHeight);
         
         /*var initTimeStamp:String = (parent as MovieClip).getTimeStamp();
         gotoTimeStamp(initTimeStamp);*/
         ExternalInterface.call("getTimeStamp");
      }
      
      private function showStartUp(e:PresentationStartupEvent):void  {
         //e.startup.autoStart = false;
      }
      
      private function onClockStateChanged(e:PresentationClockEvent):void
      {

      }
      
      private function convertTimeToString(time:Number):String
      {
         const minutes:uint = Math.floor(time / 60);
         time -= minutes * 60;
         
         var timeStr:String = time.toFixed(1);
         var secondsStr:String =
            (time < 10) ? "0" + timeStr
            : timeStr;
         
         return minutes.toString() + ":" + secondsStr;
      }
      
      private function onClockTick(e:PresentationClockEvent):void
      {
         // Retrieve the presentation timings and update the time label
         const duration:Number = m_slides.duration;
         const currentTimestamp:ITimestamp = m_player.presentationView.playbackController.clock.timestamp;
         const current:Number = m_slides.convertTimestampToTime(currentTimestamp);
      }
      
      private function onSlideChanged(e:PresentationPlaybackEvent):void
      {
         // Update the current slide label text
         const currentIndex:uint = m_playbackController.currentSlideIndex + 1;
         const count:uint = m_slides.count;
         var timestamp:ITimestamp = m_player.presentationView.playbackController.clock.timestamp;
         
         trace("current Slide"+currentIndex);
         trace("current Slide count"+count);
         trace("curent timeStamp"+timestamp);
         trace("current TimeStampIndex:"+timestamp.stepIndex);
         trace("current TimeSslideIndex:"+timestamp.slideIndex);
         trace("current TimeTimeIndex:"+timestamp.timeOffset);
      }
      
      public function updateLayout():void
      {
         if(m_player!=null)  {
            m_player.skin.window.resize(stage.stageWidth, stage.stageHeight);
         }
      }
      
      private function buildUI():void
      {
         trace("building UI");
         trace("this X: "+this.x);
         trace("loader X: "+loader.x);
         const buttonsGap:Number = 10;
         
         m_prevSlideButton = new Button();
         m_prevSlideButton.x = 0;
         //addChild(m_prevSlideButton);
         
         m_nextSlideButton = new Button();
         m_nextSlideButton.x = m_prevSlideButton.x + m_prevSlideButton.width + buttonsGap;
         //addChild(m_nextSlideButton);
         
         m_prevStepButton = new Button();
         m_prevStepButton.x = m_nextSlideButton.x + m_nextSlideButton.width + buttonsGap;
         //addChild(m_prevStepButton);
         
         m_nextStepButton = new Button();
         m_nextStepButton.x = m_prevStepButton.x + m_prevStepButton.width + buttonsGap;
         //addChild(m_nextStepButton);
         
         m_slideLabel = new TextField();
         m_slideLabel.autoSize = TextFieldAutoSize.LEFT;
         m_slideLabel.x = m_nextStepButton.x + m_nextStepButton.width + buttonsGap;
         //addChild(m_slideLabel);
         
      }
      
      public function onNextClick(e:MouseEvent):void
      {
         m_playbackController.gotoNextSlide();
      }
      
      public function onPrevClick(e:MouseEvent):void
      {
         m_playbackController.gotoPreviousSlide();
      }
      
      public function onNextStep(e:MouseEvent):void
      {
         m_playbackController.gotoNextStep();
      }
      
      public function onPrevStep(e:MouseEvent):void
      {
         m_playbackController.gotoPreviousStep();
      }
      
      public function onNextStep2(isSender:String):void
      {
         m_playbackController.gotoNextStep();
         var timestamp:ITimestamp = m_player.presentationView.playbackController.clock.timestamp;
         if(isSender=="ok")  {
            (parent as MovieClip).setTimeStamp(timestamp.slideIndex+"^"+timestamp.stepIndex+"^"+timestamp.timeOffset);
         }
         trace("next Slide index: "+m_player.presentationView.playbackController.nextSlideIndex);
         trace("curent timeStamp"+timestamp);
         trace("current TimeStampIndex:"+timestamp.stepIndex);
         trace("current TimeSslideIndex:"+timestamp.slideIndex);
         trace("current TimeTimeIndex:"+timestamp.timeOffset);
      }
      
      public function onPrevStep2(isSender:String):void
      {
         m_playbackController.gotoPreviousStep();
         var timestamp:ITimestamp = m_player.presentationView.playbackController.clock.timestamp;
         if(isSender=="ok")  {
            (parent as MovieClip).setTimeStamp(timestamp.slideIndex+"^"+timestamp.stepIndex+"^"+timestamp.timeOffset);
         }
         trace("previous Slide index: "+m_player.presentationView.playbackController.previousSlideIndex);
         trace("curent timeStamp"+timestamp);
         trace("current TimeStampIndex:"+timestamp.stepIndex);
         trace("current TimeSslideIndex:"+timestamp.slideIndex);
         trace("current TimeTimeIndex:"+timestamp.timeOffset);
      }
      
      public function gotoSlide(slideNumber:int):void
      {
         m_playbackController.gotoSlide(slideNumber,true);
         
      }
      
      public function gotoTimeStamp(timestamp:String):void
      {
         trace("gotoTimeStamp: "+timestamp);
         if(timestamp!=null)  {
            var theStamp:Array = timestamp.split("^");
            if(m_playbackController)  {
               trace("controller avaialble");
               try  {
                  m_playbackController.gotoTimestamp(theStamp[0], theStamp[1], theStamp[2], true);
               } catch(e:Error)  {
                  throw new Error("out of bound");
               }
            }  else  {
               trace("controller unavaialble");
            }
         }
      }
      
      public function get getTimeStamp():String  {
         
         var timestamp:ITimestamp = m_player.presentationView.playbackController.clock.timestamp;
         var timeStampInfos:String = timestamp.slideIndex+"^"+timestamp.stepIndex+"^"+timestamp.timeOffset;
         trace("get stamp ISPRING"+timeStampInfos);
         return timeStampInfos;
      }
      
      public function onPlayClick(e:MouseEvent):void
      {
         if (m_clock.started)
         {
            m_playbackController.pause();
         }
         else
         {
            m_playbackController.play();
         }
      }
      
      private function onProgressHandler(mProgress:ProgressEvent):void
      {
         var percent2:Number = (mProgress.target.bytesLoaded / mProgress.target.bytesTotal)*100;
         (parent as MovieClip).setProgress(percent2);
      }
   }
}


Profile profile test
Display posts from previous:  Sort by  

  


Who is online
Who is online In total there are 7 users online :: 1 registered, 0 hidden and 6 guests (based on users active over the past 5 minutes)
Most users ever online was 108 on Thu Nov 21, 2013 3:41 pm

Registered users: Bing [Bot]