I am able to read in all of my XML but I cant get my text from XML into my dynamic textfield with my pv3D class. What am I not doing?
I need to get the “copy” node (within the XML) to replace the string: textField.text=“This is only some sample text This is only some sample text”;
trace("xmlList*.copy = " + xmlList*.copy);
returns the first xmlList node copy:
This is the sample text
I need this to be placed in:
textField.text=“This is only some sample text This is only some sample text”;
…and be in line with the image that is in the same xmlList
…so the first xmlList:
<image>
<pic><![CDATA[images/img1.jpg]]></pic>
<copy>This is the sample text</copy>
</image>
…matches img1.jpg with This is the sample text
Any help is huge right now, so Thanks!
AS3 class:
package {
import flash.events.Event;
import br.com.stimuli.loading.BulkLoader;
import br.com.stimuli.loading.BulkProgressEvent;
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.filters.GlowFilter;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormatAlign;
import flash.text.AntiAliasType;
import flash.display.DisplayObject;
import gs.easing.Quint;
import gs.TweenLite;
import org.papervision3d.events.InteractiveScene3DEvent;
import org.papervision3d.materials.BitmapMaterial;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.view.BasicView;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.core.effects.view.ReflectionView;
import org.papervision3d.materials.MovieMaterial;
public class Main extends BasicView {
protected var planes:Array=[];
protected var images:Array=[];
protected var numItems:Number;
protected var currentItem:Number=3;
protected var angle:Number=25;
protected var rightBtn:Sprite;
protected var leftBtn:Sprite;
protected var xmlPath:String="xml/imageXML.xml";
protected var bulkInstance:BulkLoader;
private var carousel:DisplayObject3D=new DisplayObject3D ;
private var bitmapViewport:Viewport3D=new Viewport3D(940,300);
private var view:ReflectionView;
public function Main():void {
super(940,300,true,true);
addChild(bitmapViewport);
bitmapViewport.interactive=true;
loadXML();
}
//First load our XML
protected function loadXML():void {
bulkInstance=new BulkLoader("bulkInstance");
bulkInstance.add(xmlPath);
bulkInstance.addEventListener(BulkProgressEvent.COMPLETE,onXMLReady);
bulkInstance.start();
}
//When our xml is ready parse and load our images
protected function onXMLReady(evt:BulkProgressEvent):void {
bulkInstance.removeEventListener(BulkProgressEvent.COMPLETE,onXMLReady);
bulkInstance.addEventListener(BulkProgressEvent.COMPLETE,onImagesReady);
var xml:XML=bulkInstance.getXML(xmlPath);
var xmlList:XMLList=xml.image;
for (var i:int=0; i<xmlList.length(); i++) {
var imagePath:String=String(xmlList*.pic);
//var textPath:String=String(xmlList*.copy);
bulkInstance.add(imagePath);
images.push(imagePath);
//images.push(textPath);
//trace("xmlList*.pic = " + xmlList*.pic);
//trace("xmlList*.copy = " + xmlList*.copy);
}
numItems=images.length;
}
protected function onImagesReady(evt:BulkProgressEvent):void {
init();
}
protected function init():void {
createChildren();
startRendering();
}
protected function createChildren():void {
for (var i:int=0; i<numItems; i++) {
var mat:BitmapMaterial=new BitmapMaterial(bulkInstance.getBitmapData(images*));
trace("images* = " + images*);
mat.interactive=true;
mat.smooth=true;
var plane:Plane=new Plane(mat,360,280);
carousel.addChild(plane);
plane.rotationY=360/numItems*i;
plane.moveForward(900);
planes.push(plane);
//reflection should be implimented here///////////////////////////
view=new ReflectionView(940,300,true,true);
addChild(view);
view.singleRender();
var textMC:MovieClip=new MovieClip ;
var textField:TextField=new TextField ;
textField.wordWrap=true;
textField.width=400;
textField.height=280;
textField.multiline=true;
textField.text="This is only some sample text This is only some sample text";
textField.autoSize=TextFieldAutoSize.LEFT;
textField.antiAliasType=AntiAliasType.ADVANCED;
var textFormat:TextFormat=new TextFormat("Arial");
textFormat.size=30;
textFormat.color=0xffffff;
textFormat.bold=false;
textFormat.align="center";
textMC.defaultTextFormat=textFormat;
textField.setTextFormat(textFormat);
//Create a rect the size of the MovieClip with an opacity of 0
//This lets the TextField render properly
textMC.graphics.beginFill(0x00ff00,0);
textMC.graphics.drawRect(0,190,360,80);
textMC.graphics.endFill();
textMC.addChild(textField);
var tfMaterial:MovieMaterial=new MovieMaterial(textMC,true,false,true);
tfMaterial.interactive=true;
tfMaterial.smooth=true;
tfMaterial.tiled=true;
var tmpPlane:Plane=new Plane(tfMaterial,400,380);
tmpPlane.y=-360;
plane.addChild(tmpPlane);
plane.id=i;
plane.addEventListener(InteractiveScene3DEvent.OBJECT_OVER,onPlaneOver);
plane.addEventListener(InteractiveScene3DEvent.OBJECT_OUT,onPlaneOut);
plane.addEventListener(InteractiveScene3DEvent.OBJECT_PRESS,onPlaneClick);
scene.addChild(carousel);
startRendering();
}
camera.zoom=80;
}
protected function onPlaneOver(evt:InteractiveScene3DEvent):void {
var plane:Plane=evt.target as Plane;
plane.moveForward(-200);
trace("over");
}
protected function onPlaneOut(evt:InteractiveScene3DEvent):void {
var plane:Plane=evt.target as Plane;
plane.moveForward(200);
trace("onPlaneOut");
}
protected function onPlaneClick(evt:InteractiveScene3DEvent):void {
var plane:Plane=evt.target as Plane;
//plane.moveForward(-200);
trace("onPlaneClick");
}
public function MouseOverStage() {
stage.addEventListener( Event.MOUSE_LEAVE, mouseOutHandler );
}
private function mouseOutHandler( event:Event ):void {
trace( "mouse has left the stage" );
}
override protected function onRenderTick(event:Event=null):void {
carousel.rotationY-=viewport.containerSprite.mouseX/100;
renderer.renderScene(scene,camera,bitmapViewport);
}
}
}
XML:
<?xml version="1.0" encoding="utf-8" ?>
<data>
<!---14 images is really all you want to add as the text below will begin to run together if more are added-------->
<!---12 is optimal, just know that anything less will cause more spacing between image planes---------------------->
<image>
<pic><![CDATA[images/img1.jpg]]></pic>
<copy>This is the sample text</copy>
</image>
<image>
<pic><![CDATA[images/img2.jpg]]></pic>
<copy>This is more sample text</copy>
</image>
<image>
<pic><![CDATA[images/img3.jpg]]></pic>
<copy>Another set of sample text</copy>
</image>
<image>
<pic><![CDATA[images/img1.jpg]]></pic>
<copy>Look at this sample text</copy>
</image>
<image>
<pic><![CDATA[images/img2.jpg]]></pic>
<copy>This is the sample text</copy>
</image>
<image>
<pic><![CDATA[images/img3.jpg]]></pic>
<copy>Another set of sample text</copy>
</image>
<image>
<pic><![CDATA[images/img1.jpg]]></pic>
<copy>Look at this sample text</copy>
</image>
<image>
<pic><![CDATA[images/img2.jpg]]></pic>
<copy>This is the sample text</copy>
</image>
<image>
<pic><![CDATA[images/img3.jpg]]></pic>
<copy>Another set of sample text</copy>
</image>
<image>
<pic><![CDATA[images/img1.jpg]]></pic>
<copy>Look at this sample text</copy>
</image>
<image>
<pic><![CDATA[images/img2.jpg]]></pic>
<copy>Look at this sample text</copy>
</image>
<image>
<pic><![CDATA[images/img2.jpg]]></pic>
<copy>This is the sample text</copy>
</image>
</data>
I know I am very close so if anyone could just nudge me in the right direction I would be grateful…
Thanks