• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

how do i load a swf and take snapshots of that loaded swf?

New Here ,
May 10, 2010 May 10, 2010

Copy link to clipboard

Copied

hey guys, so i have a multitude of swf's that i need to load into my application, and after loading them i need to take image snapshots of those swf's, to create a slides list.

i know i can do somehting like this:

var imageSnap:ImageSnapshot = ImageSnapshot.captureImage(source);

but the problem is, how do i know if the swf has loaded all the data within it???

thanks in advance!

Views

930

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 10, 2010 May 10, 2010

Copy link to clipboard

Copied

any ideas??? anyone?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 11, 2010 May 11, 2010

Copy link to clipboard

Copied

You can listen for the 'complete' event that is dispatched by SWFLoader once all the date is loaded.

yourSWFLoader.addEventListener(Event.COMPLETE, yourHandler);

HTH,

FTQuest

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 11, 2010 May 11, 2010

Copy link to clipboard

Copied

hi!, i've tried doing all the eventlisteners... but for some reason my swf just dosent get loaded...

the code im trying is,

private function init():void{
     var swfLoader: SWFLoader = new SWFLoader();
     swfLoader.addEventListener( Event.COMPLETE, handleSWFLoaded );
     swfLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorEvent);
     Alert.show("getting data");
     try {
          swfLoader.load(new URLRequest("http://test-broadcast.apxinsider.com/content/swf/home_strengthWeb.swf") );
     } catch (error: Error) {
          trace(error.message + "     Couldn't load file !" );
          Alert.show(error.message);
     }
}

private function handleSWFLoaded( event: Event 😞 void
{
     Alert.show("in handle swf");
}

private function securityErrorEvent(event:SecurityErrorEvent):void{
     Alert.show("has security error event");
}
private function faultResult(event:FaultEvent):void{
     Alert.show(event.fault.message);
}

private function takeSnapshot(source:IBitmapDrawable):ByteArray {
     var imageSnap:ImageSnapshot = ImageSnapshot.captureImage(source);
     var imageByteArray:ByteArray = imageSnap.data as ByteArray;
     return imageByteArray;
}

now my thinking is that i can just call the takeSnapShot function once my swf has loaded in teh handelSWFLoaded function...

but for some reason when it gets to the function i get the following error:

TypeError: Error #1009: Cannot access a property or method of a null obj

is there another way i can loade my swf???

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 11, 2010 May 11, 2010

Copy link to clipboard

Copied

This error often refers to the wrong order of actions - you are trying to access something that hasn't been created yet.

For example, looking quite briefly at your code I can't see where do you call the 'takeSnapShot()' function - it's defined, but isn't called.

I'd suggest to start with the simplest version and then add the features.

For example, call the load() function before trying to get the 'Complete' event.

Simple iterative steps is the best approach.

FTQuest

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 18, 2010 May 18, 2010

Copy link to clipboard

Copied

well rightnow in my code im just trying to load the swf, im not up to the point of taking the snapshot yet since the swf hasnt been loaded yet... it gives me that error when im trying to load that swf...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 18, 2010 May 18, 2010

Copy link to clipboard

Copied

LATEST

OK.

Here is the starting point:

<?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[

import mx.controls.SWFLoader;

private var swfLdr:SWFLoader;

private function startSWF():void

{

swfLdr = new SWFLoader();

swfLdr.horizontalCenter = 0;

swfLdr.verticalCenter = 0;

swfLdr.source = "youFile.swf";

addElement(swfLdr);

}

]]>

</fx:Script>

<s:Button x="50" y="50" label="start" click="startSWF()" />

</s:Application>

If this code gives you an error, you want to check that the swf address is correct and the swf itself is not corrupted.

From that point,  you start build your custom functionality - one step at a time!

Sorry, HTH,

FTQuest

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines