PDA

View Full Version : problem with loading image for dynamically created view


nari422
01-23-2009, 10:57 PM
Hi Guys,
I am getting problem with store image for dynamically created view. I have one view called diVw2. For that view i created dynamically one view and add the text and image to that dynamic view .Text added successfully but image not added. I am getting the problem call to undefined method image.


<canvas ondata="canvas.forimages()">
<view id="diVw2" />
<method name="forimages">
sampleimage ="C:\temp\images\fish.jpg" ;
var dynamicView=new lz.view(diVw2,{x:5,y:35,width:515,height:100,bgcol or:'#D74B28',clip:true });
var sampleitem1 =new lz.text(dynamicView,{x:3,text:'Item Name',fgcolor:white});

pcawdron
01-25-2009, 11:03 PM
Nari,

The problem is in your second step (loading up some text) hasn't referenced the first. You've referred to it as a variable, but OpenLaszlo is going to be looking for it as a view/object.

This should work...

var dynamicViewVariable=new lz.view(canvas.diVw2 ,{name:"dynamicView",x:5, y:35, width:515, height:100, bgcolor:'#D74B28', clip:true });
var sampleitem1Variable =new lz.text(dynamicView,{x:3, text:'Item Name', fgcolor:white});

Also, you're probably going to want to add some spacing or something like a simplelayout

var dynamicViewVariable=new lz.view(diVw2,{name:"dynamicView",x:5, y:35, width:515, height:100, bgcolor:'#D74B28', clip:true });
var sampleitem1Variable = new lz.simplelayout(dynamicView,{axis:"y", spacing:10})
var sampleitem2Variable =new lz.text(dynamicView,{x:3, text:'Item Name', fgcolor:white});

If you run into any problems with referencing your new dynamicView, you may need to refer to it from the canvas rather than just with it's normal name, so something like canvas.diVw2.dynamicView

Cheers,
Peter