PDA

View Full Version : can't pause the external loaded swf movie



potatoes
August 25th, 2009, 04:24 AM
Hello, i'm new with AS3, still migrating from AS2 to AS3

i have a movieclip on timeline, and then i addchild ( a container ) to load
an external swf movie on it. Then i want to have a button so i can pause the loaded swf movie.

And my problem is, i can access to it, i can change the properties like the alpha, but i can just stop or pause it.

Can anyone help me? cause i'm frustrated now :hair:
i've been search and testing many script, but i still can make it work
it just a simple task right? i can do it quickly with AS2 :hugegrin:

Thanks 4 ur help :}

thatsasif
August 25th, 2009, 04:27 AM
Man put the code so that someone can find the actual problem.

potatoes
August 25th, 2009, 04:54 AM
Ok, i have a button named st, and loader1 load the "ling.swf"
the swf loaded, and can play, but i cant make it stop when i click on st button



stop();

var ling:URLRequest = new URLRequest("ling.swf");
var loader1:Loader = new Loader();
loader1.load(ling);
this.addChild(loader1);

loader1.alpha = 0.5; // this is working ..
loader1.stop(); // error occured...

st.addEventListener(MouseEvent.CLICK, stopp);
function stopp(e:MouseEvent):void
{
stop();
MovieClip(loader1).stop();
}

thatsasif
August 25th, 2009, 12:20 PM
DO it this way.....



stop();

var testCLip:MovieClip;
var ling:URLRequest = new URLRequest("ling.swf");
var loader1:Loader = new Loader();
loader1.contentLoaderInfo.addEventListener(Event.C OMPLETE, onCompleteHandler);
loader1.load(ling);

function onCompleteHandler(loadEvent:Event)
{
testCLip = loadEvent.currentTarget.content;
this.addChild(testCLip);
testCLip.alpha = 0.5;
testCLip.stop();
}


stage.addEventListener(MouseEvent.CLICK, stopp);
function stopp(e:MouseEvent):void
{
stop();
testCLip.stop();
}

potatoes
August 25th, 2009, 10:03 PM
Hola, Thank's a lot, it works.. :emb:
never think about onCompleteHandler function
and loadEvent.currentTarget.content
it's really diffrent with AS2, on how we comunicate with the object :hair:

Thank's :thumb:

potatoes
August 26th, 2009, 05:08 AM
I try to make a movie playback that can load another movie, it also can pause or play, but where should i put the removeChild on my script below, when i want to load new movie? it's all working, but it display Error:

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at panelZ_fla::MainTimeline/playScene()
at panelZ_fla::MainTimeline/rightClick()

i have 3 button on timeline
pp_Btn, left_Btn and Right_Btn

here's the code


var testCLip:MovieClip;
var sc_1:URLRequest = new URLRequest("sc_1.swf");
var sc_2:URLRequest = new URLRequest("sc_2.swf");
var sc_3:URLRequest = new URLRequest("sc_3.swf");
var container:Loader = new Loader();
var jlh:Number = new Number();
var pp:Boolean = true;

jlh = 1;

function playScene()
{
if (jlh == 1)
{
container.load(sc_1);
removeChild(testCLip);
trace("1");
}
else if (jlh == 2)
{
container.load(sc_2);
removeChild(testCLip);
trace("2");
}
else if (jlh == 3)
{
container.load(sc_3);
removeChild(testCLip);
trace("3");
}
else if (jlh <= 1)
{
jlh = 1;
}
else
{
jlh = 3;
}
}

right_btn.addEventListener(MouseEvent.MOUSE_DOWN, rightClick);
function rightClick(e:MouseEvent):void
{
jlh++;
playScene();
//container.unload();
}

left_btn.addEventListener(MouseEvent.MOUSE_DOWN, leftClick);
function leftClick(e:MouseEvent):void
{
jlh--;
playScene();
//container.unload();
}

container.contentLoaderInfo.addEventListener(Event .COMPLETE, onCompleteHandler)
container.load(sc_1);
function onCompleteHandler(evt:Event):void
{
testCLip = evt.currentTarget.content;
addChild(testCLip);
//testCLip.alpha = 0.1;
testCLip.play();
playScene();
}

ppBtn.addEventListener(MouseEvent.CLICK, ppState);
function ppState(event:MouseEvent):void
{
if (pp)
{
testCLip.stop();
trace("if");
ppBtn.gotoAndStop("pause");
pp = false;
}
else
{
testCLip.play();
trace("else");
ppBtn.gotoAndStop("play");
pp = true;
}
}Thanks's for helping :}

potatoes
August 26th, 2009, 09:23 PM
Before i can pause the swf movie, i was able to load the movie normally,
when i press next and back button it can load perfectly with no errors

but after i can pause and stop the movie, the movie loader comes trouble
as i said on above... :cantlook:

Can anyone help me? Thank's a lot for helping :}

thatsasif
August 27th, 2009, 01:57 AM
Check the comments in the below code...



function onCompleteHandler(evt:Event):void
{
testCLip = evt.currentTarget.content;
testCLip.name = "testCLip"; //Add this line to your code
addChild(testCLip);
//testCLip.alpha = 0.1;
testCLip.play();
playScene(); // Why are you calling this function again here. It will continously loop.
}


Next remove the child first then make the loader load....



if (jlh == 1)
{
removeChild(getChildByName("testCLip"));// Change this line also
container.load(sc_1);
trace("1");
}

potatoes
August 27th, 2009, 04:01 AM
Ok, i'll try it Mr.Asif (-: Thanks a lot

is that any diffrent AS3 on CS3 and CS4? cause i got diffrent result with the same code

:hair: