-
[RESOLVED] Help with loading swf with xml
Hi I am new looking for pointing in the right direction.
I have built a carousel currently loading images via xml. But what I am looking to have is swf loading in each block. I need help with the syntax in flash and xml as I am having trouble finding info on web.
Hope you can help!
Many thanks in advance.
-
Can you post your current code here?
-
I am a newbie, first adventure in classes and xml for a university assignment!
Ideally I want to click the carousel zoom up to user and a swf start. Hope that make sense!
here you go - xml file:
<?xml version="1.0" encoding="UTF-8"?>
<images>
<image src="img/Layer-1.png" />
<image src="img/Layer-1.png" />
<image src="img/Layer-1.png" />
<image src="img/Layer-1.png" />
<image src="img/Layer-1.png" />
<image src="img/Layer-1.png" />
<image src="img/Layer-1.png" />
<image src="img/Layer-1.png" />
<image src="img/Layer-1.png" />
<image src="img/Layer-1.png" />
</images>
Actionscript in document class:
package
{
import com.gskinner.motion.GTween;
import com.theflashblog.fp10.SimpleZSorter;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.display.Loader;
import com.leebrimelow.utils.Math2;
import fl.motion.easing.Exponential;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
public class Carousel extends Sprite
{
private var container: Sprite;
private var loader:URLLoader;
private var anglePer:Number;
private var tMan:tronMan = new tronMan();
public function Carousel()
{
init();
loadXML();
loadTronMan();
}
private function loadXML():void
{
loader = new URLLoader(new URLRequest("swfloader.xml"));
loader.addEventListener(Event.COMPLETE, createCarousel);
}
private function createCarousel (e:Event):void
{
var xml:XML = new XML(e.target.data);
var list:XMLList = xml.image;
anglePer = (Math.PI*2) / list.length();
for(var i:int=0; i<list.length(); i++)
{
var imc:imCon = new imCon();
imc.buttonMode = true;
imc.addEventListener(MouseEvent.CLICK, onClick);
var l:Loader = new Loader();
l.x = -250;
l.y = -167;
l.load(new URLRequest(list[i].@src));
imc.addChild(l);
imc.scaleX = imc.scaleY = 0.5;
imc.angle = (i*anglePer) - Math.PI/2;
imc.x = Math.cos(imc.angle) * 450;//diameter
imc.z = Math.sin(imc.angle) * 450;
imc.rotationY = 36 * -i;
container.addChild(imc);
}
}
public function loadTronMan():void{
tMan.x = 850;
tMan.y = 550;
tMan.scaleX = 1;
tMan.scaleY = 1;
addChild(tMan);
}
private function onClick(e:MouseEvent):void
{
var tw:GTween = new GTween(container, 0.8, {rotationY:Math2.toDeg(e.currentTarget.angle+Math. PI/2), z:0},
{ease:Exponential.easeInOut});
var tronManTween:Tween = new Tween(tMan, "alpha", Regular.easeOut, 1, 0, 2, true);
}
private function init():void
{
container = new Sprite();
container.x = 500;
container.y = 450;
container.z = 500;
addChild(container);
cover.addEventListener(MouseEvent.CLICK, stageClick);
this.addEventListener(Event.ENTER_FRAME, loop);
}
private function stageClick(e:MouseEvent):void
{
var tw:GTween = new GTween(container, 0.8, {rotationY:Math2.toDeg(e.currentTarget.angle+Math. PI/2), z:400},{ease:Exponential.easeInOut});
var tronManTween:Tween = new Tween(tMan, "alpha", Regular.easeOut, 0, 1, 2, true);
}
private function loop(e:Event):void
{
SimpleZSorter.sortClips(container);
}
}
}
-
Hi dawsonk i have posted my code not displaying yet 'the moderator' is doin something with it!
Thanks for the reply and hopefully answers!
-
Hi dawsonk i have posted my code not displaying yet 'the moderator' is doin something with it!
Thanks for the reply and hopefully answers!
-
code
Code below all i really want is to load swf instead of images which play on user clicks. Thanks in advance!
package
{
import com.gskinner.motion.GTween;
import com.theflashblog.fp10.SimpleZSorter;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.display.Loader;
import com.leebrimelow.utils.Math2;
import fl.motion.easing.Exponential;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
public class Carousel extends Sprite
{
private var container: Sprite;
private var loader:URLLoader;
private var anglePer:Number;
private var tMan:tronMan = new tronMan();
public function Carousel()
{
init();
loadXML();
loadTronMan();
}
private function loadXML():void
{
loader = new URLLoader(new URLRequest("swfloader.xml"));
loader.addEventListener(Event.COMPLETE, createCarousel);
}
private function createCarousel (e:Event):void
{
var xml:XML = new XML(e.target.data);
var list:XMLList = xml.image;
anglePer = (Math.PI*2) / list.length();
for(var i:int=0; i<list.length(); i++)
{
var imc:imCon = new imCon();
imc.buttonMode = true;
imc.addEventListener(MouseEvent.CLICK, onClick);
var l:Loader = new Loader();
l.x = -250;
l.y = -167;
l.load(new URLRequest(list[i].@src));
imc.addChild(l);
imc.scaleX = imc.scaleY = 0.5;
imc.angle = (i*anglePer) - Math.PI/2;
imc.x = Math.cos(imc.angle) * 450;//diameter
imc.z = Math.sin(imc.angle) * 450;
imc.rotationY = 36 * -i;
container.addChild(imc);
}
}
public function loadTronMan():void{
tMan.x = 850;
tMan.y = 550;
tMan.scaleX = 1;
tMan.scaleY = 1;
addChild(tMan);
}
private function onClick(e:MouseEvent):void
{
var tw:GTween = new GTween(container, 0.8, {rotationY:Math2.toDeg(e.currentTarget.angle+Math. PI/2), z:0},
{ease:Exponential.easeInOut});
var tronManTween:Tween = new Tween(tMan, "alpha", Regular.easeOut, 1, 0, 2, true);
}
private function init():void
{
container = new Sprite();
container.x = 500;
container.y = 450;
container.z = 500;
addChild(container);
cover.addEventListener(MouseEvent.CLICK, stageClick);
this.addEventListener(Event.ENTER_FRAME, loop);
}
private function stageClick(e:MouseEvent):void
{
var tw:GTween = new GTween(container, 0.8, {rotationY:Math2.toDeg(e.currentTarget.angle+Math. PI/2), z:400},{ease:Exponential.easeInOut});
var tronManTween:Tween = new Tween(tMan, "alpha", Regular.easeOut, 0, 1, 2, true);
}
private function loop(e:Event):void
{
SimpleZSorter.sortClips(container);
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<images>
<image src="img/Layer-1.png" />
<image src="img/Layer-1.png" />
<image src="img/Layer-1.png" />
<image src="img/Layer-1.png" />
<image src="img/Layer-1.png" />
<image src="img/Layer-1.png" />
<image src="img/Layer-1.png" />
<image src="img/Layer-1.png" />
<image src="img/Layer-1.png" />
<image src="img/Layer-1.png" />
</images>
-
Code:
private function onClick(e:MouseEvent):void {
var tw:GTween = new GTween(container, 0.8, {rotationY:Math2.toDeg(e.currentTarget.angle+Math. PI/2), z:0},{ease:Exponential.easeInOut});
var tronManTween:Tween = new Tween(tMan,"alpha",Regular.easeOut,1,0,2,true);
e.currentTarget.getChildAt(1).content.play();
}
-
Cool but
Thanks for reply i thought it maybe something to do with event target.
Just a quickie in the xml how would I link to the swf.
would it be something like <load = example.swf or 1?/>
and how would the it load to each separate swf?
Not tryed the code yet I am in work shortly.
Just need some explanation as I like to understand whats going on.
Thanks for your help, really appreciated!
-
Just replace the filenames for the pngs with the filenames for the swfs in the xml file.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|