Hi there
I am trying to create a dynamically added picture scroller.
It all works fine apart from it adds one picture on top of each other rather than after each others width.
And one last question … how would I copy the initially created movieclip so I can duplicate it so that I have a never ending scroller.
movieScroll = new MovieClip();
this.addChild(movieScroll);
for (var i:Number=1; i<11; i++)
{
poster_loader = new Loader();
poster_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,doneLoad);
var poster_url = "posters/"+i+".jpg";
poster_loader.load(new URLRequest(poster_url));
movieScroll.addChild(poster_loader);
poster_loader.cacheAsBitmap = true;
poster_loader.mask = movieMask;
poster_loader.x = w;
w = w +(poster_loader.width);
trace(poster_loader.width);
}
thanks in advance
Steven
Ok getting somewhere I added an additional .width.tag to the XML so that it wouldn’t need to get the .width value from the mcs.
Even added a dynamic mouseX scroller to make the main mc scroll
All works ok locally but when I upload to web server it doesn’t load the posters correctly
This is all the code plz plz someone help
import com.greensock.*;
import flash.display.*;
import flash.display.MovieClip;
import flash.events.*;
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.utils.Timer;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.text.TextField;
import flash.text.TextFormat;
/******** ! A R R A Y S ! ********************************/
var movie_Number:Array = new Array();
var movie_Width:Array = new Array();
var movie_Title: Array = new Array();
var movie_Director: Array = new Array();
var movie_Star: Array = new Array();
var movie_Duration: Array = new Array();
var movie_Genre: Array = new Array();
var movie_Year: Array = new Array();
var movie_Rating: Array = new Array();
var movie_Comment: Array = new Array();
var images:Array = new Array();
var xmlLoader:URLLoader, xmlData:XML;
var w:Number = 0;
var full_loader:Loader;
var full_url:String;
var LOCKY:Number = moviePosters.y;
var xSpeed:Number = 0;
init();
function init():void
{
xmlLoader = new URLLoader;
xmlLoader.addEventListener(Event.COMPLETE, loadXML);
xmlLoader.load(new URLRequest("movieInfo.xml"));
stage.addEventListener(Event.ENTER_FRAME, onOver);
}
function loadXML(e:Event):void
{
xmlData = new XML(e.target.data);
var movieWidth:XMLList = xmlData..width;
var movieTitle:XMLList = xmlData..title;
var movieDirector:XMLList = xmlData..director;
var movieStar:XMLList = xmlData..star;
var movieDuration:XMLList = xmlData..duration;
var movieGenre:XMLList = xmlData..genre;
var movieYear:XMLList = xmlData..year;
var movieRating:XMLList = xmlData..rating;
var movieComment:XMLList = xmlData..comment;
var len:int = xmlData.movie.length();
moviePosters.x = 0;
moviePosters.y = 0;
for (var i:int = 0; i < len; i++)
{
movie_Number.push(i);
movie_Width.push(movieWidth[i])
movie_Title.push(movieTitle[i]);
movie_Director.push(movieDirector[i]);
movie_Star.push(movieStar[i]);
movie_Duration.push(movieDuration[i]);
movie_Genre.push(movieGenre[i]);
movie_Year.push(movieYear[i]);
movie_Rating.push(movieRating[i]);
movie_Comment.push(movieComment[i]);
full_loader = new Loader();
full_url = "posters/" + (i+1) + ".jpg";
full_loader.load(new URLRequest(full_url));
moviePosters.addChild(full_loader);
full_loader.x = w;
full_loader.y = 0;
moviePosters.cacheAsBitmap = true;
movieMask.cacheAsBitmap = true;
moviePosters.mask = movieMask;
w = w + Number(movieWidth[i]);
}
}
function onOver(e:Event):void
{
if (mouseX < 301 || mouseX > 0){
xSpeed = int((300-mouseX)*-.01);
} else if (mouseX > 300 || mouseX < 601){
xSpeed = int((mouseX-300)*.01)}
moviePosters.x = moviePosters.x + xSpeed;
if (moviePosters.x > 0){moviePosters.x = 0;
} else if (moviePosters.x < -(moviePosters.width-600))
{moviePosters.x = -(moviePosters.width-600);
}
if(moviePosters.y != LOCKY) moviePosters.y = LOCKY;
}
ps… I learned all this myself so I not doing to bad for an old guy lol
Thanks in advance
Steven
All fixed thanks for the help