Lionpathback to Home
HAXE

InfoSlide.hx

InfoSlide.hx is a sample source code for an info slide show written in Haxe. The sample shows up informative slides which could be configured by parameters: each slide is associated with a link which will be invoked if the slide is being clicked.

The sample application has been taken from a german site http://PatientenWieIch.de, the site is a patient online forum.

Copyright/ Disclaimer

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see .

    Copyright (C) 2007 by Siegmund Gorr

Pictures are taken from pixelio.de.

Table of contents

Sample Application using InfoSlide

Parameter Description

Parameter Name Description
pn Number of slides
pi0 Picture URL for image 0
pl0 Link URL for image 0
pi1 Picture URL for image 1
pl1 Link URL for image 1

Use as many slides as you want.

Sample HTML-File

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Sample Application of InfoSlide</title>
<script src="AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<body>

<script src="AC_RunActiveContent.js" type="text/javascript"></script>
<script type="text/javascript">// <![CDATA[
AC_FL_RunContent('codebase',
'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,65,0',
'loop','true','bgcolor','#ffffff','width','586','height','160','src','Movie_02','FlashVars',
'pn=3&pi0=Show2/apfel_01.jpg&pl0=http://patientenwieich.de/c/detail2'
+'&pi1=Show2/wolke_01.jpg&pl1=http://patientenwieich.de/c/detail3'
+'&pi2=Show2/hund_01.jpg&pl2=http://patientenwieich.de/c/detail4',
'quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','infoslide');
// ]]>
</script><noscript><div><object id="Movie_02" width="586" height="160" 
type="application/x-shockwave-flash"
data="infoslide.swf?pn=3&amp;pi0=Show2/apfel_01.jpg&amp;pl0=http://patientenwieich.de/c/detail2
&amp;pi1=Show2/wolke_01.jpg&amp;pl1=http://patientenwieich.de/c/detail3&amp;
pi2=Show2/hund_01.jpg&amp;pl2=http://patientenwieich.de/c/detail4" >
<param name="movie" value="infoslide.swf?pn=3&amp;
pi0=Show2/apfel_01.jpg&amp;pl0=http://patientenwieich.de/c/detail2
&amp;pi1=Show2/wolke_01.jpg&amp;pl1=http://patientenwieich.de/c/detail3
&amp;pi2=Show2/hund_01.jpg&amp;pl2=http://patientenwieich.de/c/detail4" 
/>
<param name="quality" value="high" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="bgcolor" value="#ffffff" />
An dieser Stelle wird ein Flash-Film abgespielt, der die wesentlichen Funktionen erklärt.
</object></div></noscript>

</body>
</html>

Source Code for InfoSlide.hx

import flash.MovieClip;

class InfoSlide {
    static var mc : MovieClip;
    static var slides : Array<MovieClip>;
    static var links : Array<String>;
    static var ind : Int;
    static var picbtn : MovieClip;
    static var circle: MovieClip;
    static var hours: Array<MovieClip>;

    function new (){
    }
    
    static function main() {
        var j = 0;
        mc = flash.Lib.current;
        var app:InfoSlide = new InfoSlide();
        cnt=0;
        slides = new Array<MovieClip>();
        links = new Array<String>();
        for(j in 0...mc.pn){
          var tmc = mc.createEmptyMovieClip("sl_"+j,mc.getNextHighestDepth());
          var url : String = flash.Lib.eval("pi"+j);
          var lnk : String = flash.Lib.eval("pl"+j);
          tmc.loadMovie(url);
          if(j>0){
            tmc._alpha = 0;
          }
          slides.push(tmc);
          links.push(lnk);
        }
        // prepare all hour glas entries in advance
        hours = new Array<MovieClip>();
        for(j in 0...30+1){
          var tmc = mc.createEmptyMovieClip("hg_"+j,mc.getNextHighestDepth());
          drawCircle(tmc, flash.Stage.width-20, 20, 10);
          drawArc(tmc, flash.Stage.width-20,20,10,j);
          tmc._alpha = 0;
          hours.push(tmc);
        }

        picbtn = mc.createEmptyMovieClip("picbtn",mc.getNextHighestDepth());
        picbtn.beginFill(0xE5E5E5,100);
        picbtn.moveTo(0,0);
        picbtn.lineTo(flash.Stage.width,0);
        picbtn.lineTo(flash.Stage.width,flash.Stage.height);
        picbtn.lineTo(0,flash.Stage.height);
        picbtn.endFill();
        picbtn._alpha = 0;
        picbtn.onPress = InfoSlide.onPress;
        
        ind = 0;
        cnt=0;
        lastHour = 0;
        hours[0]._alpha = 100;

        mc.onEnterFrame = InfoSlide.frame;
        flash.Mouse.addListener(app);
    }
    
