PDA

View Full Version : SWC Component


BrettAF3D
05-21-2008, 10:46 AM
Hi, i am populating a TileList with swc ( custom component from flash) and i cant find how to pass the data from my xml file to my custom component for Initialisation. My component has a dynamic title filed and a holderMC for the img...

its easy to pass it to a custom component made in flex like:
<mx:itemRenderer>
<mx:Component>
<Image source="assets/img/{data.source}/>
<Text text={data.caption"}/>
etc....


but this syntax doesn't seem to work with my "swc" anyone has has an idea ???

swc class:

package
{

import flash.display.Loader;
import flash.events.*;
import flash.net.URLRequest;
import flash.display.MovieClip;
import flash.text.TextField;
import mx.flash.UIMovieClip;
import flash.events.IOErrorEvent;


public class TileMC extends UIMovieClip
{
[Bindable]
public var _title:String;
[Bindable]
public var _url:String;
private var _loader:Loader = new Loader();
private var _data:Object = new Object();


public function TileMC()
{

mouseChildren = false;
addEventListener(MouseEvent.MOUSE_OVER, overHandler);
addEventListener(MouseEvent.MOUSE_OUT, outHandler);
_loader.contentLoaderInfo.addEventListener(Event.C OMPLETE, LoadComplete);

}

public function Init():void
{

titleTXT.text = _title;
var request:URLRequest = new URLRequest(_url);
bgMC.gotoAndStop(1);

_loader.load(request);
}

private function overHandler(e:MouseEvent):void
{

bgMC.gotoAndPlay("over");
}

private function outHandler(e:MouseEvent):void
{

bgMC.gotoAndPlay("out");
}

private function LoadComplete(event:Event)
{
imgHolderMC.addChild(event.target.content);

}



}
}




here is the TileList:


<mx:TileList id="tl" width="100%" height="100%"
dataProvider="{acData}"
backgroundColor="#080808" borderColor="#2B2B2B"
themeColor="#080808" borderStyle="none"
rollOverColor="#080808" creationComplete="test(tl.data)" >
<mx:itemRenderer>
<mx:Component>
<!--<mx:VBox horizontalAlign="center" horizontalScrollPolicy="off" verticalScrollPolicy="off"
width="170" height="210">
<mx:Image source="assets/img/{data.source}"/>
<mx:Text width="100%" text="{data.caption}" textAlign="center"/>
</mx:VBox>-->
<mx:VBox>
<local:TileMC id="tile" _title="test" creationComplete="tile.Init()" />
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:TileList>