Counter in SWF
Is there a way to put a hit counter into a flash video? Or is that something that would need to go into the HTML file? Also I need it to be invisible, but be able to check it somehow...hah is any of this possible?
Thanks!
cmo
you can put a counter directly in flash but you'll need some server-side coding to save and update the hit count.
Similar Messages
-
Count and limit the accesses to a browser based swf
I have a swf file imbedded in a HTML. Acceess to the file are controlled by passwords, stored in a XML-file
I want to limit the number of accesses for each visitor to let us say 10 visits. How do I count (and store) the number of logons for each visitor?
SharedObject works only at clienside, but iI want i serverside. The "easy" way would be to save the number of accesses for each visitor in a text-file but Flash and save... I hvave tried ExternalInterface calls, PHP etc and etc, but cant find a way that works. This is the last obstacle in a huge project. Please help.If using a MySQL database is an option, here's a link to a tutorial that deals with all the various aspects of that.
http://www.gotoandlearn.com/play?id=20 -
Imported SWFs have max slide count?
I have an animation slide in my captivate presentation.
On the animation slide is a SWF file (created by Captivate)
that contains 19 slides.
When I run the SWF in standalone mode it works fine.
If I run the new presentation with the SWF imported, the
animation slide stops after 12 slides are shown in the SWF file on
that slide.
Is there any way I can fix this?Try extending the play-time of the animation-object and see
if that helps ... -
HOW can I make a .SWF default load after its first load?
When you have the SAME parent API on every page of an (X)HTML website, can a .SWF tell itself to load from a default position when a website user navigates to different HTML pages?
Here's my parent API as it stands:
http://www.playingthepoet.com/
HOW can you tell the .SWF to load from a default position once the .SWF has loaded a first time? AND from any page of the website, not just the Home page? This is an advanced .SWF networking issue. And I'm not sure if the best solution is a Javascript of if there's a direct AS3 programming solution.
The blurs and fade-ins are a bunch of timer variables and timer event methods timer event listeners. I want that intro ONLY ONCE. And NOT every time a user changes HTML pages. Please help, and MANY thanks for your time!!
NTHi ,
You can set a variable say "count" on stage composition ready -
sym.setVariable("count" , 0);
On stage click , you keep checking the value of this variable -
if(sym.getVariable("count") == 5)
sym.$("Symbol_2").show();
//Here "Symbol_2" is the next button that you want to appear on screen(which is initially invisible) when the symbol_1 is clicked say 5 times.
Now, on click of a button , you keep updating the variable count -
var countnew = sym.getVariable("count");
countnew = countnew+1;
sym.setVariable("count" , countnew);
Attaching the sample for reference.
Thanks and Regards,
Sudeshna Sarkar -
How to loop an swf a set number of times?
I need to loop a banner animation a set number of times, then
get it to gotoandstop on a final frame. I know in the past I could
use:
counter++; if (counter<5) { gotoAndPlay (1); }
At least for the looping part (don't even know yet about the
stop pon a particular frame part).
but now in Flash 8 I can't get my test swf to do that using
this statement. Am I missing something? (Of course, obviously I am
or I wouldn't be here!)This works for me as well, but i don't want it to jump to the
final still frame. i need mine to loop three times, then plan
through to the frame i want, stopping there. the frame i want is
not the final frame in the swf. it is somewhere in the middle.
does that make sense? -
How to unload externally loaded swf which contains 3D Carousel?
Hello to all
I am learning AS3 and have been taking on various tutorials found on the net. While learning about AS3 I came across a lesson on http://tutorials.flashmymind.com/2009/05/vertical-3d-carousel-with-actionscript-3-and-xml/ titled "Vertical 3D Carousel with AS3 and XML".
I completed the tutorial and all worked fine so I then wanted to load the swf into a existing project. The loading of the swf goes fine and when I unload my loader it is removed but only visually as in my output panel in flash CS5 I get an error as follows
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at carousel_c_fla::MainTimeline/moveCarousel()
this error repeats over and over again slowing my swf movie.
So does this mean my main flash movie trying to still play / find my unloaded 3D Carousel?
If so how do I unload remove all the AS3 that is trying to run from the 3D Carousel?
I have included the AS3 below from the tutorial page and I understand that this is what I have to remove to "break free" from the 3D Carousel swf when it is unloaded. This is where I am stuck as my knowledge of AS3 is limited - Can you guys / girls help?
//Import TweenMax
import com.greensock.*;
//The path to the XML file (use your own here)
// old var from tutorial - var xmlPath:String = "http://tutorials.flashmymind.com/XML/carousel-menu.xml";
var xmlPath:String = "carousel-menu.xml";
//We'll store the loaded XML to this variable
var xml:XML;
//Create a loader and load the XML. Call the function "xmlLoaded" when done.
var loader = new URLLoader();
loader.load(new URLRequest(xmlPath));
loader.addEventListener(Event.COMPLETE, xmlLoaded);
//This function is called when the XML file is loaded
function xmlLoaded(e:Event):void {
//Make sure that we are not working with a null variable
if ((e.target as URLLoader) != null ) {
//Create a new XML object with the loaded XML data
xml = new XML(loader.data);
//Call the function that creates the menu
createMenu();
//We need to know how many items we have on the stage
var numberOfItems:uint = 0;
//This array will contain all the menu items
var menuItems:Array = new Array();
//Set the focal length
var focalLength:Number = 350;
//Set the vanishing point
var vanishingPointX:Number = stage.stageWidth / 2;
var vanishingPointY:Number = stage.stageHeight / 2;
//We calculate the angleSpeed in the ENTER_FRAME listener
var angleSpeed:Number = 0;
//Radius of the circle
var radius:Number = 128;
//This function creates the menu
function createMenu():void {
//Get the number of menu items we will have
numberOfItems = xml.items.item.length();
//Calculate the angle difference between the menu items (in radians)
var angleDifference:Number = Math.PI * (360 / numberOfItems) / 180;
//We use a counter so we know how many menu items have been created
var count:uint = 0;
//Loop through all the <button></button> nodes in the XML
for each (var item:XML in xml.items.item) {
//Create a new menu item
var menuItem:MenuItem = new MenuItem();
//Calculate the starting angle for the menu item
var startingAngle:Number = angleDifference * count;
//Set a "currentAngle" attribute for the menu item
menuItem.currentAngle = startingAngle;
//Position the menu item
menuItem.xpos3D = 0;
menuItem.ypos3D = radius * Math.sin(startingAngle);
menuItem.zpos3D = radius * Math.cos(startingAngle);
//Calculate the scale ratio for the menu item (the further the item -> the smaller the scale ratio)
var scaleRatio = focalLength/(focalLength + menuItem.zpos3D);
//Scale the menu item according to the scale ratio
menuItem.scaleX = menuItem.scaleY = scaleRatio;
//Position the menu item to the stage (from 3D to 2D coordinates)
menuItem.x = vanishingPointX + menuItem.xpos3D * scaleRatio;
menuItem.y = vanishingPointY + menuItem.ypos3D * scaleRatio;
//Add a text to the menu item
menuItem.menuText.text = item.label;
//Add a "linkTo" variable for the URL
menuItem.linkTo = item.linkTo;
//We don't want the text field to catch mouse events
menuItem.mouseChildren = false;
//Assign MOUSE_OVER, MOUSE_OUT and CLICK listeners for the menu item
menuItem.addEventListener(MouseEvent.MOUSE_OVER, mouseOverItem);
menuItem.addEventListener(MouseEvent.MOUSE_OUT, mouseOutItem);
menuItem.addEventListener(MouseEvent.CLICK, itemClicked);
//Add the menu item to the menu items array
menuItems.push(menuItem);
//Add the menu item to the stage
addChild(menuItem);
//Assign an initial alpha
menuItem.alpha = 0.3;
//Add some blur to the item
TweenMax.to(menuItem,0, {blurFilter:{blurX:1, blurY:1}});
//Update the count
count++;
//Add an ENTER_FRAME listener for the animation
addEventListener(Event.ENTER_FRAME, moveCarousel);
//This function is called in each frame
function moveCarousel(e:Event):void {
//Calculate the angle speed according to mouseY position
angleSpeed = (mouseY - stage.stageHeight / 2) * 0.0002;
//Loop through the menu items
for (var i:uint = 0; i < menuItems.length; i++) {
//Store the menu item to a local variable
var menuItem:MenuItem = menuItems[i] as MenuItem;
//Update the current angle of the item
menuItem.currentAngle += angleSpeed;
//Calculate a scale ratio
var scaleRatio = focalLength/(focalLength + menuItem.zpos3D);
//Scale the item according to the scale ratio
menuItem.scaleX=menuItem.scaleY=scaleRatio;
//Set new 3D coordinates
menuItem.xpos3D=0;
menuItem.ypos3D=radius*Math.sin(menuItem.currentAngle);
menuItem.zpos3D=radius*Math.cos(menuItem.currentAngle);
//Update the item's coordinates.
menuItem.x=vanishingPointX+menuItem.xpos3D*scaleRatio;
menuItem.y=vanishingPointY+menuItem.ypos3D*scaleRatio;
//Call the function that sorts the items so they overlap each other correctly
sortZ();
//This function sorts the items so they overlap each other correctly
function sortZ():void {
//Sort the array so that the item which has the highest
//z position (= furthest away) is first in the array
menuItems.sortOn("zpos3D", Array.NUMERIC | Array.DESCENDING);
//Set new child indexes for the item
for (var i:uint = 0; i < menuItems.length; i++) {
setChildIndex(menuItems[i], i);
//This function is called when a mouse is over an item
function mouseOverItem(e:Event):void {
//Tween the item's properties
TweenMax.to(e.target, 0.1, {alpha: 1, glowFilter:{color:0xffffff, alpha:1, blurX:60, blurY:60},blurFilter:{blurX:0, blurY:0}});
//This function is called when a mouse is out of an item
function mouseOutItem(e:Event):void {
//Tween the item's properties
TweenMax.to(e.target, 1, {alpha: 0.3, glowFilter:{color:0xffffff, alpha:1, blurX:0, blurY:0},blurFilter:{blurX:1, blurY:1}});
//This function is called when an item is clicked
function itemClicked(e:Event):void {
//Navigate to the URL that's assigned to the menu item
var urlRequest:URLRequest=new URLRequest(e.target.linkTo);
navigateToURL(urlRequest);Hi Ned thanks for the reply,
Ok so I have a button in my main movie that loads the external swf
stop();
var my_loader:Loader = new Loader();
var my_btn:Button = new Button();
var my_pb:ProgressBar = new ProgressBar();
my_pb.source = my_loader.contentLoaderInfo;
my_btn.addEventListener(MouseEvent.CLICK,startLoading);
function startLoading(e:MouseEvent):void{
my_loader.load(new URLRequest("carousel.swf"));
addChild(my_pb);
my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishloading);
function finishloading(e:Event):void{
addChild(my_loader);
my_loader.addEventListener("killMe",
killLoadedClip);
removeChild(my_pb);
function killLoadedClip(e:Event):void {
my_loader.removeEventListener("killMe",
killLoadedClip);
my_loader.unloadAndStop();
removeChild(my_loader);
Then I have a button in my loaded swf that closes the loader
This is spread over 2 frames
Frame1
function closeIt(e:MouseEvent):void {
parent.dispatchEvent(newEvent("killMe"));
Frame 2
back_btn.addEventListener(MouseEvent.CLICK, closeIt);
Frame 2 also holds all the code for the carousel
Thanks for your time and help in advance people ; ) -
Loading multiple consecutive .swf files in Flash 8
I have a question and hope that someone may be able to help;
this might be a piece of cake for you...
I have a container .fla movie and would like to load
consecutive external .swf files. Right now I have a play button
triggering the loading of the next movie, but what I would REALLY
like is a smooth transition from .swf to .swf using a listener so
that the next .swf will load once the previous one has finished. I
have a counter which determines the next .swf in order.
So far, my code is this:
Counter:
stop();
//SETUP OUR COUNTER
var mcCounter:Number = 0;
//THIS BLOCK IS ONLY TO HANDLE THE LOADER AND THE FIRST
MOVIE, movie0.swf
var myMCL:MovieClipLoader = new MovieClipLoader();
var loadListener
bject = new Object();
myMCL.addListener(loadListener);
myMCL.loadClip("movie" + mcCounter + ".swf", 6);
loadListener.onLoadComplete = function():Void {
_level0.play();
//-------------------------<CLIP
LOADERS>------------------------------\\
function loadNextClip():Void {
if(mcCounter < 6) {
mcCounter++;
var nextMCL:MovieClipLoader = new MovieClipLoader();
nextMCL.addListener(this);
nextMCL.loadClip("movie" + mcCounter + ".swf",6);
//LOADS PREVIOUS CLIP , WON"T GO PAST ZERO
function loadPrevClip():Void {
if(mcCounter > 0) {
mcCounter--;
var prevMCL:MovieClipLoader = new MovieClipLoader();
prevMCL.addListener(this);
prevMCL.loadClip("movie" + mcCounter + ".swf",6);
//-------------------------</CLIP
LOADERS>------------------------------\\
Any suggestions? I appreciate ANY help you can offer. I have
been unsuccessfully looking for hours online, and can't find any
examples, although it doesn't seem as if it should be the hardest
thing in the world.
Thanks!You need a monitor to know when one movie clip has completed
play. A simple
monitor could be adding onEnterFrame handler to the
container_mc when
MovieClipLoader onComplete or onInit is fired. In that
handler a test to see
when the loaded clip's _currentframe == the loaded clip"s
_totaframes.
Ex:
this.createEmptyMovieClip("container_mc",
this.getNextHighestDepth());
container_mc._x = 0;
container_mc._y = 0;
var swfNumber:Number = 0;
var swfNumberMax:Number = 25;
var swfNamePrefix = "MovieClipLoaderDetectEndOfPlay_Movie";
var mclListener
bject = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip)
target_mc.startTimer = getTimer();
mclListener.onLoadComplete = function(target_mc:MovieClip)
target_mc.completeTimer = getTimer();
mclListener.onLoadInit = function(target_mc:MovieClip)
var timerMS:Number = target_mc.completeTimer -
target_mc.startTimer;
target_mc.play();
target_mc.onEnterFrame = function()
trace(this._currentframe)
if (this._currentframe == this._totalframes)
trace("Load Next Swf")
loadNextSwf()
var container_mcl:MovieClipLoader = new MovieClipLoader();
container_mcl.addListener(mclListener);
function loadNextSwf()
swfNumber++;
if (swfNumber <= swfNumberMax)
var swfSuffix = ((swfNumber<10)?"0" :"") + swfNumber;
container_mcl.loadClip(swfNamePrefix + swfSuffix + ".swf",
container_mc);
loadNextSwf()
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!
"dragonlilly" <[email protected]> wrote in
message
news:[email protected]...
I have a question and hope that someone may be able to help;
this might be
a
piece of cake for you...
I have a container .fla movie and would like to load
consecutive external
.swf
files. Right now I have a play button triggering the loading
of the next
movie, but what I would REALLY like is a smooth transition
from .swf to .swf
using a listener so that the next .swf will load once the
previous one has
finished. I have a counter which determines the next .swf in
order.
So far, my code is this:
Counter:
stop();
//SETUP OUR COUNTER
var mcCounter:Number = 0;
//THIS BLOCK IS ONLY TO HANDLE THE LOADER AND THE FIRST
MOVIE, movie0.swf
var myMCL:MovieClipLoader = new MovieClipLoader();
var loadListener
bject = new Object();
myMCL.addListener(loadListener);
myMCL.loadClip("movie" + mcCounter + ".swf", 6);
loadListener.onLoadComplete = function():Void {
_level0.play();
//-------------------------<CLIP
LOADERS>------------------------------\\
function loadNextClip():Void {
if(mcCounter < 6) {
mcCounter++;
var nextMCL:MovieClipLoader = new MovieClipLoader();
nextMCL.addListener(this);
nextMCL.loadClip("movie" + mcCounter + ".swf",6);
//LOADS PREVIOUS CLIP , WON"T GO PAST ZERO
function loadPrevClip():Void {
if(mcCounter > 0) {
mcCounter--;
var prevMCL:MovieClipLoader = new MovieClipLoader();
prevMCL.addListener(this);
prevMCL.loadClip("movie" + mcCounter + ".swf",6);
//-------------------------</CLIP
LOADERS>------------------------------\\
Any suggestions? I appreciate ANY help you can offer. I have
been
unsuccessfully looking for hours online, and can't find any
examples,
although
it doesn't seem as if it should be the hardest thing in the
world.
Thanks! -
Loading a remote SWF via SWFLoader Issue
I have a simple flex app which loads an external XML into an
arrayCollection using HTTPService send method. This works fine as
both a stand-alone, or when loaded into it's parent as a LOCAL file
via the SWFLoader tag. However, when I place this child file onto a
remote server and try to load it into the parent which resides on
my desktop, the ArrayCollection default resultFormat of the send
method triggers the following runtime error (listed below). I don't
think it's a sandbox issue because when I change result format to
e4x, it works fine remotely. I've been hitting a wall on this for
days now... Any insight would be greatly appreciated and thanks to
all in advance!!!
PARENT SWF (resides on local desktop)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="vertical" initialize="initData()">
<mx:Script>
<![CDATA[
public var baseURL:String;
public function initSWF(swfURL:String):void {
remote_swf.load(swfURL);
public function initData():void
baseURL = "
http://blahblahblah";
Security.allowDomain(baseURL);
]]>
</mx:Script>
<!-- WORKS when loading child swf LOCALLY -->
<mx:Button label="Load LOCAL SWF APP"
click="initSWF('remoteSWF.swf')"/>
<!-- DOES NOT WORK when loading child swf REMOTELY -->
<mx:Button label="Load REMOTE SWF APP" click="initSWF('
http://blahblahblah/remoteSWF.swf')"/>
<!-- LOADER -->
<mx:SWFLoader height="100%" width="100%" id="remote_swf"
autoLoad="false" visible="true" scaleContent="false"/>
</mx:Application>
CHILD SWF (resides on remote server)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="getXMLData()">
<mx:HTTPService id="myTeams" url="
http://blahblahblah/xml/myXML.xml"/>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
public function getXMLData():void
Alert.show(Security.sandboxType);
myTeams.send();
]]>
</mx:Script>
<mx:Label text="THIS IS THE LOADED SWF WHICH HAS JUST
PERFORMED A SEND ON HTTP SERVICE TO CREATE ARRAY
COLLECTION"></mx:Label>
</mx:Application>
------------ RUNTIME ERROR ---------------------------------
ArgumentError: Error #1063: Argument count mismatch on
Object/
http://adobe.com/AS3/2006/builtin::hasOwnProperty().
Expected 0, got 2.
at mx.rpc.xml::SimpleXMLDecoder/decodeXML()
at mx.rpc.xml::SimpleXMLDecoder/decodeXML()
at mx.rpc.xml::SimpleXMLDecoder/decodeXML()
at mx.rpc.http::HTTPService/
http://www.adobe.com/2006/flex/mx/internal:rocessResult()
at mx.rpc::AbstractInvoker/
http://www.adobe.com/2006/flex/mx/internal::resultHandler()
at mx.rpc::Responder/result()
at mx.rpc::AsyncRequest/acknowledge()
at :irectHTTPMessageResponder/completeHandler()
at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio
n()
at flash.events::EventDispatcher/dispatchEvent()
at
flash.net::URLLoader/flash.net:URLLoader:nComplete()After further investigations, it appears that the problem might be, due the fact that in the remote (loaded) swf, the following is null:
var sm:ISystemManager = ISystemManager(SystemManagerGlobals.topLevelSystemManagers[0]);
sm.swfBridgeGroup <----- equals null
I tried creating the swfBridgeGroup in the local (loading) swf, but the loaded one still thinks it is null.
Any ideas? -
SWF created in Flash MX 7 won't play in browser w/Flash Player 9
I just noticed that my website, which I made from a template
from templatesheaven.com, isn't playing in Flash Player 9 in a
browser. It plays in the standalone player for some reason, but
when I look at it on the web, it shows just the count-in (or
whatever it's called, the pre-load), but stops when the counter
hits 99% and the action never starts. The website is at:
www.gwhitty.com
I built it using Flash MX 7, but for all I know the template
was made using Swish, which apparently causes problems with Flash
Player 9. Anyone have any other ideas? Still plays fine in FP7, so
I'm stumped. If I open my .fla file in Flash 9 and then export,
will that likely fix the problem? Any ideas appreciated...annabeth wrote:
> I have just uploaded a website using Flash 8 with the
swf embedded into an html
> page. I am on Mac OSX and it plays perfectly in IE,
Opera and Firefox. Other
> people trying to access the site from a PC say the swf
content won't play - the
> page comes up blank. They have downloaded the Flash 9
player - is this the
> problem? I have the Flash 8 player.
URL ?
Regards
Urami
Happy New Year guys - all the best there is in the 2006 :)
<urami>
http://www.Flashfugitive.com
</urami>
<web junk free>
http://www.firefox.com
</web junk free> -
How to load a pdf/xls/swf files in to a adf:popup
hi
my requirement is to open a pdf/xls/swf in a popup. howcan i get a poup with pdf/xls/swf files . presently i am using a servlet.I set the content type in the servlet as application/pdf and so on..
I am getting data as byte stream from the data base.know how to give this bytestream/response object of the servlet to the panel window.
In a popup i placed panel window.the struture is:
<af:popup>
<af:panelwindow>
</af:panelwindow>
</af:popup>
thanks in advance
Srikanth.V
Message was edited by:
user631950Hi,
I have a similar requirement where I need to show the preview of a document in a popup.
I have a button and I added "af:fileDownloadActionListener" into the button, then I wrote the following code in my bean for the downloadactionlistener:
public void showPreviewDownloadListener(FacesContext facesContext,
java.io.OutputStream outputStream) throws IOException{
DCIteratorBinding agr = getBindingsForDCB().findIteratorBinding("xyz");
Row row = ag.getRowSetIterator().getCurrentRow();
String fileName = (String)row.getAttribute("FileName");
String fileType = (String)row.getAttribute("FileType");
BlobDomain file = (BlobDomain)row.getAttribute("FileData");
try {
InputStream inputStream = file.getBinaryStream();
byte[] buf = new byte[1024];
int count;
while ((count = inputStream.read(buf)) >= 0) {
outputStream.write(buf, 0, count);
inputStream.close();
outputStream.flush();
outputStream.close();
file.closeInputStream();
docPreviewInlineFrame.setSource(fileName);
//ADFUtils.setEL("#{pageFlowScope.docSource}", "../"+fileName);
ADFUtils.invokePopup(docPreviewPopup,true);
catch(IOException ioex) {
ioex.printStackTrace();
when I'm clicking my button, all it does is open a popup to view/download the while.
My own popup (with a dialog and an internalFram in it) does not get invoked at all.
Also the file that I'm referring is from DB, can anyone also suggest me how to set the source for the inline frame if the file is from DB?
Thanks in advance,
Swapna -
Hi,
I currently using v2.25 mac bookflip. The problem I am facing is that the onMouseDown and onMouseUp works well in swf. However, when the I upload to the web server and localhost. The chances for them to work are 50-50.
The truth is I was unable to drag the pages and I have no ideas what to do, and where to the start from can anyone tell me. what to do next?
To call the MouseUp. Basically, One swf (preloader)> load another swf (main menu and selection of books) > load another swf to read the book flip which my mouseDown is here.
Here is all the codes from mac v2.25 bookflip function. I only change the setPages function to make it load dynamically.
Notes, the problem is not sometimes. It many times.
//do not change these values: ----------------------------------------------------------------------------------------- ----------------------------
_global.mcnt = 0; //counter (used on a page where is an animation)
var gpage:Number= 0; //gotoPage No
var gflip:Boolean= false; //gotoPage flip
var gdir:Number= 0; //goto direction
var gskip:Boolean= false; //skip pages
var gtarget:Number= 0; //target when skipping
var aflip:Boolean= false; //auto flip
var flip:Boolean= false; //pageflip
var flipOff:Boolean= false; //terminateflip
var flipOK:Boolean= false; //good flip
var hflip:Boolean= false; //hardflip (the cover of the book)
var rotz:Number= -30; //hardflip max y difference
var preflip:Boolean= false; //corner flip status
var ctear:Boolean= false; //actual page status
var tear:Boolean= false;
var teard:Number= 0;
var tlimit:Number= 80;
var removedPages:Array= new Array(); //list of removed pages!
mpx = 0, mpy = 0; //mousepos at click
sx = sy = 0; //startpoint when flipping
var x:Number= 0; //mouse x,y
var y:Number= 0;
var ax:Number= 0; //auto x,y
var ay:Number= 0;
var acnt:Number= 0;
var aadd:Number= 0;
var aamp:Number= 0;
AM= Math.PI/180;
//initializing pages
function reset()
pages.p4.page._x = -pw;
pages.p4._x = pw;
pages.p1.page._x = -pw;
pages.p1._x = 0;
pages.flip.p2.page._x = -pw;
pages.flip.p2._x = pw;
pages.flip.p3.page._x = -pw;
pages.flip.p3._x = 0;
pages.p0.page._x = -pw;
pages.p0._x = 0;
pages.p5.page._x = -pw;
pages.p5._x = pw;
pages.pLL.page._x = -pw;
pages.pLL._x = 0;
pages.pLR.page._x = -pw;
pages.pLR._x = pw;
pages._visible= true;
pages.p1.page.pf.ph.mask._width= pages.flip.p2.page.pf.ph.mask._width= pages.flip.p3.page.pf.ph.mask._width= pages.p4.page.pf.ph.mask._width= pw;
pages.p1.page.pf.ph.mask._height= pages.flip.p2.page.pf.ph.mask._height= pages.flip.p3.page.pf.ph.mask._height= pages.p4.page.pf.ph.mask._height= ph;
//NEW THEORY UNPROVEN
/* pages.p1.page.pf.ph.attachMovie("pagesPreloader_mc", "pagesPreloader_mc", 0, {_visible:false});
pages.p4.page.pf.ph.attachMovie("pagesPreloader_mc", "pagesPreloader_mc", 0, {_visible:false});*/
pages.p1.page.pf.ph.pagesPreloader_mc._x= pages.p4.page.pf.ph.pagesPreloader_mc._x = pw/2;
pages.p1.page.pf.ph.pagesPreloader_mc._y= pages.p4.page.pf.ph.pagesPreloader_mc._y= ph/2;
pages.p0.page.pf.ph.mask._width= pages.p5.page.pf.ph.mask._width= pw;
pages.p0.page.pf.ph.mask._height= pages.p5.page.pf.ph.mask._height= ph;
pages.pgrad._visible = pages.mask._visible = pages.flip._visible = false;
pages.flip.p3mask._width = pages.pgmask._width = pw*2;
pages.flip.p3mask._height = pages.pgmask._height = ph;
pages.center._height = ph+2*lcaddy;
pages.flip.fmask.page.pf._width = pw;
pages.center._width = 6;
pages.flip.fmask.page.pf._height = ph;
pages.mask._width = pages.mask._height = pages.pgrad._height = pages.flip.p3shadow._height = pages.flip.flipgrad._height = 2*Math.sqrt(ph*ph+pw*pw);
pageNumber = new Array();
for(i=0;i<=(maxpage+1);i++) pageNumber[i] = i;
//////////////////////////////////////////////////////////////////////////////////MouseUP
//initializing mouse click handler
mousecontroll = new Object();
mousecontroll.onMouseDown = function()
if(flip && !aflip)
flipOK = false;
if(sx<0 && pages._xmouse>0) flipOK = true;
if(sx>0 && pages._xmouse<0) flipOK = true;
flipOff = true;
flip = false;
else if((flipOff || aflip || !canflip) && !preflip)
else if(!preflip)
var oox = ox;
var ooy = oy;
var osx = sx;
var osy = sy;
hit = hittest(); //hittest
if(hit)
startsnd(1); //Sound
flip = true;
flipOff = false;
tear = false; //not tearing yet
ox = sx = hit*pw;
pages.flip.setMask(pages.mask);
mpx = pages._xmouse, mpy = pages._ymouse;
oef();
//_quality = "MEDIUM"; //it is the place to degrade image quality while turning pages if the performance is too low.
else
{ //if preflipping
startsnd(1); //Sound
flip = true;
flipOff = false;
tear = false; //not tearing yet
aflip = preflip = false;
mpx = pages._xmouse, mpy = pages._ymouse;
oef();
mousecontroll.onMouseUp = function()
if(flip && !tear)
if((Math.abs(pages._xmouse)>(pw-afa) && Math.abs(pages._ymouse)>(ph/2-afa) && Math.abs(pages._xmouse-mpx)<afa) || preflip)
flip = false;
preflip = false;
autoflip();
startsnd(2); //sound
else if(!preflip)
preflip = false;
flipOK = false;
if(sx<0 && pages._xmouse>0) flipOK = true;
if(sx>0 && pages._xmouse<0) flipOK = true;
flipOff = true;
flip = false;
if(flipOK) startsnd(2); //sound
function hittest()
{ //hittest at mouse clicks, if click is over the book -> determining turning direction
var x=pages._xmouse;
var y=pages._ymouse;
var pmh = ph/2;
if(y<=pmh && y>=-pmh && x<=pw && x>=-pw)
var r = Math.sqrt(x*x+y*y);
var a = Math.asin(y/r);
var y = Math.tan(a)*pw;
if(y>0 && y>ph/2) y = ph/2;
if(y<0 && y<-ph/2) y = - ph/2;
oy = sy = y;
r0 = Math.sqrt((sy+ph/2)*(sy+ph/2)+pw*pw);
r1 = Math.sqrt((ph/2-sy)*(ph/2-sy)+pw*pw);
pageN = eval("pages.flip.p2.page");
pageO = eval("pages.flip.p3");
offs = -pw;
pages.flip.fmask._x = pw;
if(x<-(pw-clickarea) && page>0)
{ //>-----> flip backward
pages.flip.p3._x = 0;
hflip = checkCover(page,-1);
setPages(page-2,page-1,page,page+1);
ctear = pageCanTear[page];
return -1;
if(x>(pw-clickarea) && page<maxpage)
{ //<-----< flip forward
pages.flip.p3._x = pw;
hflip = checkCover(page,1);
setPages(page,page+2,page+1,page+3);
ctear = pageCanTear[page+1];
return 1;
} else return 0; //wrong click
function checkCover(p,dir)
if(hcover)
if(dir>0)
if(p==(maxpage-2) || p==0) return true;
else
if(p==maxpage || p==2) return true;
return false;
function corner()
var x = Math.abs(pages._xmouse);
var y = Math.abs(pages._ymouse);
if(x>(pw-afa) && x<pw && y>(ph/2-afa) && y<(ph/2))
return true;
return false;
function oef()
_global.mcnt++; //main counter incrase (need for some page effect);
if(!flip && corner()) //corner mouseover
preflip = true;
if(!autoflip()) preflip = false;
if(preflip && !corner())
preflip = false;
flip = false;
flipOK = false;
flipOff = true;
getm();
if(aflip && !preflip)
y = (ay += (sy-ay)/(gflip? gs: ps ));
acnt += aadd;
ax -= aadd;
if(Math.abs(acnt)>pw)
flipOK = true;
flipOff = true;
flip = false;
aflip = false;
if(flip) //page turning is in progress
if(tear) {
x = tox;
y = (toy += teard);
teard *= 1.2;
if(Math.abs(teard)>1200) {
flipOff = true;
flip = false;
} else {
x = (ox += (x-ox)/(gflip? gs: ps ));
y = (oy += (y-oy)/(gflip? gs: ps ));
calc(x,y); //positioning pages and shadows
if(flipOff)
{ //terminating page turning effect... (comlplete turning... dropped on the other side)
if(flipOK || tear)
x = (ox += (-sx-ox)/(gflip? gs: es ));
y = (oy += (sy-oy)/(gflip? gs: es ));
calc(x,y);
if(x/-sx > 0.99 || tear) //we are done with turning, so stop all turning issue
flip = false;
flipOK = flipOff = false;
pages.pgrad._visible = pages.flip._visible = false;
//_quality = "BEST"; //if quality is decrased during turning effect, you must reset its default value
if(tear) //if tear: remove page
removePage((sx<0)? page: page+1);
page += (sx<0)? -2: 0;
else
page += (sx<0)? -2: 2; //and tourning pages at pagenumber level...
if(gskip) page = gtarget;
setPages(page,0,0,page+1);
tear = false;
if(gpage>0 && !gskip) //gotoflip active -> is there another flipping left?
gpage--;
autoflip();
startsnd(0); //sound
else gflip = gskip = false;
else //terminating page turning effect... (incomlplete turning... dropped on the dragged side)
x = (ox += (sx-ox)/3);
y = (oy += (sy-oy)/3);
calc(x,y);
if(x/sx > 0.99) //we are done with turning, so stop all turning issue
flip = false;
flipOff = false;
aflip = false;
pages.pgrad._visible = pages.flip._visible = false;
//_quality = "HIGH"; //if quality is decrased during turning effect, you must reset its default value
setPages(page,0,0,page+1); //no change at pagenumbers
function calc(x,y) //positioning pages and shadows by x,y reference points
if(hflip)
{ //hardflip
var xp = (sx<0)? -x: x;
if(xp>0)
sp2._visible = false;
sp3._visible = true;
scalc(sp3,x);
else
sp3._visible = false;
sp2._visible = true;
scalc(sp2,x);
pages.flip.setMask(null);
pages.flip._visible = true;
pages.flip.fgrad._visible = false;
pages.flip.p2._visible = pages.flip.p3._visible = false;
return;
} else pages.flip.fgrad._visible = true;
//normal flipping process
rr0 = Math.sqrt((y+ph/2)*(y+ph/2)+x*x);
rr1 = Math.sqrt((ph/2-y)*(ph/2-y)+x*x);
if((rr0>r0 || rr1>r1) && !tear)
{ // we can tear off pages now
// so reference points must be recalculated
if(y<sy)
var a = Math.asin((ph/2-y)/rr1);
y = (ph/2-Math.sin(a)*r1);
x = (x<0)? -Math.cos(a)*r1: Math.cos(a)*r1;
if(y>sy)
if((sx*x)>0) y = sy, x = sx;
else y = sy, x = -sx;
if((rr1-r1)>tlimit && ctear)
teard = -5;
tear = true;
tox = ox = x;
toy = oy = y;
else
var a = Math.asin((y+ph/2)/rr0);
y = Math.sin(a)*r0-ph/2;
x = (x<0)? -Math.cos(a)*r0: Math.cos(a)*r0;
if(y<sy)
if((sx*x)>0) y = sy, x = sx;
else y = sy, x = -sx;
if((rr0-r0)>tlimit && ctear)
teard = 5;
tear = true;
tox = ox = x;
toy = oy = y;
if((sx<0 && (x-sx)<10) || (sx>0 && (sx-x)<10))
if(sx<0) x = -pw+10;
if(sx>0) x = pw-10;
//calculating flipping process
pages.flip._visible = true;
pages.flip.p3shadow._visible = pages.pgrad._visible = !tear;
pages.flip.p2._visible = pages.flip.p3._visible = true;
//equation of the line
var vx = x-sx;
var vy = y-sy;
var a1 = vy/vx;
var a2 = -vy/vx;
cx = sx+(vx/2);
cy = sy+(vy/2);
//trigonometriai szamitasok
//calculating rotation of the page, and the masks
var r = Math.sqrt((sx-x)*(sx-x)+(sy-y)*(sy-y));
var a = Math.asin((sy-y)/r);
if(sx<0) a = -a;
ad = a/AM; //in degree
pageN._rotation = ad*2;
r = Math.sqrt((sx-x)*(sx-x)+(sy-y)*(sy-y));
rl = (pw*2);
if(sx>0)
{//flip forward
pages.mask._xscale = 100;
nx = cx-Math.tan(a)*(ph/2-cy);
ny = ph/2;
if(nx>pw)
nx = pw;
ny = cy+Math.tan(Math.PI/2+a)*(pw-cx);
pageN.pf._x = -(pw-nx);
pages.flip.fgrad._xscale = (r/rl/2)*pw;
pages.pgrad._xscale = -(r/rl/2)*pw;
pages.flip.p3shadow._xscale = (r/rl/2)*pw;
else //flip backward
pages.mask._xscale = -100;
nx = cx-Math.tan(a)*(ph/2-cy);
ny = ph/2;
if(nx<-pw)
nx = -pw;
ny = cy+Math.tan(Math.PI/2+a)*(-pw-cx);
pageN.pf._x = -(pw-(pw+nx));
pages.flip.fgrad._xscale = -(r/rl/2)*pw;
pages.pgrad._xscale = (r/rl/2)*pw;
pages.flip.p3shadow._xscale = -(r/rl/2)*pw;
pages.mask._x = cx;
pages.mask._y = cy;
pages.mask._rotation = ad;
pageN.pf._y = -ny;
pageN._x = nx+offs;
pageN._y = ny;
pages.flip.fgrad._x = cx;
pages.flip.fgrad._y = cy;
pages.flip.fgrad._rotation = ad;
pages.flip.fgrad._alpha = (r>(rl-50))? 100-(r-(rl-50))*2: 100;
pages.flip.p3shadow._x = cx;
pages.flip.p3shadow._y = cy;
pages.flip.p3shadow._rotation = ad;
pages.flip.p3shadow._alpha = (r>(rl-50))? 100-(r-(rl-50))*2: 100;
pages.pgrad._x = cx;
pages.pgrad._y = cy;
pages.pgrad._rotation = ad+180;
pages.pgrad._alpha = (r>(rl-100))? 100-(r-(rl-100)): 100;
pages.flip.fmask.page._x = pageN._x;
pages.flip.fmask.page._y = pageN._y;
pages.flip.fmask.page.pf._x = pageN.pf._x;
pages.flip.fmask.page.pf._y = pageN.pf._y;
pages.flip.fmask.page._rotation = pageN._rotation;
function scalc(obj,x) //hardflip calc
if(x<-pw) x=-pw;
if(x>pw) x=pw;
var a = Math.asin( x/pw );
var rot = a/AM/2;
var xs = 100;
var ss = 100*Math.sin( rotz*AM );
x = x/2;
var y = Math.cos(a)*(pw/2)*(ss/100);
placeImg(obj, rot, ss, x, y)
pages.pgrad._visible = pages.flip._visible = true;
pages.pgrad._xscale = x;
pages.pgrad._alpha = pages.flip.p3shadow._alpha = 100;
pages.flip.p3shadow._xscale = -x;
pages.flip.p3shadow._x = 0;
pages.flip.p3shadow._y = 0;
pages.flip.p3shadow._rotation = 0;
pages.pgrad._x = 0;
pages.pgrad._y = 0;
pages.pgrad._rotation = 0;
function placeImg(j, rot, ss, x, y)
var m = Math.tan( rot*AM );
var f = Math.SQRT2/Math.sqrt(m*m+1);
var phxs = 100*m;
var phRot = -rot;
var xs = 100*f;
var ys = 100*f;
j.ph.pic._rotation = 45;
j.ph.pic._xscale = (phxs<0)? - xs: xs;
j.ph.pic._yscale = ys*(100/ss);
j.ph._rotation = phRot;
j.ph._xscale = phxs;
j._yscale = ss;
j._x = x;
j._y = y;
j._visible = true;
function setPages(p1,p2,p3,p4)
//attach the right page "image" at the right place
p0 = p1-2; //pages for transparency...
p5 = p4+2;
if(p0<0) p0=0;
if(p5>maxpage) p5=0;
if(p1<0) p1=0; //visible pages
if(p2<0) p2=0;
if(p3<0) p3=0;
if(p4<0) p4=0;
globalP1= p1;
globalP2= p2;
globalP3= p3;
globalP4= p4;
if(checkPageLoaded[globalP1-1] == false && checkPageLoaded[globalP4-1] == false)
trace("Preloader 3");
checkPageLoaded[globalP1-1]= true;
checkPageLoaded[globalP4-1]= true;
var cCounterTwo:Number= globalP1- (canPreLoadNumber+ 1);
var cTwoPerPage:Number= cCounterTwo+ 2;
cCountPage(cCounterTwo, cTwoPerPage, globalP1, globalP4);
pages.p1.page.pf.ph.pic._x = -(p1-1)*pw;
pages.p1.page.pf.ph._y = -ph/2;
if(hflip) //hardflip pages are specials!!!
pages.flip.hfliph.sp2._visible = true;
pages.flip.hfliph.sp3._visible = true;
sp2 = eval("pages.flip.hfliph.sp2");
sp2.ph.pic.pic._x = -(p2-1)*pw - pw/2;
sp3 = eval("pages.flip.hfliph.sp3");
sp3.ph.pic.pic._x = -(p3-1)*pw - pw/2;
else
pages.flip.hfliph.sp2._visible = false;
pages.flip.hfliph.sp3._visible = false;
sp2 = eval("pages.flip.p2.page.pf.ph.pic");
pages.flip.p2.page.pf.ph.pic._x = -(p2-1)*pw;
pages.flip.p2.page.pf.ph._y = -ph/2;
sp3 = eval("pages.flip.p3.page.pf.ph.pic");
pages.flip.p3.page.pf.ph.pic._x = -(p3-1)*pw;
pages.flip.p3.page.pf.ph._y = -ph/2;
pages.p4.page.pf.ph.pic._x = -(p4-1)*pw;
pages.p4.page.pf.ph._y = -ph/2;
soundDuration = containerArray[page+1].voice.duration/1000;
checkPage(p4,p2,p3,containerArray[arrayCounter].voice,buttonName,dotName,txtName);
transcript_mc.removeMovieClip();
function resetPages()
setPages(page,0,0,page+1);
function autoflip()
{ //start auto flip!
if(!aflip && !flip && !flipOff && canflip)
{ //only when all conditions fits our needs
acnt = 0
var pmh = ph/2;
aamp = Math.random()*pmh-(ph/4);
var x= gflip? (gdir*pw)/2: ((pages._xmouse<0)? -pw/2: pw/2);
var y= pages._ymouse;
if(y>0 && y>pmh) y = pmh;
if(y<0 && y<-pmh) y = - pmh;
oy = sy = y;
ax = (pages._xmouse<0)? -pmh: pmh;
ay = y*Math.random(); //page turnig style randomizing
offs = -pw;
var hit = 0;
if(x<0 && page>0)
pages.flip.p3._x = 0;
hflip = (hcover && gskip)? (page==maxpage || gtarget==0): checkCover(page,-1);
ctear = pageCanTear[page];
if(!(preflip && hflip)) {
if(gskip) setPages(gtarget,gtarget+1,page,page+1);
else setPages(page-2,page-1,page,page+1);
hit = -1;
if(x>0 && page<maxpage)
pages.flip.p3._x = pw;
hflip = (hcover && gskip)? (page==0 || gtarget==maxpage): checkCover(page,1);
ctear = pageCanTear[page+1];
if(!(preflip && hflip))
if(gskip) setPages(page,gtarget,page+1,gtarget+1);
else setPages(page,page+2,page+1,page+3);
hit = 1;
if(hflip && preflip)
hit = 0;
preflip = false;
return false;
if(hit)
anim._visible = false;
flip = true;
flipOff = false;
ox = sx = hit*pw;
pages.flip.setMask(pages.mask);
aadd = hit*(pw/(gflip? 5:10 )); //autoflip takes 10 frames to be done!!!
aflip = true;
pages.flip.fmask._x = pw;
if(preflip)
oy = sy = (pages._ymouse<0)? -(ph/2): (ph/2);
r0 = Math.sqrt((sy+ph/2)*(sy+ph/2)+pw*pw);
r1 = Math.sqrt((ph/2-sy)*(ph/2-sy)+pw*pw);
pageN = eval("pages.flip.p2.page");
pageO = eval("pages.flip.p3");
oef();
return true;
} else return false;
function getm()
{ //get x,y reference points depending of turning style: manual/auto
if(aflip && !preflip)
x = ax;
y = ay;
else
x = pages._xmouse;
y = pages._ymouse;
function getPN(i)
{//get the right page number
if(i==0) return 0;
var find = false;
for(j=1;j<=maxpage;j++)
if(i==pageNumber[j])
i=j;
find = true;
break;
if(find) return i;
else return -1;
function removePage(i)
i = (Math.floor((i-1)/2)*2)+1;
removedPages.push(pageNumber[i], pageNumber[i+1]);
for(j=(i+2);j<=(maxpage+1);j++)
pageOrder[j-2]=pageOrder[j];
pageCanTear[j-2]=pageCanTear[j];
pageNumber[j-2]=pageNumber[j];
maxpage -= 2;Do you mean it's firing when you click Edit?. I've replicated your code as below and it worked, try to remove the OnRowCommand run a build and then add the it again:
protected void Page_Load(object sender, EventArgs e)
BindGridwithDummy();
protected void GridMainCat_RowCommand(object sender, GridViewCommandEventArgs e)
string catID = e.CommandArgument.ToString();
if (e.CommandName == "Edt" && e.CommandArgument != null)
if (e.CommandName == "Dlt")
private void BindGridwithDummy()
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new System.Data.DataColumn("Test", typeof(String)));
dr = dt.NewRow();
dr[0] = "A dummy Data"; //Adds the Dummy Data in the Row
dt.Rows.Add(dr);
// Show the DataTable values in the GridView
GridView1.DataSource = dt;
GridView1.DataBind();
<asp:GridView ID="GridView1" runat="server" OnRowCommand="GridMainCat_RowCommand">
<Columns>
<asp:BoundField DataField="Test" />
<asp:TemplateField>
<HeaderTemplate>
Button</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton Style="padding: 4px;" ID="lnkDel" CommandName="Dlt" runat="server"
CausesValidation="false" Text="Delete" CommandArgument="1" OnClientClick="javascript:return('Are you sure, do you want to delete Record??')"></asp:LinkButton><br />
<asp:LinkButton ID="lnkEdit" runat="server" Text="Edit" CausesValidation="false"
CommandName="Edt" CommandArgument="2" Style="padding: 4px;"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView> -
Download SWFs to cell, run in main SWF
Hey there people!
We've got a tricky one for you guys, really hope you can help
us out.
We're developing a Flash Lite 2.1 application mainly for cell
phones, and to start off we're testing on a Nokia N73.
The application needs to be able to load SWFs which has been
downloaded alternatively pushed to the phone and saved locally on
the phone.
There seems to be a number of challenges:
1) How can we address a separate SWF locally from a main SWF
on a cell phone?
2) Any suggestions on how to distribute the separate SWFs to
the phone? Push of some sort? Install SIS-file that places the
separate SWFs in correct folder that main SWF can read from?
3) Is it possible to write to an XML file locally on a cell
phone?
4) The application needs to list the separate SWF-files, how
can this be done?
As I mentioned, hope you guys can help us out!
Thanks, Andreasciao,
1. you can use loadMovie function to load movies localy. but
you should be using relative paths i.e. more_swfs/new.swf
2. yes, you can make update SIS files with new/updated
content, and install in same folder as the previous install. for
more on update SIS, read the makesis help in the Nokia S60 SDK
3. yes, but using a third-party .exe helper program. but i
would suggest using shareobeject to save your data. SO can save
native AS objects string/number/xml
4. you can do it in two ways, 1) put a list.txt in your sis,
and update sis files with updated list.txt 2) you can create a
sequential loading loop, ie loadVariables("content_" add counter
add ".txt") and check if the content_n.txt loads its data, if
there's no data in last loaded text file, it means that file
doesn't exist. so you should not loadmovie content_n.swf and break
the loop
note: this will show user an error message "unable to load
data", and use can abort/exit the app at this point... so, i will
recomend the 1st one ;)
best regards,
// chall3ng3r // -
Need help with gallery showing .jpg AND .swf
Hi all,
I have an image gallery that loads images and swf-files from an XML-file. The .jpg's load and display just fine, but the .swf files won't show. The data is loaded though. Any help is greatly appreciated!
Thanks so much in advance,
Dirk
My XML file looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
- <slideshow>
<image src="photo1.jpg" time="1" title="test" desc="test" artist="sabre" link="" target="_self" />
<image src="photo2.jpg" time="3" title="test2" desc="test2desc" artist="sabre" link="" target="_self" />
<image src="flash1.swf" time="2" title="test3" desc="test3desc" artist="sabre" link="" target="_self" />
</slideshow>
And the AS3:
// import tweener
import caurina.transitions.Tweener;
// delay between slides
const TIMER_DELAY:int = 5000;
// fade time between slides
const FADE_TIME:Number = 1;
// flag for knowing if slideshow is playing
var bolPlaying:Boolean = true;
// reference to the current slider container
var currentContainer:Sprite;
// index of the current slide
var intCurrentSlide:int = -1;
// total slides
var intSlideCount:int;
// timer for switching slides
var slideTimer:Timer;
// slides holder
var sprContainer1:Sprite;
var sprContainer2:Sprite;
// slides loader
var slideLoader:Loader;
// current slide link
var strLink:String = "";
// current slide link target
var strTarget:String = "";
// url to slideshow xml
var strXMLPath:String = "xml.xml";
// slideshow xml loader
var xmlLoader:URLLoader;
// slideshow xml
var xmlSlideshow:XML;
function initSlideshow():void {
// hide buttons, labels and link
mcInfo.visible = false;
btnLink.visible = false;
var request:URLRequest = new URLRequest (strXMLPath);
request.method = URLRequestMethod.POST;
var variables:URLVariables = new URLVariables();
variables.memberID = root.loaderInfo.parameters.memberID;
request.data = variables;
var loader:URLLoader = new URLLoader (request);
loader.addEventListener(Event.COMPLETE, onXMLLoadComplete);
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(request);
// create new timer with delay from constant
slideTimer = new Timer(TIMER_DELAY);
// add event listener for timer event
slideTimer.addEventListener(TimerEvent.TIMER, nextSlide);
// create 2 container sprite which will hold the slides and
// add them to the masked movieclip
sprContainer1 = new Sprite();
sprContainer2 = new Sprite();
mcSlideHolder.addChild(sprContainer1);
mcSlideHolder.addChild(sprContainer2);
// keep a reference of the container which is currently
// in the front
currentContainer = sprContainer2;
// add event listeners for buttons
btnLink.addEventListener(MouseEvent.CLICK, goToWebsite);
btnLink.addEventListener(MouseEvent.ROLL_OVER, showDescription);
btnLink.addEventListener(MouseEvent.ROLL_OUT, hideDescription);
mcInfo.btnPlay.addEventListener(MouseEvent.CLICK, togglePause);
mcInfo.btnPause.addEventListener(MouseEvent.CLICK, togglePause);
mcInfo.btnNext.addEventListener(MouseEvent.CLICK, nextSlide);
mcInfo.btnPrevious.addEventListener(MouseEvent.CLICK, previousSlide);
// hide play button
mcInfo.btnPlay.visible = false;
function onXMLLoadComplete(e:Event):void {
// show buttons, labels and link
mcInfo.visible = true;
btnLink.visible = true;
// create new xml with the received data
xmlSlideshow = new XML(e.target.data);
var unesc_xmlSlideshow:XML = new XML(unescape(xmlSlideshow));
// get total slide count
intSlideCount = unesc_xmlSlideshow..image.length();
// switch the first slide without a delay
switchSlide(0);
function fadeSlideIn(e:Event):void {
var unesc_xmlSlideshow:XML = new XML(unescape(xmlSlideshow));
// add loaded slide from slide loader to the
// current container
addSlideContent();
// clear preloader text
mcInfo.lbl_loading.text = "";
// check if the slideshow is currently playing
// if so, show time to the next slide. If not, show
// a status message
if(bolPlaying) {
mcInfo.lbl_loading.text = "Next slide in " + unesc_xmlSlideshow..image[intCurrentSlide].@time + " sec.";
} else {
mcInfo.lbl_loading.text = "Slideshow paused";
// fade the current container in and start the slide timer
// when the tween is finished
Tweener.addTween(currentContainer, {alpha:1, time:FADE_TIME, onComplete:onSlideFadeIn});
function onSlideFadeIn():void {
// check, if the slideshow is currently playing
// if so, start the timer again
if(bolPlaying && !slideTimer.running)
slideTimer.start();
function togglePause(e:MouseEvent):void {
var unesc_xmlSlideshow:XML = new XML(unescape(xmlSlideshow));
// check if the slideshow is currently playing
if(bolPlaying) {
// show play button
mcInfo.btnPlay.visible = true;
mcInfo.btnPause.visible = false;
// set playing flag to false
bolPlaying = false;
// set status message
mcInfo.lbl_loading.text = "Slideshow paused";
// stop the timer
slideTimer.stop();
} else {
// show pause button
mcInfo.btnPlay.visible = false;
mcInfo.btnPause.visible = true;
// set playing flag to true
bolPlaying = true;
// show time to next slide
mcInfo.lbl_loading.text = "Next slide in " + unesc_xmlSlideshow..image[intCurrentSlide].@time + " sec.";
// reset and start timer
slideTimer.reset();
slideTimer.start();
function switchSlide(intSlide:int):void {
// check if the last slide is still fading in
if(!Tweener.isTweening(currentContainer)) {
// check, if the timer is running (needed for the
// very first switch of the slide)
if(slideTimer.running)
slideTimer.stop();
// change slide index
intCurrentSlide = intSlide;
// check which container is currently in the front and
// assign currentContainer to the one that's in the back with
// the old slide
if(currentContainer == sprContainer2)
currentContainer = sprContainer1;
else
currentContainer = sprContainer2;
// hide the old slide
currentContainer.alpha = 0;
// bring the old slide to the front
mcSlideHolder.swapChildren(sprContainer2, sprContainer1);
// delete loaded content
clearLoader();
// create a new loader for the slide
slideLoader = new Loader();
// add event listener when slide is loaded
slideLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, fadeSlideIn);
// add event listener for the progress
slideLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress);
var unesc_xmlSlideshow:XML = new XML(unescape(xmlSlideshow));
// load the next slide, seems to f*ck up here...
slideLoader.load(new URLRequest(unesc_xmlSlideshow..image[intCurrentSlide].@src));
// show description of the next slide
mcInfo.lbl_description.text = unesc_xmlSlideshow..image[intCurrentSlide].@title;
// show artist's name of the next slide
mcInfo.lbl_artist.text = unesc_xmlSlideshow..image[intCurrentSlide].@artist;
// set link and link target variable of the slide
strLink = unesc_xmlSlideshow..image[intCurrentSlide].@link;
strTarget = unesc_xmlSlideshow..image[intCurrentSlide].@target;
mcInfo.mcDescription.lbl_description.htmlText = unesc_xmlSlideshow..image[intCurrentSlide].@desc;
// show current slide and total slides
//mcInfo.lbl_count.text = (intCurrentSlide + 1) + " / " + intSlideCount + " Slides";
mcInfo.lbl_count.text = " Slide " + (intCurrentSlide + 1) + " / " + intSlideCount;
function showProgress(e:ProgressEvent):void {
// show percentage of the bytes loaded from the current slide
mcInfo.lbl_loading.text = "Loading..." + Math.ceil(e.bytesLoaded * 100 / e.bytesTotal) + "%";
function goToWebsite(e:MouseEvent):void {
// check if the strLink is not empty and open the link in the
// defined target window
if(strLink != "" && strLink != null) {
navigateToURL(new URLRequest(strLink), strTarget);
function nextSlide(e:Event = null):void {
// check, if there are any slides left, if so, increment slide
// index
if(intCurrentSlide + 1 < intSlideCount)
switchSlide(intCurrentSlide + 1);
// if not, start slideshow from beginning
else
switchSlide(0);
function previousSlide(e:Event = null):void {
// check, if there are any slides left, if so, decrement slide
// index
if(intCurrentSlide - 1 >= 0)
switchSlide(intCurrentSlide - 1);
// if not, start slideshow from the last slide
else
switchSlide(intSlideCount - 1);
function showDescription(e:MouseEvent):void {
// remove tweens
Tweener.removeTweens(mcInfo.mcDescription);
// fade in the description
Tweener.addTween(mcInfo.mcDescription, {alpha:1, time:0.5, y: -1});
function hideDescription(e:MouseEvent):void {
// remove tweens
Tweener.removeTweens(mcInfo.mcDescription);
// fade out the description
Tweener.addTween(mcInfo.mcDescription, {alpha:0, alpha:1, time:0.5, y: 30});
function clearLoader():void {
try {
// get loader info object
var li:LoaderInfo = slideLoader.contentLoaderInfo;
// check if content is bitmap and delete it
if(li.childAllowsParent && li.content is Bitmap){
(li.content as Bitmap).bitmapData.dispose();
} catch(e:*) {}
function addSlideContent():void {
// empty current slide and delete previous bitmap
while(currentContainer.numChildren){Bitmap(currentContainer.getChildAt(0)).bitmapData.disp ose(); currentContainer.removeChildAt(0);}
// create a new bitmap with the slider content, clone it and add it to the slider container
var bitMp:Bitmap = new Bitmap(Bitmap(slideLoader.contentLoaderInfo.content).bitmapData.clone());
currentContainer.addChild(bitMp);
// init slideshow
initSlideshow();I'm sorry, you're right! Didn't intend to be lazy...
This line loads the image in the loader 'slideLoader'. This seems to work fine with image files (.jpg), but .swf files are ignored. Is it possible to load both .jpg AND .swf files in a loader, or do I have to use some other method for this?
slideLoader.load(new URLRequest(unesc_xmlSlideshow..image[intCurrentSlide].@src));
Thanks again,
Dirk -
Hello there. I was trying to mess around with flash and I was hoping I would use TweenMax to scale up a rectangle (instantiated as rect) on mouse over, and then once it is scaled up I wanted to load an swf file to its center (the swf is called CircularPreloader.swf which is a fake preloader, just for messing around porpuse). Well, I tried but it didn't work cuz I kept getting this error: TypeError: Error #1009: Cannot access a property or method of a null object reference.
at scaleUp_fla::MainTimeline/frame1()
Here's the code:
import gs.*;
import gs.easing.*;
rect.addEventListener(MouseEvent.MOUSE_OVER, scaleUp);
rect.addEventListener(MouseEvent.MOUSE_OUT, scaleDown);
var myTween:TweenMax
function scaleUp(e:MouseEvent):void
myTween = new TweenMax(rect, 0.4, {scaleX:4, scaleY:4});
function scaleDown(e:MouseEvent):void
TweenMax.to(rect, 0.2, {width: 240.9, height: 94});
myTween.addEventListener(Event.COMPLETE, addPreloader);
function addPreloader(e:Event):void
var mc:MovieClip = new MovieClip();
mc.x = rect.width / 2;
mc.y = rect.height / 2;
addChild(mc);
var loader:Loader = new Loader();
var req:URLRequest = new URLRequest("Circular Preloader.swf");
loader.load(req);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, addF);
function addF(e:Event):void
mc.addChild(loader);
Any help would be appreciated.Tried it again and this is the error I got:
ArgumentError: Error #1063: Argument count mismatch on scaleUp_fla::MainTimeline/addPreloader(). Expected 1, got 0.
at Function/http://adobe.com/AS3/2006/builtin::apply()
at gs::TweenLite/complete()
at gs::TweenMax/complete()
at gs::TweenMax/render()
at gs::TweenLite$/updateAll()
and here's the code I used:
import gs.*;
import gs.easing.*;
rect.addEventListener(MouseEvent.MOUSE_OVER, scaleUp);
rect.addEventListener(MouseEvent.MOUSE_OUT, scaleDown);
function scaleUp(e:MouseEvent):void
TweenMax.to(rect, 0.4, {scaleX:4, scaleY:4, onComplete:addPreloader});
function scaleDown(e:MouseEvent):void
TweenMax.to(rect, 0.2, {width: 240.9, height: 94});
function addPreloader(e:Event):void
var mc:MovieClip = new MovieClip();
mc.x = rect.width / 2;
mc.y = rect.height / 2;
addChild(mc);
var loader:Loader = new Loader();
var req:URLRequest = new URLRequest("Circular Preloader.swf");
loader.load(req);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, addF);
function addF(e:Event):void
mc.addChild(loader);
What do you think is missing? -
Tracing loaded external SWF bytes
I have a file that loads 13 external Swfs into a shell. When
they are all loaded, the shell plays the files in succession. That
works fine, but I a trying to show the progress of the loading
process, but the flash pretty much freezes until all of the files
are loaded then jumps my progress bar all the way to the end.
Basically, nothing is allowed to happen until the scenes are all
loaded completely. I can't even put a revolving animation on the
main timeline to display until the files are loaded. The animation
just sits on frame one until all the files are loaded, then starts
to play, which defeats the purpose. Is there anyway to pause the
code until the first movie is loaded, hten move on to then next
movie load or a way to concurrently display bytes loaded while the
file is being loaded.
var courseArray:Array= Array("Scene1.swf", "Scene2.swf",
"Scene3.swf", "Scene4.swf", "Scene5.swf", "Scene6.swf",
"Scene7.swf", "Scene8.swf", "Scene9.swf", "Scene10.swf",
"Scene11.swf", "Scene12.swf", "Scene13.swf");
startup = function() {
this.createEmptyMovieClip("scene"+(i+1), (i+1));
this["scene"+(i+1)].loadMovie(courseArray
for (i=0; i<13; i++) {
startup();
//****Jumps progress bar 1/13th of the way each time the
loading code happens****
this.progressBar.gotoAndStop(_root.progressBar._currentframe+(int(100/13)));
The code all seems to happen immediately because the
progressBar jumps all the way to the end right away, but the flash
freezes until the files are completely loaded. Can I pause this
code until each individual file is finished loaded, then run the
next loop?That is what I am asking. What would be the code? I already
had code that counted the .getBytesLoaded(), and would move the
progressBar based on what percent of the .getBytesTotal(). Like I
said before. The progressBar would just sit at 0%, then jump to
100% when the movie finished loading. The flash would just hang up,
then jump all the way past when done loading. In the code I have
below, it is supposed to jump the Progressbar 1/13th of the way
(because I have 13 files being loaded) each time through the loop,
but that doesn't work either. It just sits on 1 then jumps to 100
when the files finish loading even though it should do it in
progression through the loop.
Maybe you are looking for
-
CC Desktop became corrupt can't reinstall OS X
OS 10.10.2 I've been using CC for awhile without issue. Somehow my CC Desktop app became corrupt. I uninstalled it and tried reinstalling. It gets about halfway through the install process than the installer box simply disappears. I've downloaded
-
Discoverer 4.1.37 exporting to Oracle Reports
The documentation for installing Discoverer says to install the Oracle Reports API to export to Oracle Reports, but it is not on the Discoverer CD. Is the Reports API in another distribution, and which is the version I need with Discoverer 4.1.37? Th
-
RAF support, does it work with non-Fuji lenses like Zeiss TOUIT
Hello, I am shoorting eith a Fujifilm X-E2. The camera lists as supported in cameraraw 8.4. When I scroll through the camera-options in the development module I don't find my camera. Futher asking around (Fuji) told me that the support is "build in"
-
SATA III for Pavilion dv7t series
Do both hard drive slots in the dv7t series support the SATA III spec (6 Gb/Sec) ?
-
Java.io.IOException: Connection timed out while using non-blocking NIO
Hi, I am using non-blocking NIO on jdk 1.6 to transfer files between two processes. The problem is that the sender thread times out on the write call even though it's in non-blocking mode. It doesn't make sense. The receiver on the other end is runni