11 Replies Latest reply on Aug 24, 2009 7:18 AM by kglad

    Dynamically load images?

    jayNarh

      I'm quite new to the world of flash so bare with me. I've been playing around with a demo version of a PHP Flv streaming player from rich media project. I've been able to setup my player to play flv videos dynamically by passing an id from the database to the swf file (works great).

       

      However I cannot for the life of me work out how images are loaded dynamically. The player uses the filename and adds .jpg as the extension to load the image file when the player starts. Problem is my image name will be different to the file and so I need to pass a variable in the same way I am passing a variable for the movie name.

       

      Can anyone explain how images are loaded dynamically? I have looked at the action script for the layers and this is all there is. Can't see anything to do with images.

       

       

       

      // skinID=1
      // Instance names and linkage identifiers were set with '_1' extension
      //
      myPlayer.skinID=1;
      myPlayer.skinPlayer=true;

      var passed:String = video;
      myPlayer.movieName = video;
      // Init isFullScreen and zoom var
      isFullScreen=false;
      zoom=1;

      // Set scaleMode to noScale and align top left
      Stage.align = "TL";
      Stage.scaleMode = "noScale";

      // fullscreen function. This function is called by the fullscreen button.
      fullFunction = function () {
      // Test if the player is playing or not.
      if (!myPlayer.initMovie && myPlayer.meta && !isFullScreen) {
        Stage["displayState"] = "fullScreen";
      } else if (!myPlayer.initMovie && myPlayer.meta && isFullScreen) {
        Stage["displayState"] = "normal";
      }
      }


      // Call fullFunction when user double clicks on the screen
      myPlayer.doubleClickFull=function(){
      fullFunction();
      }

      // changeZoom function. This function is called by the changeZoom button
      changeZoom=function(){
      if(zoom==1){
      myPlayer.changeZoom(0.75);
      zoom=0.75;
      }
        else {
      myPlayer.changeZoom(1);
      zoom=1;
      }
      }


      Eventlistener = new Object();
      Eventlistener.onFullScreen = function(bFull:Boolean) {
      if (bFull) {
        isFullScreen = true;
        // Set pictureKeepAspectRatio to true to keep picture ratio in fullscreen mode
        fullWidth = Stage.width;
        fullHeight = Stage.height;
        ratio = myPlayer.movieInfoWidth/myPlayer.movieInfoHeight;
       
        // Keep in memory size and location
        memPlayerWidth=myPlayer.playerWidth;
        memPlayerHeight=myPlayer.playerHeight;
        memPlayerX=myPlayer._x;
        memPlayerY=myPlayer._y;
       
        // Keep in memory screenBorder, controlsY, autoSize and smoothing values;
        memPictureKeepAspectRatio=myPlayer.pictureKeepAspectRatio;
        memScreenBorder=myPlayer.screenBorder;
        memControlsY=myPlayer.controlsY;
        memAutoSize=myPlayer.autoSize;
        memSmoothing=myPlayer.smoothing;
       
        // Set smoothing to false not to increase CPU usage
        myPlayer.smoothing=false;
        myPlayer.pictureKeepAspectRatio=true;
        myPlayer.screenBorder = false;
        myPlayer.controlsY = -myPlayer.controlsHeight;
        myPlayer.autoSize = "Movie";
       
        myPlayer.playerWidth = fullWidth;
        myPlayer.playerHeight = fullHeight+myPlayer.controlsHeight;
       
        // Call changeProp method
        myPlayer.changeProp(0,0);
       
        // Set zoom to 1
        zoom=1;
       
        // Antibug function (RollOver cannot be detected for 2 seconds when the player goes fullscreen)
        // Hide Controls
        myPlayer.hideControls();
        intervalShow=setInterval(showControls,2000);
       
       
        } else {
        isFullScreen = false;
        // Remind normal values
        myPlayer.playerWidth = memPlayerWidth;
        myPlayer.playerHeight = memPlayerHeight;
       
        myPlayer.smoothing=memSmoothing;
        myPlayer.pictureKeepAspectRatio=memPictureKeepAspectRatio;
        myPlayer.screenBorder=memScreenBorder;
        myPlayer.controlsY=memControlsY;
        myPlayer.autoSize=memAutoSize;
       
        //Show controls
        clearInterval(intervalShow);
        myPlayer.controls="Show";
       
        // Call changeProp method
        myPlayer.changeProp(memPlayerX,memPlayerY);
       
        // Set zoom to 1
        zoom=1;
        }
      };
      Stage.addListener(Eventlistener);


      showControls=function(){
      myPlayer.showControls();
      clearInterval(intervalShow);
      }

       

       

       

      Part of my html code to call swf using php:

       

      <?php print "<param name=\"movie\" value=\"clickvideo?video=video".$id." /> <param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"#222222\" /> <embed src=\"clickvideo?video=video".$id." quality=\"high\" bgcolor=\"#222222\" width=\"512\" height=\"384\" name=\"clickvideo\" align=\"middle\" allowScriptAccess=\"sameDomain\" allowFullScreen=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"/> " ?>

       

       

      Thank you