Adobe Dreamweaver Forums



Last 10 THreads :         Print Documentation (Last Post : Peter Grainge - Replies : 3 - Views : 5 )           »          Array with For Loop Basics (Last Post : David Stiller - Replies : 3 - Views : 4 )           »          How to align XML loading text to right (Last Post : loki2357 - Replies : 0 - Views : 1 )           »          Help with navigation (Last Post : NedWebs - Replies : 1 - Views : 2 )           »          left join won't work in query of query? (Last Post : Amm85 - Replies : 0 - Views : 1 )           »          Truncate text? (Last Post : Handycam - Replies : 0 - Views : 1 )           »          security violation connecting to socket (Last Post : SoxFan33 - Replies : 1 - Views : 2 )           »          Please point me to the correct topic section of thisForum (Last Post : GillyWilly - Replies : 10 - Views : 11 )           »          Library is missing names from splitter bar (Last Post : Mad Dog - Replies : 5 - Views : 6 )           »          pdf question (Last Post : Joseph Kunz - Replies : 2 - Views : 3 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 10-01-2008, 02:59 PM
strayhand
 
Posts: n/a
Diggs:
Default Loading Sounslides inside of Flex

I need a little assistance correctly loading an external swf file into my flex
application.

I'm not sure where I've gone wrong, but at this point I'm assuming that it's a
path error of some sort. The swf file that I'm trying to load is actually a
http://soundslides.com/ presentation which was built using AS2 and relies on a
flashvar called "project" to feed it the necessary xml document. The flex
application is being inserted dynamically into the page using a Jquery plugin.

Here's a live version of what I'm trying to accomplish. It was built using
Jquery and Soundslides, but due to some unforeseen browser complications I've
decided to rebuilt the entire widget using Flex instead of Jquery.

Example 1: Original version using Jquery + Soundslides - Look at the
sliding student views section.
http://www.plu.edu/admission/first-year

Example 2: Flex + Soundslides - This is a work in progress, and it's
the version that I need help with.
http://dev.plu.edu/admission/home-sv-widget.php

So basically in example 2 I've got a sequence of jpgs that are set to slide
forward at a given time interval. When a user clicks on one of the jpgs the
mouse event calls the following method:

Code:
// Load Soundslide
public function loadSoundslide (e:MouseEvent):void
{
// Get project id from button id
var projID:int = currentImage;

// Create path for loader
var swfPath:String = basePath + playerPath + "?project=" +
basePath + projectsArray[projID];

//Alert.show(swfPath);

// Load Soundslide swf
swfRequest.url = swfPath;
swfLoader.load(swfRequest);
wrapper.addChild(swfLoader);

}
I thought that this would work but it doesn't seem to be doing the trick. Any
thoughts? One more question. Say I get this to work. Would I just call another
method for unloading the swf? Attached is my project so that you have a sense
of what I'm working on. I'm also going to post a
zipfile]http://dev.plu.edu/admission/admission-studentviews.zip containing more
of the project, the student-views content is rather large so I'm only going to
include one of them.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
backgroundAlpha="0"
horizontalScrollPolicy="off"
creationComplete="init();"
width="380"
height="264">

<mx:Style source="sv.css" />

<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.controls.Button;
import mx.controls.Image;
import mx.effects.Move;

// XML
public var xml:XML;

// Image Mask
[Bindable]
[Embed(source="assets/images/mask-sv.png")]
private var maskPng:Class;

// Image variables
[Bindable]
public var currentImage:int = 1;
[Bindable]
public var nextImage:int;
[Bindable]
public var prevImage:int = 1;

// Project variables
public var projectsArray:Array = new Array();

// Base path
public var basePath:String;

// Playback options
public var playerPath:String;
public var slideDuration:int;

// Swf Loader
public var swfRequest:URLRequest = new URLRequest();
public var swfLoader:Loader = new Loader();

// Misc
public var interval:uint;
[Bindable]
public var alertDump:String;

// Intialize
public function init():void
{
// Setup XML
var xmlDefault:String = "assets/student-views/home.xml";
var xmlPath:String = Application.application.parameters.xmlpath;

if(xmlPath != null)
{
xmlDefault = xmlPath;
}

var loader:URLLoader = new URLLoader(new URLRequest(xmlDefault));
loader.addEventListener(Event.COMPLETE, onLoaded);
}

