What am i doing wrong, SWF File
Copy link to clipboard
Copied
Hello all,
This is driving me crazy!
I have made a flex app, that imports a swf file, converts it to a movie clip, and then pulls which frame to display from a XML file, that is checked every second. This works fine when using the following SWF file - http://davidtest.webcastglobal.com/swf/flash.swf
Although when i tried re-creating my own example - http://davidtest.webcastglobal.com/swf/flash2.swf
my flex app fails to respond correctly. THe swf file just loops thru all the frames in one go, and fails to take into account the XML file pointing at what frame to look at, and fails to look at the HTTPS service.
Ok so here is an example of the app with both examples embeded.
http://davidtest.webcastglobal.com/swfwork/Main.html - This is using the working swf file,
http://davidtest.webcastglobal.com/swfbroke/Main.html - This is using the swf file that i have created.
THe code that i am using to achieve this is as follows -
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="load()">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
[Bindable] public var dataDump:String = "datadump";
[Bindable] private var myText:String
private var flashMovie:MovieClip;
private function initMovie():void{
flashMovie = loader.content as MovieClip;
}
private function load():void{
flashMovie.gotoAndStop(myText)
getImage.send();
setTimeout(load,1000);
}
private function handleImage(event:ResultEvent):void
{
myText = event.result.framelocation;
}
]]>
</mx:Script>
<mx:SWFLoader id="loader" source="flash2.swf" complete="initMovie()" x="-9" y="-3"/>
<mx:Button label="Next" click="flashMovie.nextFrame()" x="78" y="405"/>
<mx:Button label="Previous" click="flashMovie.prevFrame()" x="0" y="405"/>
<mx:Button label="4" click="flashMovie.gotoAndPlay(7)" x="156" y="405"/>
<mx:HTTPService id="getImage" result="handleImage(event)" url="http://davidtest.webcastglobal.com/change.xml" method="POST">
<mx:request xmlns="">
<dataDumping>
{dataDump}
</dataDumping>
</mx:request>
</mx:HTTPService>
<mx:Text x="817" y="10" text="Total: {myText}" width="157"/>
</mx:Application>
My question is when creating my own swf file, what am i doing wrong? Flex clearly isnt interacting with it in the same way as the original swf, by the way, this swf was taken from a tutorial.
If anyone could point me in a direction or offer help on this i would be thankful. Im sure i am just missing something out when i create my swf in flash
Copy link to clipboard
Copied
is the only difference (between the working and non-working tests) in your flex code, the source parameter of your SWFLoader?
in particular, what's calling load() (the first time)? it looks like there should be a call in initMovie().
Copy link to clipboard
Copied
Yep, the only difference between the workin and not working code is the source of the SWF loader.
The load() function is called in the applicationComplete(). Which runs it once the whole flex app is loaded.
It leaves me to believe that i am creating my SWF in flash wrong.
Is there anything spedific i need to do in order for flex to communicate with it ? In terms of changing the frame?
Thanks for the reply.
Copy link to clipboard
Copied
i don't know flex so you may be correct but even if you are you need to be sure load() is called after initMovie() is called. in flash there's a trace() function that i'd use to confirm both are called and called in the correct order. do you have a similar debugging tool in flex?
Copy link to clipboard
Copied
Ok, i have re-worked my code, It now calls initMovie() first and then load().
I get the same problem.
I am almost 100% sure its the way i have created my swf file.
Could you talk me through how you would create it ?
Thanks again
Copy link to clipboard
Copied
1. your swf file must be published for as3.
2. it should consist of a main timeline with more than 1 frame.
3. it needs as many frames as you're going to reference in the xml.
4. that main timeline should contain objects on its frames so you can see when the main timeline is on one frame vs another referenced in your xml.
that's it. those are the only requirements of the swf.
have you confirmed that intiMovie() is called first and then load()? if so, how did you confirm?
Copy link to clipboard
Copied
Hello, thanks for the info on making the SWF file, although i am still having problems making the swf talk to flex.
I have changed when the load() function is being called, i linkied it to a button instead, and let the app run for a few minutes before hitting the button and nothing, i would assume that the intiMovie had fully been loaded within a couple of minutes.
I am doing soemthing completely wrong when i create a swf file and i dont know what.
Copy link to clipboard
Copied
with all programming you need debugging tools. i'm certain flex has some but i don't know what they are.
does flex have something comparable to the actionscript trace() function (or the php echo/print function or the asp Response.Write etc)?

