as requested, i'm giving more detailed description of problem...
first off have mxml:
<mx:panel x="270" y="10" width="690" height="680" id="maincontainerpanel"> <mx:canvas x="270" y="10" width="670" height="640" id="canvas" initialize="oninit()"> <mx:script> protected function oninit():void { spiro = new spirograph(canvas); } </mx:script> </mx:canvas> </mx:panel>
this passes tag object constructor of main as3 class file. works fine, in constructor have:
function spirograph(canvas:canvas):void { maincontainer = canvas; maincontainer.graphics.beginfill(0xffffff); maincontainer.graphics.drawrect(0, 0, 670, 640); maincontainer.graphics.endfill(); }
at moment, adding sprite objects maincontainer using wrapper class called spriteuicontainer:
package includes { import flash.display.sprite; import mx.core.uicomponent; public class spriteuicontainer extends uicomponent { public function spriteuicontainer(sprite:sprite) { super(); this.explicitwidth = sprite.width; this.explicitheight = sprite.height; this.x = sprite.x; this.y = sprite.y; addchild(sprite); } } }
which used in following way:
private var circcentre:sprite = new sprite(); circcentre.x = maincontainer.width / 2; circcentre.y = maincontainer.height / 2; circcentre.graphics.linestyle(3, 0xd0b917); circcentre.graphics.beginfill(0xf2df56, 0.2); circcentre.graphics.drawcircle(20, 20, 50); circcentre.graphics.endfill(); maincontainer.addchildat(new spriteuicontainer(circcentre), 1);
the circcentre sprite never appears on screen , don't understand how can appear.
any appreciated!
by 'attached' mean adding new sprites uicomponent using addchild method?
if so; you'll have add code size , position new 'sprite' relative other objects in container. there no such code in example. recommend implementing code in updatedisplaylist().
more information on updatedisplaylist() in flex component lifecycle documentation.
if need more help, you'll have expand on how adding new sprites uicomponent instance; , perhaps show example add more one.
Comments
Post a Comment