// XML has been loaded
public function onLoaded (e:Event):void
{
// Assign the XML data to a variable
xml = new XML(e.target.data);

// Setup options
basePath = xml.setup.site.basePath;
playerPath = xml.setup.playback.playerPath;
slideDuration = xml.setup.playback.slideDuration;

// Create images/buttons
var idCount:uint = 1;

for each (var property:XML in xml.items.item)
{
// Build imageStack item

// Setup image
var imageItem:Image = new Image();
imageItem.id = "img" + idCount;
imageItem.source = property.image;
imageItem.setActualSize(380, 240);
imageItem.useHandCursor = true;
imageItem.buttonMode = true;
imageItem.addEventListener(MouseEvent.CLICK, stopInterval);
imageItem.addEventListener(MouseEvent.CLICK, loadSoundslide);

// Add image to imageStack (HBOX)
imageStack.addChild(imageItem);

// Build button item

// Setup button
var buttonItem:Button = new Button();
buttonItem.id = "btn" + idCount;
buttonItem.name = "btn" + idCount;
buttonItem.label = idCount.toString();
buttonItem.width = 20;
buttonItem.height = 20;
buttonItem.useHandCursor = true;
buttonItem.buttonMode = true;
buttonItem.addEventListener(MouseEvent.CLICK, stopInterval);
buttonItem.addEventListener(MouseEvent.CLICK, moveHorizontalBoxMouse);

// Add button to vbox
buttonSet.addChild(buttonItem);

// Build Project Array
projectsArray[idCount] = property.project;

// Increment variables
idCount++;
}

// Update button state
updateButton();

// Start imageStack loop
interval = setInterval(advancePlayer, slideDuration);
}

// Advance player
public function advancePlayer ():void
{

if(currentImage <= imageStack.numChildren -1)
{
nextImage = currentImage + 1;
}
else
{
nextImage = 1;
}

// Move imageStack
moveHorizontalBox(nextImage);

}

// Stop interval
public function stopInterval (e:MouseEvent):void
{
clearInterval(interval);
}

// Update button
public function updateButton ():void
{

// Set previoius button state to out
Button(buttonSet.getChildByName("btn" + prevImage)).dispatchEvent(new
MouseEvent(MouseEvent.ROLL_OUT));

// Match button state to current image
Button(buttonSet.getChildByName("btn" + currentImage)).dispatchEvent(new
MouseEvent(MouseEvent.ROLL_OVER));
}

// Move Horizontal Box (Mouse)
public function moveHorizontalBoxMouse (e:MouseEvent):void
{
var imgID:int = int(e.target.id.substr(3,1));
moveHorizontalBox (imgID);
}

// Move Horizontal Box
public function moveHorizontalBox (id:int):void
{
// Determine x
var x:int = (id - 1) * 380 * -1;

// Move imageStack to x position
var move:Move = new Move();
move.end();
move.xTo = x;
move.duration = 2000;
move.target = imageStack;
move.play();

// Update previous image
prevImage = currentImage;

// Update current image
currentImage = id;

// Update button
updateButton();

}

// Load Soundslide
public function loadSoundslide (e:MouseEvent):void
{
// Get project id from button id
var projID:int = currentImage;

// Create path for loader
var swfPath:String = basePath + playerPath + "?project=" +
basePath + projectsArray[projID];

//Alert.show(swfPath);

// Load Soundslide swf
swfRequest.url = swfPath;
swfLoader.load(swfRequest);
wrapper.addChild(swfLoader);

}

]]>
</mx:Script>

<!-- Begin Wrapper -->
<mx:Canvas id="wrapper" height="264" width="380" cacheAsBitmap="true"
mask="{imageMask}" horizontalScrollPolicy="off">

<!-- Begin Image Stack -->
<mx:HBox id="imageStack" height="240" horizontalGap="0"
horizontalScrollPolicy="off" >

</mx:HBox>
<!-- End Image Stack -->

<!-- Test Labels -->
<!--
<mx:Label text="Current Image + {currentImage}" y="10" />
<mx:Label text="Next Image + {nextImage}" y="25" />
<mx:Label text="Previous Image + {prevImage}" y="40" />
<mx:Label text="Alert Dump + {alertDump}" y="55" />
-->
<!-- Test Labels -->

<!-- Begin Navigation -->
<mx:Canvas id="navigation" styleName="navigation" width="380" height="24"
x="0" y="240">

<!-- Begin Label -->
<mx:Label text="Student Views" x="12" y="4" />
<!-- End Label -->

<!-- Begin Button Set -->
<mx:HBox id="buttonSet" styleName="button-set" horizontalGap="2"
horizontalAlign="center" width="380" height="21" x="0" y="3">

</mx:HBox>
<!-- End Button Set -->

</mx:Canvas>
<!-- End Navigation -->

</mx:Canvas>
<!-- End Wrapper -->

<!-- Begin Image Mask -->
<mx:Image id="imageMask" source="{maskPng}" cacheAsBitmap="true" width="380"
height="264" />
<!-- End Image Mask-->

</mx:Application>



Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 08:08 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk