This tutorial will go over how to create a dynamic Flash slide show in WordPress using Peak Studios Flash Php MySQL extension.
You can follow along on the video or simply follow the steps below. You will see (sv:some time) at the start each section. This lets you know where to cue the video tutorial to if you want to learn more about the function.
Set up your Flash file | (sv:0:25)
Set up slide show in WordPress | (sv:7:45)
Create slideshowtostage.as | (sv:3:05)
package{
import flash.display.MovieClip;
public class slideshowtostage extends MovieClip{
private var ss:MovieClip = new slideshow_mc();
public function slideshowtostage(){
//add your stuff to the stage.
ss.cacheAsBitmap = true;
addChild(ss);
}
}
}
Create slideshow.as | (sv:4:50)
package{
import flash.display.MovieClip;
import flash.net.URLVariables;
import flash.utils.Timer;
import flash.events.*;
import fl.transitions.*;
import fl.transitions.easing.*;
//custom classes
import FP9.flash.com.ps.php.as3.*;
import MyLoader;
public class slideshow extends MovieClip{
private var DB_loc:String;
private var slideshow_select:SelectDB;
private var pics:Array;
private var slideshowPlaying:Boolean;
private var t:Timer;
public var pics_count:int;
public var pics_length:int;
public var showingChild:int;
public var displayArray:Array = new Array();
public function slideshow(){
//set your db loc
DB_loc = "";
slideshowselect();
}
//-------------Flash PHP MySQL-------------
private function slideshowselect():void{
var slideshow_table = "wp_postmeta";
//--Array should be the table row names you wish to pull from
var slideshow_tableRow:Array = new Array();
slideshow_tableRow[0] = "meta_value";
//where to look
var slideshow_where:Array = new Array();
slideshow_where[0] = "meta_key";
/*values can be = <> > < <= >= BETWEEN LIKE IN You can put TABLE (i.e =TABLE)after any of the operators to use a table field in the what array value*/
var slideshow_like:Array = new Array();
slideshow_like[0] = "=";
//What to look for
var slideshow_what:Array = new Array();
slideshow_what[0] = "home_pics";
//What to look for
var slideshow_functionStrings:Array = new Array();
slideshow_functionStrings[0] = "";
//orderBy and ASC arrays must have the same amount of items in the array.
//What to look for
var slideshow_orderBy:Array = new Array();
slideshow_orderBy[0] = "";
//What to look for
var slideshow_ASC:Array = new Array();
slideshow_ASC[0] = "";
slideshow_select = new SelectDB(slideshow_table, slideshow_tableRow, slideshow_where, slideshow_like, slideshow_what, slideshow_orderBy, slideshow_ASC, slideshow_returnFunction, slideshow_functionStrings, DB_loc);
}
private function slideshow_returnFunction(vars:URLVariables, selectRows:Array, functionStrings:Array):void{
pics = vars.meta_value0.split(",",20);
pics_length = pics.length;
if(pics_length > 0){
loadPics(pics_count);
}
}
//-------------start loading images--------------
private function loadPics(n:int):void{
var mypic:String = pics[n];
var myl:MyLoader = new MyLoader("home-slides/"+mypic, picloaded);
myl.alpha = 0;
addChild(myl);
}
private function picloaded():void{
if (pics_count == 0){
fadeIn(0);
loadTimer();
}
pics_count++;
if(pics_count
}
}
//-------------fade in-------------
private function fadeIn(n:int):void{
var myTweenAlpha:Tween = new Tween(getChildAt(n), "alpha", Strong.easeOut, 0, 1, 1, true);
if(showingChild != 0){
fadeOut(showingChild);
}
showingChild = n;
}
//-------------fade out-------------
private function fadeOut(n:int):void{
var myTweenAlpha:Tween = new Tween(getChildAt(n), "alpha", Strong.easeOut, 1, 0, 1, true);
}
//-------------timer functions-------------
private function loadTimer():void{
t = new Timer(3500);
t.addEventListener(TimerEvent.TIMER, timerComplete);
t.start();
}
private function timerComplete(e:TimerEvent):void{
if((pics_length - 1) == showingChild){
fadeIn(0);
}else{
fadeIn(showingChild + 1);
}
}
}
}
Create MyLoader.as | (sv:12:55)
package {
import flash.display.Loader;
import flash.events.ProgressEvent;
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.MovieClip;
public class MyLoader extends MovieClip {
private var ldr:Loader;
private var func:Function;
public function MyLoader(argFile:String, f:Function) {
func = f;
ldr = new Loader();
ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoadProgressEvent);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
ldr.load(new URLRequest(argFile));
addChild(ldr);
}
private function onLoadProgressEvent(e:ProgressEvent):void {
//var percent:int = Math.round((e.bytesLoaded / e.bytesTotal) * 100);
}
private function loaded(e:Event):void{
e.target.removeEventListener(ProgressEvent.PROGRESS, onLoadProgressEvent);
e.target.removeEventListener(Event.COMPLETE, loaded);
func();
}
}
}
You must be logged in to post a comment.
Copyright © 2012 Peak Studios All rights reserved |
Become a fan