PDA

View Full Version : SWF Loader and MovieClip problems


davidhopkins
05-12-2010, 10:55 AM
Hello all.
I am using the following code to import a swf file that has a number or frames. When i hit next or previous it moves either to the next or previous frame.

The code is as follows

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" applicationComplete="load()">
<mx:Script>
<![CDATA[
private var flashMovie:MovieClip;

private function initMovie():void{
flashMovie = loader.content as MovieClip;
}
private function load():void{
flashMovie.stop()
}
]]>
</mx:Script>
<mx:SWFLoader id="loader" source="flash.swf" complete="initMovie()"/>
<mx:Button label="Next" click="flashMovie.nextFrame()"/>
<mx:Button label="Previous" click="flashMovie.prevFrame()"/>
</mx:Application>

This works fine, everything is as i want, apart from i want what ever SWF frame is being displayed, to be displayed on all web browsers that have the page open.

I imagine i would be able to use an XML file, and pull the frame being displayed from that and have it check the XML file every couple of seconds ?

Although saying that im not 100% sure on how to achieve this.

Can anyone offer some help please?

davidhopkins
05-12-2010, 12:37 PM
Ok, So i have been working on this concerpt a little more.

I have created a HTTPS service,

<mx:HTTPService id="getImage" result="handleImage(event)" url="change.xml" method="POST">
<mx:request xmlns="">
<dataDumping>
{dataDump}
</dataDumping>
</mx:request>
</mx:HTTPService>

This pulling data from the XML file where i plan to store the frame that needs to be displayed on of the SWF file.

I checked that the HTTP service was working by using the function

private function handleImage(event:ResultEvent):void
{
img1.source = event.result.imagelocation;
}

And as i expected when i change the xml file, the image changes.

However i created a variable

private var i:String = "test";

And planned to have the HTTP service change the value of this value. I assumed it would be the same code as what i previously used,so used the following code

private function handleImage(event:ResultEvent):void
{
var i = event.result.imagelocation;
}

However using this, it dosent update the value of the variable being displayed in the text box,

<mx:Text x="817" y="10" text="Total: {i}" width="157"/>



Can anyone see where i am going wrong ?

Inigoesdr
05-15-2010, 11:17 PM
Do you have "i" set to bindable with the meta tag?

[Bindable]
private var i:String = "test";

Also, try making "i" public, and tracing the value of "i" & the return from the HTTPService inside of your function that is updating the value.