[Flashcoders] Manipulating and Removing loaded swf

2010-03-09 Thread Lehr, Theodore
Given the code below that I found on the web - I have 2 questions:

1) How would I manipulate the swf (i.e. change it's placement on the stage)

2) How would I remove it?


TIA

Ted

import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;

function startLoad()
{
var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest(“MouseActions.swf”);
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, 
onProgressHandler);
mLoader.load(mRequest);
}

function onCompleteHandler(loadEvent:Event)
{
addChild(loadEvent.currentTarget.content);
}
function onProgressHandler(mProgress:ProgressEvent)
{
var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
trace(percent);
}
startLoad();

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Manipulating and Removing loaded swf

2010-03-09 Thread kennethkawam...@gmail.com
Create a var outside of your functions to reference your loaded SWF:

var mc:MovieClip;

So that you can assign it to your SWF when loaded:

mc = loadEvent.target.content as MovieClip;

Then you can interact with it:

with(mc){
   x = 100;
   y = 200;
}

removeChild(mc);

etc.

-- 
Kenneth Kawamoto
http://www.materiaprima.co.uk/

On 9 March 2010 14:18, Lehr, Theodore ted_l...@federal.dell.com wrote:
 Given the code below that I found on the web - I have 2 questions:

 1) How would I manipulate the swf (i.e. change it's placement on the stage)

 2) How would I remove it?


 TIA

 Ted

 import flash.net.URLRequest;
 import flash.display.Loader;
 import flash.events.Event;
 import flash.events.ProgressEvent;

 function startLoad()
 {
 var mLoader:Loader = new Loader();
 var mRequest:URLRequest = new URLRequest(“MouseActions.swf”);
 mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
 mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, 
 onProgressHandler);
 mLoader.load(mRequest);
 }

 function onCompleteHandler(loadEvent:Event)
 {
        addChild(loadEvent.currentTarget.content);
 }
 function onProgressHandler(mProgress:ProgressEvent)
 {
 var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
 trace(percent);
 }
 startLoad();

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders