bombdigiti
April 26th, 2008, 07:06 PM
hey, i was wondering if anyone would be able to give me a hand converting some as2 to as3. Its kind of a media content management system and we've basically only learned as2 at school, so i am having a lot of trouble. If anyone could help or just say some pointers that would be awesome, thanks. Yea, its super sloppy...
Heres the code:
ActionScript Code:
//importing
import flash.events.*;
import flash.net.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
//setting variables
var played = 0;
var imagecount = 1;
var caniplay = 0;
var canishowthesongs = 0;
var canishowthevids = 0;
var vidplaying = 0;
var titletext = "";
var infotext = "";
var mytext:Loader = new Loader();
var url:String = "http://localhost/media_gallery/loadinfo.php";
var urlReq:URLRequest = new URLRequest(url);
mytext.load(urlReq);
mytext.onLoad = function(success) {
if (success) {
var imagearray = mytext.images.split("|");
var galleryinfoarray = mytext.galleryinfo.split("|");
var gallerytitlearray = mytext.gallerytitles.split("|");
var galleryarray = mytext.galleryimages.split("|");
var numimages = imagearray.length;
var audioarray = mytext.audio.split("|");
var audionamearray = mytext.audioname.split("|");
var audioartistarray = mytext.audioartist.split("|");
var videoarray = mytext.videos.split("|");
var videonamearray = mytext.videoname.split("|");
var videoinfoarray = mytext.videoinfo.split("|");
var mysound = new Sound();
mysound.loadSound(root.audioarray[0],true);
mysound.stop();
volumelevel = 100;
}
};
function moveSlider(xpos:Number, sliderwidth:Number) {
var xPosT:Tween = new Tween(slider, "x", Regular.easeOut, slider.x, xpos, 2, true);
var wPosT:Tween = new Tween(slider, "width", Regular.easeOut, slider.width, sliderwidth, 2, true);
}
photoSelectAnimation.addEventListener(TweenEvent.M OTION_FINISH, onMotionFinished);
function photoSelectAnimation(objalph:Number, xpos:Number, textInfo:String) {
removeTracks();
titletext = "";
infotext = "";
var slideDown:Tween = new Tween(slider2, "scaleY", Regular.easeOut, slider2.scaleY, 105, 2, true);
var slideAlpha:Tween = new Tween(slider2, "alpha", Regular.easeOut, slider2.alpha, 15, 2, true);
function onMotionFinished(event:TweenEvent):void {
var aPosT1:Tween = new Tween(photoselect, "alpha", Regular.easeIn, photoselect.alpha, objalph, 2, true);
var aPosT2:Tween = new Tween(photoinfo, "alpha", Regular.easeIn, photoinfo.alpha, objalph, 2, true);
var aPosT3:Tween = new Tween(picture, "alpha", Regular.easeIn, picture.alpha, objalph, 2, true);
if (caniplay == 0) {
loadImages();
}
};
}
videoSelectAnimation.addEventListener(TweenEvent.M OTION_FINISH, onMotionFinished);
function videoSelectAnimation(objalph:Number, xpos:Number, textInfo:String) {
var slideDown:Tween = new Tween(slider2, "scaleY", Regular.easeOut, slider2.scaleY, 105, 2, true);
var slideAlpha:Tween = new Tween(slider2, "alpha", Regular.easeOut, slider2.alpha, 20, 2, true);
function onMotionFinished(event:TweenEvent):void {
var aPosT1:Tween = new Tween(videoselect, "alpha", Regular.easeIn, videoselect.alpha, objalph, 2, true);
var aPosT2:Tween = new Tween(photoinfo, "alpha", Regular.easeIn, photoinfo.alpha, objalph, 2, true);
var aPosT3:Tween = new Tween(video, "alpha", Regular.easeIn, video.alpha, objalph, 2, true);
var aPosT4:Tween = new Tween(stopvid, "alpha", Regular.easeIn, 0, 100, 2, true);
var aPosT5:Tween = new Tween(playvid, "alpha", Regular.easeIn, 0, 100, 2, true);
var aPosT6:Tween = new Tween(pausevid, "alpha", Regular.easeIn, 0, 100, 2, true);
if (canishowthevids == 0) {
vidplayer.visible = true;
vidplayer.contentPath = videoarray[0];
titletext = videonamearray[0];
infotext = videoinfoarray[0];
loadVideos();
vidplayer.stopButton = stopvid;
vidplayer.playButton = playvid;
vidplayer.pauseButton = pausevid;
playvid.y = 261;
pausevid.y = 261;
stopvid.y = 261;
}
};
}
audioSelectAnimation.addEventListener(TweenEvent.M OTION_FINISH, onMotionFinished);
function audioSelectAnimation(objalph:Number, xpos:Number, textInfo:String) {
removeThumbs();
//root.titletext = "";
//root.infotext = "";
var slideDown:Tween = new Tween(slider2, "yscale", Regular.easeOut, slider2.scaleY, 105, 2, true);
var slideAlpha:Tween = new Tween(slider2, "alpha", Regular.easeOut, slider2.alpha, 20, 2, true);
function onMotionFinished(event:TweenEvent):void {
var aPosT1:Tween = new Tween(audioselect, "alpha", Regular.easeIn, audioselect.alpha, objalph, 2, true);
var aPosT3:Tween = new Tween(photoinfo, "alpha", Regular.easeIn, photoinfo.alpha, objalph, 2, true);
var aPosT:Tween = new Tween(audio, "alpha", Regular.easeIn, audio.alpha, objalph, 2, true);
if (canishowthesongs == 0) {
currenttrack = audionamearray[0];
currentartist = audioartistarray[0];
loadTracks();
}
};
}
function loadImages() {
var starty = 60;
var startx = 27;
numthumbs = galleryarray.length;
for (i=0; i<numthumbs; i++) {
var count = i+1;
if (count == 4 || count == 7) {
starty += 67;
startx = 27;
}
flash.display.MovieClip.MovieClip("holder", "thumb"+count, count);
loadMovie(galleryarray[i], "thumb"+count);
eval("thumb"+count).y = starty;
eval("thumb"+count).x = startx;
var aPosT:Tween = new Tween(eval("thumb"+count), "alpha", Regular.easeOut, 0, 100, 1, true);
startx += 65;
}
}
function setText(num) {
titletext = gallerytitlearray[num];
infotext = galleryinfoarray[num];
}
function removeThumbs() {
for (i=1; i<9; i++) {
removeChild("thumb"+i);
}
}
function loadTracks() {
starty = 130;
startx = 170;
numtracks = audioarray.length-1;
for (i=0; i<numtracks; i++) {
count = i+1;
if (count == 5) {
starty += 85;
startx = 10;
}
flash.display.MovieClip.MovieClip("trackholder", "track"+count, count);
eval("track"+count).trackholder = audionamearray[i]+" | "+audioartistarray[i];
eval("track"+count).y = starty;
eval("track"+count).x = startx;
starty += 15
}
}
videobtn.buttonMode = true;
videobtn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverVideo);
function mouseOverVideo(event:MouseEvent):void {
trace("videobtnselected");
moveSlider(12,36);
}
photobtn.buttonMode = true;
photobtn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverPhoto);
function mouseOverPhoto(event:MouseEvent):void {
trace("photobtnselected");
moveSlider(61,40);
}
audiobtn.buttonMode = true;
audiobtn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverAudio);
function mouseOverAudio(event:MouseEvent):void {
trace("audiobtnselected");
moveSlider(116,38);
}
videobtn.onPress = function() {
removeThumbs();
sectiontitle = "Videos";
caniplay = 1;
canishowthesongs = 1;
canishowthevids = 0;
slider2.scaleY = 15;
slider2.alpha = 0;
videoSelectAnimation(100,524);
photoSelectAnimation(0,125);
audioSelectAnimation(0,326);
};
photobtn.onPress = function() {
if (vidplayer.bytesTotal>-1) {
removeVids();
}
playvid._y = 400;
pausevid._y = 400;
stopvid._y = 400;
removeThumbs();
sectiontitle = "Photos";
caniplay = 0;
canishowthesongs = 1;
canishowthevids = 1;
slider2.scaleY = 15;
slider2.alpha = 0;
videoSelectAnimation(0,524);
photoSelectAnimation(100,125);
audioSelectAnimation(0,326);
};
audiobtn.onPress = function() {
if (root.mysound.position == 0) {
root.mysound.start();
}
if (vidplayer.bytesTotal>-1) {
removeVids();
}
playvid.y = 400;
pausevid.y = 400;
stopvid.y = 400;
sectiontitle = "Audio";
canishowthesongs = 0;
canishowthevids = 1;
caniplay = 1;
slider2.scaleY = 15;
slider2.alpha = 0;
videoSelectAnimation(0,524);
photoSelectAnimation(0,125);
audioSelectAnimation(100,326);
};
stopsound.onPress = function() {
mysound.stop();
thispoint = 0;
};
playsound.onPress = function() {
mysound.start(thispoint);
};
pausesound.onPress = function() {
thispoint = mysound.position/1000;
mysound.stop();
};
function removeTracks() {
thismany = audioarray.length;
for (i=1; i<thismany; i++) {
removeChild("track"+i);
}
}
function loadVideos() {
starty = 130;
startx = 130;
numvids = videoarray.length-1;
for (i=0; i<numvids; i++) {
count = i+1;
if (count == 4) {
starty += 85;
startx = 10;
}
flash.display.MovieClip.MovieClip("vidholder", "vid"+count, count);
eval("vid"+count).vidtext = root.videonamearray[i];
eval("vid"+count).y = starty;
eval("vid"+count).x = startx;
starty += 15;
}
}
function removeVids() {
thismany = videoarray.length;
vidplayer.visible = false;
vidplayer.stop();
for (i=1; i<thismany; i++) {
removeChild("vid"+i);
}
}
Heres the code:
ActionScript Code:
//importing
import flash.events.*;
import flash.net.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
//setting variables
var played = 0;
var imagecount = 1;
var caniplay = 0;
var canishowthesongs = 0;
var canishowthevids = 0;
var vidplaying = 0;
var titletext = "";
var infotext = "";
var mytext:Loader = new Loader();
var url:String = "http://localhost/media_gallery/loadinfo.php";
var urlReq:URLRequest = new URLRequest(url);
mytext.load(urlReq);
mytext.onLoad = function(success) {
if (success) {
var imagearray = mytext.images.split("|");
var galleryinfoarray = mytext.galleryinfo.split("|");
var gallerytitlearray = mytext.gallerytitles.split("|");
var galleryarray = mytext.galleryimages.split("|");
var numimages = imagearray.length;
var audioarray = mytext.audio.split("|");
var audionamearray = mytext.audioname.split("|");
var audioartistarray = mytext.audioartist.split("|");
var videoarray = mytext.videos.split("|");
var videonamearray = mytext.videoname.split("|");
var videoinfoarray = mytext.videoinfo.split("|");
var mysound = new Sound();
mysound.loadSound(root.audioarray[0],true);
mysound.stop();
volumelevel = 100;
}
};
function moveSlider(xpos:Number, sliderwidth:Number) {
var xPosT:Tween = new Tween(slider, "x", Regular.easeOut, slider.x, xpos, 2, true);
var wPosT:Tween = new Tween(slider, "width", Regular.easeOut, slider.width, sliderwidth, 2, true);
}
photoSelectAnimation.addEventListener(TweenEvent.M OTION_FINISH, onMotionFinished);
function photoSelectAnimation(objalph:Number, xpos:Number, textInfo:String) {
removeTracks();
titletext = "";
infotext = "";
var slideDown:Tween = new Tween(slider2, "scaleY", Regular.easeOut, slider2.scaleY, 105, 2, true);
var slideAlpha:Tween = new Tween(slider2, "alpha", Regular.easeOut, slider2.alpha, 15, 2, true);
function onMotionFinished(event:TweenEvent):void {
var aPosT1:Tween = new Tween(photoselect, "alpha", Regular.easeIn, photoselect.alpha, objalph, 2, true);
var aPosT2:Tween = new Tween(photoinfo, "alpha", Regular.easeIn, photoinfo.alpha, objalph, 2, true);
var aPosT3:Tween = new Tween(picture, "alpha", Regular.easeIn, picture.alpha, objalph, 2, true);
if (caniplay == 0) {
loadImages();
}
};
}
videoSelectAnimation.addEventListener(TweenEvent.M OTION_FINISH, onMotionFinished);
function videoSelectAnimation(objalph:Number, xpos:Number, textInfo:String) {
var slideDown:Tween = new Tween(slider2, "scaleY", Regular.easeOut, slider2.scaleY, 105, 2, true);
var slideAlpha:Tween = new Tween(slider2, "alpha", Regular.easeOut, slider2.alpha, 20, 2, true);
function onMotionFinished(event:TweenEvent):void {
var aPosT1:Tween = new Tween(videoselect, "alpha", Regular.easeIn, videoselect.alpha, objalph, 2, true);
var aPosT2:Tween = new Tween(photoinfo, "alpha", Regular.easeIn, photoinfo.alpha, objalph, 2, true);
var aPosT3:Tween = new Tween(video, "alpha", Regular.easeIn, video.alpha, objalph, 2, true);
var aPosT4:Tween = new Tween(stopvid, "alpha", Regular.easeIn, 0, 100, 2, true);
var aPosT5:Tween = new Tween(playvid, "alpha", Regular.easeIn, 0, 100, 2, true);
var aPosT6:Tween = new Tween(pausevid, "alpha", Regular.easeIn, 0, 100, 2, true);
if (canishowthevids == 0) {
vidplayer.visible = true;
vidplayer.contentPath = videoarray[0];
titletext = videonamearray[0];
infotext = videoinfoarray[0];
loadVideos();
vidplayer.stopButton = stopvid;
vidplayer.playButton = playvid;
vidplayer.pauseButton = pausevid;
playvid.y = 261;
pausevid.y = 261;
stopvid.y = 261;
}
};
}
audioSelectAnimation.addEventListener(TweenEvent.M OTION_FINISH, onMotionFinished);
function audioSelectAnimation(objalph:Number, xpos:Number, textInfo:String) {
removeThumbs();
//root.titletext = "";
//root.infotext = "";
var slideDown:Tween = new Tween(slider2, "yscale", Regular.easeOut, slider2.scaleY, 105, 2, true);
var slideAlpha:Tween = new Tween(slider2, "alpha", Regular.easeOut, slider2.alpha, 20, 2, true);
function onMotionFinished(event:TweenEvent):void {
var aPosT1:Tween = new Tween(audioselect, "alpha", Regular.easeIn, audioselect.alpha, objalph, 2, true);
var aPosT3:Tween = new Tween(photoinfo, "alpha", Regular.easeIn, photoinfo.alpha, objalph, 2, true);
var aPosT:Tween = new Tween(audio, "alpha", Regular.easeIn, audio.alpha, objalph, 2, true);
if (canishowthesongs == 0) {
currenttrack = audionamearray[0];
currentartist = audioartistarray[0];
loadTracks();
}
};
}
function loadImages() {
var starty = 60;
var startx = 27;
numthumbs = galleryarray.length;
for (i=0; i<numthumbs; i++) {
var count = i+1;
if (count == 4 || count == 7) {
starty += 67;
startx = 27;
}
flash.display.MovieClip.MovieClip("holder", "thumb"+count, count);
loadMovie(galleryarray[i], "thumb"+count);
eval("thumb"+count).y = starty;
eval("thumb"+count).x = startx;
var aPosT:Tween = new Tween(eval("thumb"+count), "alpha", Regular.easeOut, 0, 100, 1, true);
startx += 65;
}
}
function setText(num) {
titletext = gallerytitlearray[num];
infotext = galleryinfoarray[num];
}
function removeThumbs() {
for (i=1; i<9; i++) {
removeChild("thumb"+i);
}
}
function loadTracks() {
starty = 130;
startx = 170;
numtracks = audioarray.length-1;
for (i=0; i<numtracks; i++) {
count = i+1;
if (count == 5) {
starty += 85;
startx = 10;
}
flash.display.MovieClip.MovieClip("trackholder", "track"+count, count);
eval("track"+count).trackholder = audionamearray[i]+" | "+audioartistarray[i];
eval("track"+count).y = starty;
eval("track"+count).x = startx;
starty += 15
}
}
videobtn.buttonMode = true;
videobtn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverVideo);
function mouseOverVideo(event:MouseEvent):void {
trace("videobtnselected");
moveSlider(12,36);
}
photobtn.buttonMode = true;
photobtn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverPhoto);
function mouseOverPhoto(event:MouseEvent):void {
trace("photobtnselected");
moveSlider(61,40);
}
audiobtn.buttonMode = true;
audiobtn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverAudio);
function mouseOverAudio(event:MouseEvent):void {
trace("audiobtnselected");
moveSlider(116,38);
}
videobtn.onPress = function() {
removeThumbs();
sectiontitle = "Videos";
caniplay = 1;
canishowthesongs = 1;
canishowthevids = 0;
slider2.scaleY = 15;
slider2.alpha = 0;
videoSelectAnimation(100,524);
photoSelectAnimation(0,125);
audioSelectAnimation(0,326);
};
photobtn.onPress = function() {
if (vidplayer.bytesTotal>-1) {
removeVids();
}
playvid._y = 400;
pausevid._y = 400;
stopvid._y = 400;
removeThumbs();
sectiontitle = "Photos";
caniplay = 0;
canishowthesongs = 1;
canishowthevids = 1;
slider2.scaleY = 15;
slider2.alpha = 0;
videoSelectAnimation(0,524);
photoSelectAnimation(100,125);
audioSelectAnimation(0,326);
};
audiobtn.onPress = function() {
if (root.mysound.position == 0) {
root.mysound.start();
}
if (vidplayer.bytesTotal>-1) {
removeVids();
}
playvid.y = 400;
pausevid.y = 400;
stopvid.y = 400;
sectiontitle = "Audio";
canishowthesongs = 0;
canishowthevids = 1;
caniplay = 1;
slider2.scaleY = 15;
slider2.alpha = 0;
videoSelectAnimation(0,524);
photoSelectAnimation(0,125);
audioSelectAnimation(100,326);
};
stopsound.onPress = function() {
mysound.stop();
thispoint = 0;
};
playsound.onPress = function() {
mysound.start(thispoint);
};
pausesound.onPress = function() {
thispoint = mysound.position/1000;
mysound.stop();
};
function removeTracks() {
thismany = audioarray.length;
for (i=1; i<thismany; i++) {
removeChild("track"+i);
}
}
function loadVideos() {
starty = 130;
startx = 130;
numvids = videoarray.length-1;
for (i=0; i<numvids; i++) {
count = i+1;
if (count == 4) {
starty += 85;
startx = 10;
}
flash.display.MovieClip.MovieClip("vidholder", "vid"+count, count);
eval("vid"+count).vidtext = root.videonamearray[i];
eval("vid"+count).y = starty;
eval("vid"+count).x = startx;
starty += 15;
}
}
function removeVids() {
thismany = videoarray.length;
vidplayer.visible = false;
vidplayer.stop();
for (i=1; i<thismany; i++) {
removeChild("vid"+i);
}
}