ActionScript 3.0 :: XML Gallery Sorting With Loader Class?
Sep 26, 2009
I'm reasonably new to AS3 having made the leap from Flash 8 to CS4 in a single bound. I've been doing okay, but I've stumbled across a bit of an issue:I'm using an XML file to load a gallery of images and information, where a node typically looks like this:
PHP Code:
<project> <image>1.jpg</image> <link>gallery-1</link> - <title>- <![CDATA[ This is image number 1]]> </title>- <info>- <![CDATA[ Lorem ipsum dolor sit amet, consectetaur adipisicing elit. ]]> </info> </project>- <project>
In AS, once my XML has been parsed, it runs this function:
[AS]
var projectTitles:Array = new Array();
function createProjectClips(list:XMLList):void {
[code]....
This all works fine; I need all of these thumbs loaded and parsed at the same time to show the full gallery. The issue is that, as the images are of varying file sizes they don't load in sequence, and because I can't pass additional parameters through the eventListener, I've apparently got no way to organise the images on screen. So, my images on screen might be in the sequence 1.jpg, 4.jpg, 3.jpg, 2.jpg, but my projectTitles array will say Image 1, Image 2, Image 3, Image 4.
I am finding my way with AS3 but am having difficulty with a gallery project I am trying to put together based on the sample slideshow available on this site.
The problem relates to reading the thumb and image paths in the xml file. The error that is coming back is:
Loading error on ImageLoader 'loader1' (assets/thumbs/): Error #2035: URL Not Found. URL: file:///C|/Documents%20and%20Settings/Alistair.HOME/Desktop/AB%20gallery%20proj/assets/thumbs/
I'm making a flash gallery with a pre loader on the first frame and on the second frame is the content.
The pre loader works, and loads up my first gallery image but then I can not proceed to view any more when I click my gallery buttons. Previously without the pre loader the buttons worked fine.
This is driving me crazy. When I preview in Flash, everything looks fine. When I preview in HTML. Not so much. I've created a gallery using xml and have the code centering (and otherwise positioning) each new loaded item by referencing each ones information.
It seems to have trouble doing this with the first swf and positioning it at 0,0 after I click through the forward/back buttons that swf moves to a different location on the stage. My guess is that the loader height and width get calculated as 0,0 before the image gets loaded, and then screws everything up from there.
I am using the Loader class to load 3 external swfs: sharedTopics.swf (does not have a document class) fonts.swf (document class is FontManager) main.swf (document class is Main) The same loader is used to load all 3 assets.
The picture loader is working well and the text too but it doesn't work so well together. When I'm clicking on a sticker, the picture is load and a text too but it's not the good one.
I have made a photogallery in actionscript 3 which uses an .XML file to import pictures. As the user clicks on the displayed image the code loads the next image in the cycle into the display. Now, I would like to add a preloader which displays the loading progress of each image as the user clicks (otherwise there is just a blank area as the image loads). I have made a pre-loader for the main .SWF but I can't figure out how to make it work for the images or how to make a seperate one for the images. The fact is that I am a bit of a muppet when it comes to AS3, and am finding myself getting lost an confused quite easily.
I have attatched the .FLA if that helps any! If not then...
here is the link to the .HTML page that contains the .swf:
i am loading all thumbs and images in a container on a single frame using action script..but the size of the swf becomes 1.2 mb so i want to add a loader to it...the loader i am trying to add counts the frames but my file has just one frame so the loader doesnot show up..
here is the script of my gallery..and the timeline has just one frame...
My problems comes in when you have to open a different image album and have to eliminate all the previously loaded children in the movieclip. When i load a new album i used a code you posted here: AS3 How to remove previous loadersbut the problem is that sometimes the user leaves the album page before ALL the pics laod so when they click on a new album to open it a new image is placed somewhere else cause the loader has already been launched. I've tryd to close() the loader but it doesn't seem to work.Here you can see the working site to see what im talking abouy you have to click on an album, leave before all the pictures load and open up another one.
getImage(dataList[0].file) function getImage(href:String):void { var loader:Loader = new Loader();
I have a sliding thumbnail gallery which when a thumbnail is clicked loads an external .png into a container with an instance name of mycontainer which I have on the stage in the .fla. Its added like such: When the Loader's (which I gave an instance name of imgLoader) complete event is called the function onLoaded loads it -like this: mycontainer.addChild(imgLoader);
I also added a mask(stageMask2) to mycontainer which is the same size as the external .png--I then used this code imgLoader.mask=stageMask2; to mask the .png. I did this because I added a zoommc function which enlarges the imgLoader and wanted to keep the visible size of the container the same. I would also like to be able to drag the zoomed image. I don't want to drag mycontainer as it contains the mask and I cant drag the imgLoader as it doesn't have that property--Do I need to put the imgLoader in another container?
Here's the problematic code: var stageMask2:Sprite = new Sprite(); stageMask2.graphics.beginFill(0x183045,0); stageMask2.graphics.drawRect(swfX,swfY,604,403); stageMask2.graphics.endFill(); var closeWin:TextField=new TextField(); [Code] .....
This is the code i used in a gallery that loads images sequentally. My problems comes in when you have to open a different image album and have to eliminate all the previously loaded children in the movieclip. The problem is that sometimes the user leaves the album page before ALL the pics laod so when they click on a new album to open it a new image is placed somewhere else cause the loader has already been launched. I've tryd to close() the loader but it doesn't seem to work. Here you can see the working site www.barbarabritvin.com (to see what im talking about you have to click on an album, leave before all the pictures load and open up another one.
getImage(dataList[0].file) function getImage(href:String):void { var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, imageReady);
I have set up a functioning xml image gallery with simple left and right arrows. I am now trying to make it an infinite looping gallery swapping the first and last sprites in an array and + and - their x value so they "physically" move in the photos container.
All of this works fine except for the actual loaded image. The xml data, name description, and image to be loaded are set up in one function and all the data is added to the sPhotoSprite (sprite) in this function. This All works perfectly..
A second function is then called to add the current image:
var currentImage:Loader = Loader(evt.target.loader); then currentSprite.addChild(currentImage); (the sprite is declared at the start)
The problem being that the sPhotosSprite is no longer reference-able. I've tried :
But this only ever returns the final sprite. The same problem of only ever returning the final sprite occurs when I try setting an external sprite to hold the current sprite in it and then referencing it in the second function.
I have created a drop menu, with a nice little transparency. I have also set up the buttons to link to other SWF files and load them into a loader on the page. My problem is that the loader sits above the drop menus, so when you go to click on the menus they drop down behind the loader and you can't see them. Is there away of sending the loader to the back of the flash work? Maybe using a sprite, not that I have had much experience with sprites.
var my_loader:Loader = new Loader(); my_loader.x = 10; my_loader.y = 40;
I have this piece of code to change images. I was trying to figure out how you could put a timer on the code, so if the image has been displayed for say 5 seconds it diverts to the next image automatically? Also if it's not to hard, when it has played to the end to divert to the 1st image.
I wanted to design a [relatively] all purpose class to load images and SWF's with a preloader MC and error handler. I made this BUT, when I load the MC I cannot control it. i.e. I load an SWF containing an animated GIF, but I cannot say mc.gotoAndStop();
How can I get Loader class from Progress event. function loadMovies () { var ldr:Loader=new Loader() ldr.load(new URLRequest("test.swf")) ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,getper) addChild(ldr)} function getper (event) { var info:LoaderInfo=LoaderInfo(event.target) trace(info.loader) }loadMovies()
my application needs to load an swf into something that looks and acts like a video player. so you can scrub through the parts that are loaded and see the progress of the load. im not using any pre-fab video components, but to make it work i need to know which frames are loaded and i need to be able to skip to them.
1) to know how many frames are loaded (not bytes!) and 2) to be able to skip to a loaded frame before the movie finishes loading.
it seems to me that using the Loader class you can do neither. sure, you can check progress with bytesloaded (not useful to me) but you cant do ANYTHING to the swf, programmatically, until it is fully loaded! am i wrong about this?
[Code]...
if you look at the comments in the code above you see my problem. if i cant see which frames are loaded or skip to them before the movie is finished loading, the user has to wait until the movie is done loading before they can start no navigate and i can't show them a meaningful loading progress bar like they have on video players (bytes doesnt tell me how much "time" is loaded)
am i the only one who thinks its crazy that in flash, which is all about showing content quickly while it loads, you cant do anything with the swf until its complete? am i missing something or is this a real limitation?
I am making an application where I load a picture from the web at a rate of once per second. When I load a new picture I unload the old one the problem is that the old pictures are never completely erased from memory and the application keeps on consuming more and more memory until I'm guessing it eats all the memory in the cache (I haven't run it for that long yet :))
here is the code: what this does is load a picture when you click the screen, then unloads it when you click the picture. do it a few times and notice that the numbers (which show System.totalMemory) only go up but never go down to their original amount...
Code:
var url:String = "http://www.memorycity.com/shop/MBB/images/GIGABYTE_memory.jpg"; stage.addEventListener(MouseEvent.CLICK,onclick) var txt:TextField = new TextField()
I have a flash rotating banner script that I purchased, and wish to incorporate into my homepage. Instead of creating a page with HTML and adding the banner code as a separate object on the page, I wish to load it as an external swf into a movieclip on my stage. This is what the banner looks like:
[URL]
I have a page that I'm redesigning, it's located at:
[URL]
I have a movieclip named load_banner. Inside the movieclip in its own frame, I put in the following code:
I'm trying to load images using the loader class but it doesn't seem to ever trigger the complete event (in this case anyway). The images are only 16x16px images from the local machine, so it should take no time at all to load. I use the totalImages variable as a counter; as an image is loaded, it subtracts 1 from it. Once it is 0, all images are loaded. I can create an instance and it goes as far as tracing "Begin loading images", but that's it. No errors in the console either.
I'm working with Loader class in as3 and there comes some really strange problem. I have two swf files, one loading the other. In the first one, I have codes like this:
var loader:Loader=new Loader(); var context:LoaderContext=new LoaderContext(); context.applicationDomain=ApplicationDomain.curren tDomain; var req:URLRequest=new URLRequest("Untitled-1.swf"); loader.load(req); loader.contentLoaderInfo.addEventListener(Event.CO MPLETE,onCPL); function onCPL(e):void{ trace("finish"); addChild(e.currentTarget.content); }
And the second one, with the name "Untitled-1.swf", doesn't seem to work in the first one. I find out that as long as there are ANY codes in the second swf file, the first one will repeat tracing "finish" endlessly.
I have a loader which loads on a MouseEvent.Click. It uses this for multiple swfs Actionscript Code: myLoader.load(new URLRequest(event.target.name + ".swf")); How can I add a custom preloader to this?
I have a "master" SWF file into which I load content (other SWFs) via the Loader Class (with code below). var contentLoader:Loader = new Loader();this.contentContainer.addChild(contentLoader);I load the content (these other SWFs) into a MovieClip container on the stage called "contentContainer". The "contentContainer" is much smaller than the "master" SWFs stage and also much smaller than the original size of the SWFs that the Loader is loading in. Also, and this is very important, the "contentContainer" itself is sized -- not scaled -- (see code) and placed on the stage depending on how large the stage is scaled (I am trying to make one of those "liquid stage" flash sites that fills the browser window with flash content regardless of window size).//this resides in a function that is called whenever the stage RESIZE Event is fired
I'm trying to load an image in a movieclip using using the following:
Load_image_btn.addEventListener(MouseEvent.CLICK,Load_image); function Load_image(event:MouseEvent):void{ var my_loader:Loader = new Loader(); my_loader.load(new URLRequest("C:UsersAmandaDesktoppicture1")); addChild(my_loader);}
im loading a child swf into my parent swf and I want to pass some parameters to the child swf.
Here is my code:
var req:URLRequest = new URLRequest( "test.swf" ); var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener( Event.COMPLETE, loadComplete ); loader.load(req);
I created a button class with a method that will allow me to control an external SWF. However, the loader for the SWF is created on my main timeline. Is it possible to access the loader object from within my button class?No matter what I try I either get an error that the variable is not defined (rightfully so because I haven't defined it in the class, it's defined on the main timeline) or that the object is null (when I declare the loader from within the class, which I know is wrong as well)
I'm trying to use a custom class to create a mosaic type of gallery, and load jpegs in which some may have different dimensions. I'm using the Loader Class and I can get the content width value of the jpegs I'm loading, but I'm having trouble adding that value to the property of the (custom) object. Here is the Class: