PDA

View Full Version : SWFLoader content control


Pipan
01-05-2009, 11:35 AM
I know this have been brought up before.
But it just doesnt work.

I have a swfLoader in my Flex 3 app, which loads a simple AS3 SWF made in Flash CS3.

This swf has 3 frames on the root timeline. My goal is to control what frame to show, from my flex-app.

This is what ive tried:

//this code is called from a btn-click
var mc:MovieClip = MovieClip(myLoader.content);
mc.gotoAndStop(2);


But nothing. No error. What to do?

drkstr
01-05-2009, 07:50 PM
I don't quite understand the concept of time lines, or why you would want to use them, so I apologize if I'm way off here. What I can say is that the idea of working with time lines kind of goes against the principals of Flex coding, where you would generally take a more object oriented approach.

Instead of trying to manipulate the time line from Flex, why don't you implement a public function in your root class of the SWF that changes the view states internally.

MovieClip(myLoader.content).changeViewState(ViewSt ate.SOME_STATE);

Where ViewState.SOME_STATE is some string id for the desired scene. You can just pass the string directly of course, but this helps keep things synchronized.

If you prefer to work with the time line directly, maybe someone else can give you better advice on how to achieve this.


Best Regards,
~Aaron

Pipan
01-06-2009, 06:53 AM
That would be great drkstr.

But I just cant access any function in the flashmovie.

I've tried making a function in the first keyframe, and Flex cant access it. Throws a ReferenceError: Error #1069:.

I also tried making a main-class for the flashmovie called myMain.as and made a public function in that, but same result. Flex cant find it.

drkstr
01-06-2009, 06:43 PM
I think the accessible function should be added to scene 1 of your Flash movie.

Maybe this will help some:

http://www.onflex.org/ted/2007/11/runtime-flash-cs3flex-integration-via.php

Best Regards,
~Aaron