0

I do slide presentations on iPad via Flex IOS packager 4.6. The slides are swf's that have to be dynamically loaded at runtime because they change daily. Can't compile them in.

My slides load fine with animations and look great - but the animations on each slide loop. I can't stop them. When I decompile slide swf's I see the stop() commands there on each one. IOS just blows by these stop()'s though (PC doesn't). Interesting that the swf's load at all on IOS. I'd have thought the stop()'s would have prevented that. They do load though. IOS just doesn't honor the stop()'s. Animations play beautifully. Can I stop them some other way? Maybe externally from my main Flex code? Is there a way to stop a Flash animation without stop()? Maybe build the animation differently? Another product I've seen has solved this issue so I know a solution exists. When they play animations on IOS they stop.

Robert
  • 828
  • 2
  • 13
  • 28
  • Are you using the Loader class? Can you post the code you are using to load the SWFs? – eterps Dec 14 '11 at 23:21
  • Using Flex 4.6 SWFLoader. Just setting the source property on it with URL path to slides. Pretty simple. Issue probably isn't in there. SWF's are loading fine. – Robert Dec 15 '11 at 15:01
  • Then in AS, slide.source = URL; – Robert Dec 15 '11 at 15:08

1 Answers1

0

Try making a reference to the MovieClip once the SWF is loaded using the complete event of SWFLoader. Your MovieClip will be accessible from event.target.content in the complete event handler. You can then call stop() on the MovieClip directly, and see if that works. See the example below:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
              >


    <fx:Script>
        <![CDATA[

            public var mc:MovieClip;

            protected function swfloader1_completeHandler(event:Event):void
            {
                mc = event.target.content as MovieClip;
                mc.addEventListener(Event.ENTER_FRAME,newFrame);
                mc.stop();
            }

            protected function newFrame(event:Event):void
            {
                if( mc.currentFrame == mc.totalFrames )
                {
                    mc.stop();
                    mc.removeEventListener( Event.ENTER_FRAME, newFrame );
                }
            }

            protected function button1_clickHandler(event:MouseEvent):void
            {
                            mc.gotoAndPlay(1);
            }

        ]]>
    </fx:Script>

    <s:SWFLoader source="[REFERENCE TO YOUR SWF]" complete="swfloader1_completeHandler(event)"/>
    <s:Button label="Play" click="button1_clickHandler(event)" />

</s:Application>
eterps
  • 14,198
  • 4
  • 35
  • 46
  • Interesting. Let me give it a shot. – Robert Dec 15 '11 at 17:10
  • Two different results depending on the FlashBuilder project type used. When loaded into a Flex mobile project, which is what I need, it throws a runtime exception on line #15 (mc.addEventListener(Event.ENTER_FRAME,newFrame) with the loading of each new slide. mc comes up null. When loading into a regular Flex project this exception is not thrown, but the play button doesn't restart the clip playback, which is what I think it's supposed to do. That would indicate control of the clip. Did you have a different result? As is, I can't get to run on the iPad due to the null pointer exception. – Robert Dec 15 '11 at 22:46
  • Ah, forgot to reset the movieclip to the first frame when the button is clicked. Not sure about the iOS situation, I'll try it in a Flex mobile project and see what happens. – eterps Dec 16 '11 at 03:38
  • I see what the mobile exception is. It's an AS3 (AVM2 movie) vs AS2 (AVM1 movie) issue. I'm loading AS2 swf's. That's what my PPT/swf converter produces. mc comes up null because AS2 swf's are not MovieClip's. They are actually an older type - AVM1Movie. Just changing the type in your code doesn't get it because an AVM1Movie is a different animal. In fact it's real difficult to talk to AS2 movies from AS3. Local connections attempt to bridge this divide but I can't get them to work yet. Other option is to find a PPT to swf converter that produces AS3 output. Haven't found that yet. – Robert Dec 16 '11 at 05:59