www.webdeveloper.com
Results 1 to 2 of 2

Thread: AS3 layers issue

Hybrid View

  1. #1
    Join Date
    Jan 2004
    Posts
    484

    AS3 layers issue

    Hi I am new to as3

    I have a layer question
    I know that in flash cs3 each object is given its own layer

    I declare the loader object in the function
    the addchild after load is complete for that picture
    but it seem to be only loading the one image
    that is the last image in my xml.

    I am trying to get it to load all the images on the screen at once


    I have the following code that loads an image on to the screen from an xml file.

    Code:
    var loader:URLLoader = new URLLoader();
    loader.dataFormat = URLLoaderDataFormat.TEXT;
    loader.addEventListener(Event.COMPLETE,loadXML);
    loader.load(new URLRequest("xml/main.xml"));
    var myXML:XML;
    
    function loadXML(evt:Event):void
    {
    	try{
    			myXML = new XML(evt.target.data);
    			//trace(myXML);
    		}catch(e:TypeError){
    			trace("Could Not Parse the XML\n");
    			trace(e.message);
    		}
    }
    
    function init(event:MouseEvent):void
    {
    
    
    	var n = 0;
    	var currSlide:DisplayObject;
    	var bitmap:Loader = new Loader();	
    	
    	for(var i = 0;i<myXML.title.length();i++){
    		
    		var stImage:String = myXML.title[i].image.toString();
    
    	    bitmap.load(new URLRequest(stImage));
    
    		bitmap.x = Math.floor(50+n);
    		bitmap.y = Math.floor(50+n);
    		n++;
    		addChild(bitmap);
    		
    		}
    
    	
    }
    this is the xml.
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE data[
    <!ELEMENT title(comments, image)>
    <!ATTLIST title name CDATA #REQUIRED>
    <!ELEMENT comments (#PCDATA)>
    <!ELEMENT image (#PCDATA)>
    ]>
    <data>
    	<title name="Phone No1.">
    		<comments>This is phone Number 1</comments>
    		<image>img/1.jpg</image>
    	</title>
    	<title name="Phone No2.">
    		<comments>This is phone Number 2</comments>
    		<image>img/2.jpg</image>
    	</title>
    	<title name="Phone No3.">
    		<comments>This is phone Number 3</comments>
    		<image>img/3.jpg</image>
    	</title>
    	<title name="Phone No4.">
    		<comments>This is phone Number 4</comments>
    		<image>img/4.jpg</image>
    	</title>
    	<title name="Phone No5.">
    		<comments>This is phone Number 5</comments>
    		<image>img/5.jpg</image>
    	</title>
    	<title name="Phone No6.">
    		<comments>This is phone Number 6</comments>
    		<image>img/6.jpg</image>
    	</title>
    	<title name="Phone No7.">
    		<comments>This is phone Number 7</comments>
    		<image>img/7.jpg</image>
    	</title>
    </data>

  2. #2
    Join Date
    Nov 2007
    Location
    Ohio
    Posts
    308
    Are you able to post your FLA and images into a zip?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles