Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6144633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:40:42+00:00 2026-05-23T18:40:42+00:00

I’m trying to create an as3 project that dynamically pulls images from a database

  • 0

I’m trying to create an as3 project that dynamically pulls images from a database and sticks them into the framework of a flash movie that I making with this. Currently I am following a tutorial (in as2, and I am converting it to as3 as I go along) and am trying to get images to load from the same directory as the project, but I am having issues with the Loader. I am a complete newb at as3 and as such have almost no idea what I am doing, so I come to you guys for help as to why my program won’t work properly. Here is the entire code from my project.

import flash.net.URLLoader;
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.MovieClip;
import flash.display.*;
import com.greensock.TweenLite;
import com.greensock.easing.*;

var xmlPath = "content.xml";
var photos_xml:XML = new XML();
var imageList:XMLList = new XMLList();
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, loadXML)
var imageLoader:Loader = new Loader();
imageLoader.addEventListener(Event.INIT, initHandler);
imageLoader.addEventListener(Event.COMPLETE, completeHandler);
var currentImage:Number = 0;
var timer:Number;

xmlLoader.load(new URLRequest(xmlPath));

//stop();

function loadXML(e:Event):void
{
    photos_xml = new XML(e.target.data);
    imageList = photos_xml.image.text();

    //for (var i:int = 0; i < imageList.length(); i++)
//  {
//      trace (imageList[i]);
//  }

    loadImage();
}

function loadImage()
{
    var loadURL = imageList[currentImage]
    var req:URLRequest = new URLRequest(loadURL);
    var targetClip:MovieClip = new MovieClip();
    targetClip.alpha = 0;
    clearInterval(timer);

    //trace(loadURL);
    //======== imageLoader refuses to throw events! ===========
    trace(req.url)
    imageLoader.load(req);
    targetClip.addChild(imageLoader);
    shell_mc.pics_mc.addChild(targetClip);

    trace("I am in loadImage");
}

function setTimer():void
{
    timer = setInterval(loadImage, 1000);
}

function removePrevious(prevImg:MovieClip):void
{
    if (prevImg != null)
    {
        removeChild(prevImg);
        //removeMovieClip(prevImg);
    }

    //trace(currentImage);
    currentImage = (currentImage + 1) % imageList.length();
}

function initHandler(event:Event):void
{
    trace("I am in initHandler");
    TweenLite.to(shell_mc.background_mc, 0.25, {width:event.target.width + 20, height:event.target.height + 20, ease:Quad.easeOut});
    TweenLite.to(shell_mc.border_mc, 0.25, {width:event.target.width, height:event.target.height, ease:Quad.easeOut});
    TweenLite.to(shell_mc.mask_mc, 0.25, {width:event.target.width, height:event.target.height, ease:Quad.easeOut});

    var clipXTarg = Math.round((stage.width / 2) - ((event.target.width + 20) / 2));
    var clipYTarg = Math.round((stage.height / 2) - ((event.target.height + 20) / 2));
    TweenLite.to(shell_mc, 0.25, {x:clipXTarg, y:clipYTarg, ease:Quad.easeOut});

    var prevImgNum:Number;
    if (currentImage == 0)
    {
        prevImgNum = imageList.length() - 1;
    }
    else
    {
        prevImgNum = currentImage - 1;
    }
    var prevImg = shell_mc.pics_mc["pic" + prevImgNum];
    TweenLite.to(prevImg, 0.25, {autoAlpha:0, onComplete:removePrevious(prevImg)});
}

function completeHandler(event:Event):void
{
    trace("I am in completeHandler");
    TweenLite.to(event.target, 0.25, {autoAlpha:100, delay:0.25});
    setTimer();
}

The issue here is that the imageLoader won’t throw any events as it is loading the image file, and there are absolutely no errors to give me any clue why it might be failing. Here is how my xml file looks:

Assets/DaVinci1.jpg
Assets/DaVinci2.jpg
Assets/DaVinci3.jpg

Both the project and the Assets folder are in the same directory, so the filepath should not be an issue, but otherwise I don’t know. Here is the tutorial I am following (http://active.tutsplus.com/tutorials/xml/flash-slideshow-xml/)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:40:42+00:00Added an answer on May 23, 2026 at 6:40 pm

    When you are loading the swf or image types you need to add eventListener not to the loader but to the contentLoaderInfo

    contentLoader   = new Loader ();
    
    contentLoader.contentLoaderInfo.addEventListener ( Event.COMPLETE, handleComplete );
    contentLoader.contentLoaderInfo.addEventListener ( ProgressEvent.PROGRESS, handleProgress );
    contentLoader.contentLoaderInfo.addEventListener ( ErrorEvent.ERROR, handleError );
    contentLoader.contentLoaderInfo.addEventListener ( IOErrorEvent.IO_ERROR, handleError );
    contentLoader.contentLoaderInfo.addEventListener ( SecurityErrorEvent.SECURITY_ERROR, handleError );
    

    and whe you need to load data ( text based files ) you doing like with your XMLLoader

    dataLoader              = new URLLoader ();
    
    dataLoader.addEventListener ( Event.COMPLETE, handleComplete );
    dataLoader.addEventListener ( ProgressEvent.PROGRESS, handleProgress );         
    dataLoader.addEventListener ( ErrorEvent.ERROR, handleError );
    dataLoader.addEventListener ( IOErrorEvent.IO_ERROR, handleError );
    dataLoader.addEventListener ( SecurityErrorEvent.SECURITY_ERROR, handleError );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.