Sunday, April 4, 2010

I thought I understood this stuff ..

we'll at least AS 2.0 ..

got a clip ... loads a child .. runs AS in frame 1 of child ... then child unloads ...

here's my problem ... when the child unloads the code in frame 1 of the child is re run ....

I know it's something stupid ...

parent swf

var CtlrStatus:Boolean = false
var vidCtrls:MovieClip
var vCtlrsLdr:Loader = new Loader()
vCtlrsLdr.contentLoaderInfo.addEventListener(Event.INIT, LoadComplete);
var vCtlrName:String

var cc:LocalConnection = new LocalConnection()
cc.allowDomain(''*'')
cc.client = this

var cc2:LocalConnection = new LocalConnection()

function LoadCtlrs():void{
if(CtlrStatus == false){
?//var vCtlrsLdr:Loader = new Loader()
//vCtlrsLdr.contentLoaderInfo.addEventListener(Event.INIT, LoadComplete);
?var reqst:URLRequest = new URLRequest(protocol + domain + path + ''Controls.swf'');
?vCtlrsLdr.load(reqst);
}
if(CtlrStatus == true){
?unLoadCtlrs(null)
}
}

function LoadComplete(evt:Event):void {
vidCtrls = MovieClip(vCtlrsLdr.content);
vCtlrsLdr.unload()
addChildAt(vidCtrls,1);
CtlrStatus = true
vCtlrName = vidCtrls.name
vidCtrls.x = 49
vidCtrls.y = 199
vidCtrls.gotoAndPlay(2)
cc.connect(''_cCom'')
cc2.send(''_cCom2'',''setVol'',Volume)
Shell.addEventListener(MouseEvent.MOUSE_OVER, unLoadCtlrs);
}

function unLoadCtlrs(evt):void{
?Shell.removeEventListener(MouseEvent.MOUSE_OVER, unLoadCtlrs)
?vidCtrls.gotoAndPlay(11)
}

function unLoadComplete():void {
removeChild(getChildByName(vCtlrName))
CtlrStatus = false
cc.close()
}

=================================

child frame 1

stop()
Security.allowDomain(''*'')
var cc:LocalConnection = new LocalConnection()

var Volume:Number
var adjVol:Boolean = false
this.Pause_Btn.addEventListener(MouseEvent.CLICK, vPause);
this.Play_Btn.addEventListener(MouseEvent.CLICK, vPlay);
this.Vol_Ctl.Sknob.addEventListener(MouseEvent.MOUSE_DOWN, vVol);
this.Vol_Ctl.Sknob.addEventListener(MouseEvent.MOUSE_UP, vVol);
this.Vol_Ctl.Sknob.addEventListener(MouseEvent.MOUSE_MOVE, vVol);

function setVol(Volume){
this.Vol_Ctl.Sknob.x = this.Vol_Ctl.Sldr.x + Volume
}

var cc2:LocalConnection = new LocalConnection()
cc2.allowDomain(''*'')
cc2.client = this
trace(''I just ran'')
try {
?cc2.connect(''_cCom2'')
}catch (error:Error){
?trace(''error:: already connected'');
}

function vPause(evt:MouseEvent):void{
cc.send(''_cCom'',''vidPause'')
}

function vPlay(evt:MouseEvent):void{
cc.send(''_cCom'',''vidPlay'')
}

function vVol(evt:MouseEvent):void{
if (evt.type == ''mouseDown''){
?adjVol = true
?var boundRect:Rectangle=new Rectangle(this.Vol_Ctl.Sldr.x,0,this.Vol_Ctl.Sldr.width,0);
?this.Vol_Ctl.Sknob.startDrag(false,boundRect)
}
if(evt.type == ''mouseUp'') {
?adjVol = false
?this.Vol_Ctl.Sknob.stopDrag()
}
if(evt.type == ''mouseMove''){
?if (adjVol == true){
Volume = 100 - (this.Vol_Ctl.Sldr.width - (this.Vol_Ctl.Sknob.x + this.Vol_Ctl.Sknob.width/2))-5
cc.send(''_cCom'',''vidVolume'',Volume)
?}
}
}

frame 20

//cc2.close()
cc.send(''_cCom'',''unLoadComplete'')
trace(''Last Frame'')

No comments:

Post a Comment