    static var cnt : Int;
    static var lastHour : Int;
    
    /* 0-limit anzeige, limit-limit2 bergang von alt zu neu
       l1 frames in daueranzeige
       l2 frames im wechsel
    */
    static function frame(){
      var l1 : Int = 80; 
      var l2 : Int = 15;
      var l : Int = l1+l2;
      cnt=cnt+1;
      
      var hour : Int;
      hour = Math.round(cnt/l1*30);
      if(lastHour!=hour){
        hours[hour]._alpha = 100;
        hours[lastHour]._alpha = 0;
        lastHour = hour;
      }
      if(cnt>=l1){
        if(cnt<l){
          var p : Float = ((cnt-l1)/l2)*100;
          // ALPHA 0=transparent-100=opaque
          slides[ind]._alpha = 100-p;
          var newInd : Int = (ind+1)%slides.length;
          slides[newInd]._alpha = p;
        }else{
          cnt=0;
          slides[ind]._alpha = 0;
          ind = (ind+1)%slides.length;
          slides[ind]._alpha = 100;
        }
      }
    }
    
    static function onRelease(){
      trace("REL "+links[ind]);
    }
    
    static function onPress(){
      flash.Lib.getURL(links[ind],"_self");
    }

    function onMouseDown(){
    }
    
    static function drawCircle(mc:MovieClip, x:Float, y:Float, r:Float) {
      mc.beginFill(0xE5E5E5,100);
      mc.moveTo(x+r, y);
      mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, Math.sin(Math.PI/4)*r+x,
      Math.sin(Math.PI/4)*r+y);
      mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, x, r+y);
      mc.curveTo(-Math.tan(Math.PI/8)*r+x, r+y, -Math.sin(Math.PI/4)*r+x,
      Math.sin(Math.PI/4)*r+y);
      mc.curveTo(-r+x, Math.tan(Math.PI/8)*r+y, -r+x, y);
      mc.curveTo(-r+x, -Math.tan(Math.PI/8)*r+y, -Math.sin(Math.PI/4)*r+x,
      -Math.sin(Math.PI/4)*r+y);
      mc.curveTo(-Math.tan(Math.PI/8)*r+x, -r+y, x, -r+y);
      mc.curveTo(Math.tan(Math.PI/8)*r+x, -r+y, Math.sin(Math.PI/4)*r+x,-Math.sin(Math.PI/4)*r+y);
      mc.curveTo(r+x, -Math.tan(Math.PI/8)*r+y, r+x, y);
      mc.endFill();
    }
    /* draw an filled arc with center at x,y and radius r, clockwise with 0<=hour<=12
    */
    static function drawArc(mc:MovieClip, x:Float, y:Float, r:Float, hour:Int) {
      mc.beginFill(0xC0C0C0,100);
      var i:Int;
      var alpha : Float;
      var beta : Float;
      var delta: Float;
      var maxVal:Int = 12;
      maxVal = 30;
      i=0;
      alpha = Math.PI;
      delta = Math.PI/6;
      delta = Math.PI*2/maxVal;
      mc.moveTo(x,y);
      mc.lineTo(x+Math.sin(alpha)*r,y+Math.cos(alpha)*r);
      if(hour<0){
        hour=0;
      }else if(hour>maxVal){
        hour=maxVal;
      }
      while(i<hour){
        beta = alpha - delta/2;
        alpha = alpha - delta;
        mc.curveTo(
          x+Math.sin(beta)*r,y+Math.cos(beta)*r,
          x+Math.sin(alpha)*r,y+Math.cos(alpha)*r);
        i++;
      }
      mc.lineTo(x,y);
      mc.endFill();
    }
}

Compile Instructions for Haxe

haxe -swf-version 8 -swf-header 586:160:18:FF0000 -swf infoslide.swf -main InfoSlide
		

Feedback/ Comments

Your feedback is very welcome and appreciated.
For the ease of simplicity I did not add an feedback form, so please just drop me a mail.
Please send it to haxe@lionpath.com.