Function to undo movieclips
hi guys! is there any function which i can undo a movie clip
when i press a button? Is like when i click on the undo button it
will just set back to the previous screen i did.
I should add,
It might be the "htmldb_Get" JavaScript code that performed the conversion before the database even gets the value.
Similar Messages
-
Accessing a function from a movieclip form a top level layer
Im having a dillema. my whole game rests on being able to
access functions from a movieclip inside a movieclip in a top level
layer called "Cards" to another layer called "Functions". I've used
this code:
play_modifier_card(this.num.text);
to access this function:
function play_modifier_card(card_num){
trace(card_num);
It works OK when the function is in the movieclip but not
when it is in a top level layer. I tried
"_root.play_modifier_card(this.num.text);" but it didn't work. Any
help appriciated. Thanks in advance._global.play_modifier_card(card_num) {
trace(card_num);
} -
I have erroneoulsy deleted icons repetious images from the computer which then affected my iphoto images, leaving me in some cases only with the thembnail image. When I try to enlarge or perform any other function all that appears is a black field containing a grey circle with a black exclamation symbol( !)
within it. How to I get back full function of these affected images and undo my goof up. I have tried restore, but my attempts have not proved successful.
Help !!!
silvercohoWhat exactly did you do to delete these?
How did you try to "restore" and what did you try to restore?
Probably the only solution is to restore your backup of the iPhoto library from before you did this
LN -
Calling a function from a movieClip
I have a function in my main timeline but I want to call it
from a movieClip - I've tried _parent.myFunction() and
_root.myFunction() but they don't work while _parent.gotoAndPlay
does work.
Thanks.
Rob ChildressIs the page number variable set on the main timeline? You may
have to show me the flash file. -
Button functionality in a movieclip within another movieclip for another movieclip
Ok so i have this looping thumbnails bar that goes like this:
Scene1-imagebar-imagebarinside
The buttons symbols are in the "imagebarinside" movieclip and i am using this code:
ss1.addEventListener(MouseEvent.CLICK, play1);
function play1(event:MouseEvent):void
gotoAndStop("ssbox1");
...in this movieclip to play another labeled frame in another movieclip (Scene1-Bara)
Problem is it wont work :-< if anyone has a better ideea i'll really apreciate itHey!
So, trying to understand the distribution of your MovieClips inside the flash file, this is what I understand:
Scene1 contains a movieclip with the instance name "imagebar" and another movieclip with the instance name "bara".
"imagebar" contains a movieclip with the instance name "imagebarinside". If that is the case (And the code being on the first frame of "imagebarinside"), I would use something like:
function play1(event:MouseEvent):void
Object(this.parent).parent.bara.gotoAndStop("ssbox1");
Hope this works! -
Using modular functions with movieclips
hi guys, this morning i was looking a tutorial that shows how to make modular functions, the user only used numbers, i was wandering if there is a way to use this with movieclips or childs.
The example was:
function addNumber(num1:Number, num2:Number, num3:Number):void
trace(num1+num2*num3);
addNumber(3, 4, 7);
i tried using a movieclip called cuadro and triying to move on the x axis, but it didnt work out:
function mObj(obj1:MovieClip, num1:Number):void
obj1.x = num1;
addNumber(cuadro, 50);
any sugestion?
thnks in advanceoh sorry my bad, i was trying another stuff
i know that the last line must say
mObj(cuadro, 50);
what im trying to do is use the function with some objects in the stage, and for example when i press the first button, it will write mObj(cuadro1, 50) , button2 mObj(cuadro2, 80), so i can use the same function for diferents objects -
Movieclip(root) doesn't work inside a function
Hey everyone,
I'm having this problem.
In fact, when i publish my FLA with player 9, there is no prob.
When i publish with selecting player 10, there is this problem.
I paste my code :
var leng:int = MovieClip(root).program.websiteXML.pages.titlePage.length();
trace ("leng"+leng);
setInterval(function () : void {
if (MovieClip(root).program.autoCh==true){
trace("CHANGE");
MovieClip(root).allContent.controllMenu2['itemButton_' + MovieClip(root).program.linkPic].gotoAndPlay("s4");
if (MovieClip(root).program.linkPic < int(leng-1)){
MovieClip(root).program.linkPic++;
}else{
//MovieClip(root).allContent.play ();
MovieClip(root).program.autoCh=false;
MovieClip(root).program.linkPic=1;
MovieClip(root).allContent.controllMenu2['itemButton_' + MovieClip(root).program.linkPic].gotoAndPlay("s4");
for (var z:uint=1; z<(MovieClip(root).program.linkPic+1); z++) {
var tempMC:MovieClip = MovieClip(MovieClip(root).allContent.controllMenu2)["itemButton_"+z];
Tweener.addTween(tempMC, { x:(z-1)*(45+1)-353, time:1} );
for (var j:uint=(MovieClip(root).program.linkPic+1); j<7; j++) {
var tempMC2:MovieClip = MovieClip(MovieClip(root).allContent.controllMenu2)["itemButton_"+j];
Tweener.addTween(tempMC2, { x:(j-1)*(45+1)+352, time:1} );
MovieClip(root).allContent.controllMenu2['itemButton_' + MovieClip(root).program.linkPic].gotoAndPlay("s3");
}}, 4000);
For leng variable, there is no problem, the value is taken.
But it's inside SetIntervall, at
MovieClip(root).program.autoCh
it tells me that :
TypeError: Error #1009: Il est impossible d'accéder à la propriété ou à la méthode d'une référence d'objet nul.
at Function/<anonymous>()[main6_cs3_fla._00button_136::frame1:32]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at SetIntervalTimer/onTimer()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
And if I put the value outside the function :
var autoChtest = MovieClip(root).program.autoCh;
And use it :
if (autoChtest==true)
There is no errors but my function doesn't work correctly, as autoCh can be "false" in another action.
Well, I hope this will not scare you, and someone will try to help me, please.
If someone know anything about this issue or having same problem please tell me.
Thanks!Ok i see more clearly, you know it's diificult for me to understand it because i'm into flash AS since a few weeks.
And what you say about the way setInterval is use, with the function in it, i'm totally agree with that, it's difficult to read.
The truth is that this is a template that I bought and it was like that, so to do what i've got to do i needed to change some AS3 code.
This is how it is now :
var rootvar = MovieClip(root).root;
function diapodebut (e:TimerEvent) : void {
if (rootvar.program.autoCh==true){
trace("CHANGE");
rootvar.allContent.controllMenu2['itemButton_' + rootvar.program.linkPic].gotoAndPlay("s4");
if (rootvar.program.linkPic < int(leng-1)){
rootvar.program.linkPic++;
}else{
//MovieClip(root).allContent.play ();
rootvar.program.autoCh=false;
rootvar.program.linkPic=1;
rootvar.allContent.controllMenu2['itemButton_' + rootvar.program.linkPic].gotoAndPlay("s4");
for (var $z:uint=1; $z<(rootvar.program.linkPic+1); $z++) {
var tempMC:MovieClip = MovieClip(rootvar.allContent.controllMenu2)["itemButton_"+$z];
Tweener.addTween(tempMC, { x:($z-1)*(45+1)-353, time:1} );
for (var j:uint=(rootvar.program.linkPic+1); j<7; j++) {
var tempMC2:MovieClip = MovieClip(rootvar.allContent.controllMenu2)["itemButton_"+j];
Tweener.addTween(tempMC2, { x:(j-1)*(45+1)+352, time:1} );
rootvar.allContent.controllMenu2['itemButton_' + rootvar.program.linkPic].gotoAndPlay("s3");
else
timerSynchro.stop( );
var leng:int = MovieClip(root).program.websiteXML.pages.titlePage.length();
trace ("leng"+leng);
var timerSynchro:Timer = new Timer( 4000, 6) ;
timerSynchro.addEventListener( TimerEvent.TIMER, diapodebut);
timerSynchro.start() ;
You can see that I use Timer class, i've seen on another website just what you say : use Timer instead of setInterval with AS3.
If you still find something wrong to you, tell me!
Thanks again for your help ! -
Is there anything in AS to help with doing a Back/Undo
function (a bit vague i know).
I'm currently loading movieclips/xml/drawing with api at
different position on the timeline. At the moment the user has a
play button and plays through all of these sequentially.
Is there any prebuilt functions / anything that would help
with creating a backfunction so the user can play backwards through
the movie.
At the moment i've just been doing this by having a remove /
whatever function in the frame before the fram with the load/
whatever function. But it's not a very neat way because if i
add/modify code later i have to make sure I have another function
to undo these changes earlier in the movie.
Thanks for any help!Not that I would know of - to rephrase it: No ;-).
Actually I think one way to do it would be to follow a
mcv-pattern, and keep model-states in an array that you can revert
to, but it aint easy. I guess that is whay it took a lot of (even
bigger ones) Apps quite some time to implement a decent back/undo
functionality. -
Problem in Loading Multiple image in Single Sprite/MovieClip
Hi All,
I am having a killing problem in loading multiple images in single movie clip/sprite using a separate class.
Here is the ImageLoader.as class
package com.project.utils{
import com.project.*;
import com.project.utils.*;
import flash.events.EventDispatcher;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.display.Loader;
import flash.events.IOErrorEvent;
import flash.net.URLLoader;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.display.Bitmap;
public class ImageLoader extends EventDispatcher {
public var imgloader:Loader;
public var imgMc:MovieClip;
public var imgObject:Object;
public var loaded:Number;
public function ImageLoader():void {
imgMc = new MovieClip();
imgObject = new Object();
imgloader = new Loader();
public function loadImage(imgHolder:MovieClip, imgObj:Object):void {
imgMc = new MovieClip();
imgObject = new Object();
imgloader = new Loader();
imgMc = imgHolder;
imgObject = imgObj;
imgloader.contentLoaderInfo.addEventListener(Event.COMPLETE,onImgLoad);
imgloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,onImgLoadProgress);
imgloader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onImageLoadFailed);
imgloader.load(new URLRequest(imgObj.FilePath));
private function onImgLoad(Evt:Event):void {
var image:Bitmap = Bitmap(Evt.target.content);
try {
imgMc.removeChildAt(0);
} catch (error:Error) {
imgMc.addChild(image);
try {
if (imgObject.URL != undefined) {
imgMc.buttonMode = true;
imgMc.removeEventListener(MouseEvent.CLICK, onImageClicked);
imgMc.addEventListener(MouseEvent.CLICK, onImageClicked);
} catch (err:Error) {
dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD"));
private function onImageClicked(evt:MouseEvent):void {
trace("Image Attrs:"+imgObject.URL +" Target "+imgObject.Target);
private function onImgLoadProgress(Evt:ProgressEvent):void {
if (Evt.bytesLoaded>0) {
loaded = Math.floor((Evt.bytesLoaded*100)/Evt.bytesTotal);
dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_PROC",loaded));
private function onImageLoadFailed(Evt:IOErrorEvent):void {
trace("Image Loading Failed");
dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_FAIL"));
Here I am loading some images using the above class in a for loop, like
for (var i=0; i < 3; i++) {
//imgLoader=new ImageLoader;
imgLoader.addEventListener("CustomEvent.ON_IMGE_LOAD",onImageLoad);
var target:MovieClip=videolist_mc["list" + mcCount + "_mc"];
target.list_mc.visible=false;
var imgObj:Object=new Object;
imgObj.FilePath=list[i].Thumbnail;
imgObj.Url=list[i].Url;
imgObj.Target=list[i].Target;
target.list_mc.urlObj=new Object ;
target.list_mc.urlObj=imgObj;
imgLoader.loadImage(target.list_mc.imgholder_mc,imgObj);
target.list_mc.lable_txt.htmlText="<b>" + list[i].Label + "</b>";
target.list_mc.imgholder_mc.buttonMode=true;
target.list_mc.imgholder_mc.addEventListener(MouseEvent.CLICK,onItemPressed);
mcCount++;
In this case, the ImageLoader.as works only on the last movie clip from the for loop. For example, if i am trying to load three image in three movie clips namely img_mc1,img_mc2 and img_mc3 using the for loop and ImageLoader.as, I am getting the image loaded in the third movie clip only img_mc.
See at the same time, If i uncomment onething in the for loop that is
//imgLoader=new ImageLoader;
its working like a charm. But I know creating class objects in a for loop is not a good idea and also its causes some other problems in my application.
So, help to get rid out of this problem.
Thanks
-Varunpackage com.project.utils{
import com.project.*;
import com.project.utils.*;
import flash.events.EventDispatcher;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.display.Loader;
import flash.events.IOErrorEvent;
import flash.net.URLLoader;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.display.Bitmap;
public class ImageLoader extends EventDispatcher {
public var imgloader:Loader;
public var imgMc:MovieClip;
public var imgObject:Object;
public var loaded:Number;
public function ImageLoader():void {
// better add you movieclip to the stage if you want to view anything added to it.
imgMc = new MovieClip();
imgObject = new Object();
imgloader = new Loader();
public function loadImage(filepath:String):void {
imgloader.contentLoaderInfo.addEventListener(Event.COMPLETE,onImgLoad);
imgloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,onImgLoadPr ogress);
imgloader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onImageLoadF ailed);
imgloader.load(new URLRequest(filepath));
private function onImgLoad(Evt:Event):void {
var image:Bitmap = Bitmap(Evt.target.content);
try {
imgMc.removeChildAt(0);
} catch (error:Error) {
imgMc.addChild(image);
try {
if (imgObject.URL != undefined) {
imgMc.buttonMode = true;
imgMc.removeEventListener(MouseEvent.CLICK, onImageClicked);
imgMc.addEventListener(MouseEvent.CLICK, onImageClicked);
} catch (err:Error) {
dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD"));
private function onImageClicked(evt:MouseEvent):void {
trace("Image Attrs:"+imgObject.URL +" Target "+imgObject.Target);
private function onImgLoadProgress(Evt:ProgressEvent):void {
if (Evt.bytesLoaded>0) {
loaded = Math.floor((Evt.bytesLoaded*100)/Evt.bytesTotal);
dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_PROC",loaded));
private function onImageLoadFailed(Evt:IOErrorEvent):void {
trace("Image Loading Failed");
dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_FAIL"));
Here I am loading some images using the above class in a for loop, like
for (var i=0; i < 3; i++) {
var imgLoader:ImageLoader=new ImageLoader();
imgLoader.addEventListener("CustomEvent.ON_IMGE_LOAD",onImageLoad);
var target:MovieClip=videolist_mc["list" + mcCount + "_mc"];
target.list_mc.visible=false;
var imgObj:Object=new Object;
imgObj.FilePath=list[i].Thumbnail;
imgObj.Url=list[i].Url;
imgObj.Target=list[i].Target;
target.list_mc.urlObj=new Object ;
target.list_mc.urlObj=imgObj;
imgLoader.loadImage(pass the image file's path/name);
target.list_mc.lable_txt.htmlText="<b>" + list[i].Label + "</b>";
target.list_mc.imgholder_mc.buttonMode=true;
target.list_mc.imgholder_mc.addEventListener(MouseEvent.CLICK,onItemPressed);
mcCount++; -
To use the same code for many movieclips
Dear all.
I am using the flash to build my personal book online. I need zoom many movieclip, my images.
i make the code and function perfectly. But I want to find a way to use the same function for all movieclips and so, mantaining my code clean.
mc_01.addEventListener(MouseEvent.MIDDLE_MOUSE_DOWN, Drag);
mc_01.addEventListener(MouseEvent.MIDDLE_MOUSE_UP, unDrag);
mc_02.addEventListener(MouseEvent.MIDDLE_MOUSE_DOWN, Drag);
mc_02.addEventListener(MouseEvent.MIDDLE_MOUSE_UP, unDrag);
and many others....
function Zoom(e:MouseEvent):void
mc_01.x = 0; //I try here for this.x but the previews movie, called "Books" is who have changed your x value.
mc_01.y = 0;
I
EDIT: For untangle, the previews movie is called MyAllPhotos and then, contain all movieclips that are each movie clip is one my imagesHi Mr Kglad.
And when I call a property like a X position I use this["mc_"+padF(i)].x = 0; for substitute the mc_01.x = 0 ?
My problem realy is inside the function. Your loop add an event to my clips and direction to function Drag and UnDrag.
But inside in this functions, I need get some informations for the clip.
Here the code:
function Zoom(e:MouseEvent):void //Sorry, but the correct name my functions is Zoom and not Drag and unDrag
var mod:Number = 50;
mc_01.scaleX += e.delta / mod; //in this name mc what I need to use? this, parent? I try and not function.
mc_01.scaleY += e.delta / mod; -
Stop and Play All Child MovieClips in Flash with Actionscript 3.0
I am stuck with the ActionScript here. I have a very complex animated flash movie for eLearning. These contain around 10 to 15 frames. In each frame I am having multiple movie clip symbols. The animation has been created using a blend of scripting and also normal flash animation.
Now I want to create pause and play functionality for the entire movie. I was able to create the pause function but when i try to play the movie it behaves very strange.
I was able to develop the pause functionality by refering to the below mentioned links:
http://www.unfocus.com/2009/12/07/stop-all-child-movieclips-in-flash-with-actionscript-3-0 /
http://www.curiousfind.com/blog/174
Any help in this regard is highly appreciated as i am approaching a deadline.
I am pasting the code below:
import flash.display.MovieClip;
import flash.display.DisplayObjectContainer;
import flash.utils.Timer;
import flash.events.TimerEvent;
import fl.transitions.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import flash.events.Event;
import flash.events.MouseEvent;
stop();
// function to stop all movieclips
function stopAll(content:DisplayObjectContainer):void
if (content is MovieClip)
(content as MovieClip).stop();
if (content.numChildren)
var child:DisplayObjectContainer;
for (var i:int, n:int = content.numChildren; i < n; ++i)
if (content.getChildAt(i) is DisplayObjectContainer)
child = content.getChildAt(i) as DisplayObjectContainer;
if (child.numChildren)
stopAll(child);
else if (child is MovieClip)
(child as MovieClip).stop();
// function to play all movieclips
function playAll(content:DisplayObjectContainer):void
if (content is MovieClip)
var movieClip:MovieClip = content as MovieClip;
if (movieClip.currentFrame < movieClip.totalFrames) // if the main timeline has reached the end, don't play it
movieClip.gotoAndPlay(currentFrame);
if (content.numChildren)
var child:DisplayObjectContainer;
var n:int = content.numChildren;
for (var i:int = 0; i < n; i++)
if (content.getChildAt(i) is DisplayObjectContainer)
child = content.getChildAt(i) as DisplayObjectContainer;
if (child.numChildren)
playAll(child);
else if (child is MovieClip)
var childMovieClip:MovieClip = child as MovieClip;
if (childMovieClip.currentFrame < childMovieClip.totalFrames)
//childMovieClip.play();
childMovieClip.play();
function resetMovieClip(movieClip:MovieClip):MovieClip
var sourceClass:Class = movieClip.constructor;
var resetMovieClip:MovieClip = new sourceClass();
return resetMovieClip;
pauseBtn.addEventListener(MouseEvent.CLICK, onClickStop_1);
function onClickStop_1(evt:MouseEvent):void
MovieClip(root).stopAll(this);
myTimer.stop();
playBtn.addEventListener(MouseEvent.CLICK, onClickPlay_1);
function onClickPlay_1(evt:MouseEvent):void
MovieClip(root).playAll(this);
myTimer.start();
Other code which helps in animating the movie and other functionalities are as pasted below:
stage.addEventListener(Event.RESIZE, mascot);
function mascot():void {
// Defining variables
var mc1:MovieClip = this.mascotAni;
var sw:Number = stage.stageWidth;
var sh:Number = stage.stageHeight;
// resizing movieclip
mc1.width = sw/3;
mc1.height = sh/3;
// positioning mc
mc1.x = (stage.stageWidth/2)-(mc1.width/2);
mc1.y = (stage.stageHeight/2)-(mc1.height/2);
// keeps the mc1 proportional
mc1.scaleX <= mc1.scaleY ? (mc1.scaleX = mc1.scaleY) : (mc1.scaleY = mc1.scaleX);
stage.removeEventListener(Event.RESIZE, mascot);
mascot();
this.mascotAni.y = 100;
function mascotReset():void
// Defining variables
var mc1:MovieClip = this.mascotAni;
stage.removeEventListener(Event.RESIZE, mascot);
mc1.width = 113.45;
mc1.height = 153.85;
mc1.x = (stage.stageWidth/2)-(mc1.width/2);
mc1.y = (stage.stageHeight/2)-(mc1.height/2);
// keeps the mc1 proportional
mc1.scaleX <= mc1.scaleY ? (mc1.scaleX = mc1.scaleY) : (mc1.scaleY = mc1.scaleX);
var interval:int;
var myTimer:Timer;
// function to pause timeline
function pauseClips(secs:int, myClip:MovieClip):void
interval = secs;
myTimer = new Timer(interval*1000,0);
myTimer.addEventListener(TimerEvent.TIMER, goNextFrm);
myTimer.start();
function goNextFrm(evt:TimerEvent):void
myTimer.reset();
myClip.nextFrame();
myTimer.removeEventListener(TimerEvent.TIMER, goNextFrm);
// function to pause timeline on a particular label
function pauseClipsLabel(secs:int, myClip:MovieClip, myLabel:String):void
interval = secs;
myTimer = new Timer(interval*1000,0);
myTimer.addEventListener(TimerEvent.TIMER, goNextFrm);
myTimer.start();
function goNextFrm(evt:TimerEvent):void
myClip.gotoAndStop(myLabel);
myTimer.removeEventListener(TimerEvent.TIMER, goNextFrm);
MovieClip(root).pauseClips(4.5, this);
// function to fade clips
function fadeClips(target_mc:MovieClip, next_mc:MovieClip, from:Number, to:Number):void
var fadeTW:Tween = new Tween(target_mc, "alpha", Strong.easeInOut, from, to, 0.5, true);
fadeTW.addEventListener(TweenEvent.MOTION_FINISH, fadeFinish);
function fadeFinish(evt:TweenEvent):void
next_mc.nextFrame();
fadeTW.removeEventListener(TweenEvent.MOTION_FINISH, fadeFinish);
// function to fade clips with speed
function fadeClipsSpeed(target_mc:MovieClip, next_mc:MovieClip, from:Number, to:Number, speed:int):void
var fadeTW:Tween = new Tween(target_mc, "alpha", Strong.easeInOut, from, to, speed, true);
fadeTW.addEventListener(TweenEvent.MOTION_FINISH, fadeFinish);
function fadeFinish(evt:TweenEvent):void
next_mc.nextFrame();
fadeTW.removeEventListener(TweenEvent.MOTION_FINISH, fadeFinish);
// function to show screen transitions
function screenFx(target_mc:MovieClip, next_mc:MovieClip):void
//var tweenTW:Tween = new Tween(target_mc,"alpha",Strong.easeInOut,0,1,1.2,true);
var tranFx:TransitionManager = new TransitionManager(target_mc);
tranFx.startTransition({type:Iris, direction:Transition.OUT, duration:1.2, easing:Strong.easeOut, startPoint:5, shape:Iris.CIRCLE});
tranFx.addEventListener("allTransitionsOutDone",doneTrans);
function doneTrans(evt:Event):void
next_mc.nextFrame();
tranFx.removeEventListener("allTransitionsOutDone",doneTrans);
// function to show screen transitions inverse
function screenFxInv(target_mc:MovieClip, next_mc:MovieClip):void
var tweenTW:Tween = new Tween(target_mc,"alpha",Strong.easeInOut,0,1,1.2,true);
var tranFx:TransitionManager = new TransitionManager(target_mc);
tranFx.startTransition({type:Iris, direction:Transition.IN, duration:2, easing:Strong.easeOut, startPoint:5, shape:Iris.SQUARE});
tranFx.addEventListener("allTransitionsInDone",doneTrans);
function doneTrans(evt:Event):void
next_mc.nextFrame();
tranFx.removeEventListener("allTransitionsInDone",doneTrans);
// function to zoom in
function zoomFx(target_mc:MovieClip):void
//var tweenTW:Tween = new Tween(target_mc,"alpha",Strong.easeInOut,0,1,1.2,true);
var tranFx:TransitionManager = new TransitionManager(target_mc);
tranFx.startTransition({type:Zoom, direction:Transition.IN, duration:3, easing:Strong.easeOut});
//tranFx.addEventListener("allTransitionsInDone",doneTrans);
/*function doneTrans(evt:Event):void
next_mc.nextFrame();
// Blinds Fx
function wipeFx(target_mc:MovieClip):void
var tranFx:TransitionManager = new TransitionManager(target_mc);
tranFx.startTransition({type:Wipe, direction:Transition.IN, duration:3, easing:Strong.easeOut, startPoint:9});
// Blinds Fx Center
function fadePixelFx(target_mc:MovieClip):void
var tranFx:TransitionManager = new TransitionManager(target_mc);
tranFx.startTransition({type:Fade, direction:Transition.IN, duration:1, easing:Strong.easeOut});
tranFx.startTransition({type:PixelDissolve, direction:Transition.IN, duration:1, easing:Strong.easeOut, xSections:100, ySections:100});This movie is an animated movie from the start to end. I mean to say that though it stops at certain keyframes in the timeline it stops for only a certain time and then moves on to the next animation sequence.
Its not an application where the user can interact.
On clicking the play button i want the movie to play normally as it was playing before. If the user has not clicked on the pause button it would anyhow play from start to finish.
Is there anyway where i could send in the fla file? -
Use length of XML file to tween movieclip?
Hello,
I'm creating a horizontal scrolling gallery in which the content is loaded through xml. So far the xml loads fine and the content is easily nested within movieclips and positioned within a larger movieclip containing each of the movieclips containing the content. With that said, I am able to move this main movieclip left and right with no problem using a tween and a fixed position but I have no way of stopping the movieclip according to how much content is in the xml file. I'm attempting to use the length of the xml file to move this main movieclip but either it can't be done or my coding is wrong.
Thank you in advance!
Here is my code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
var currentContentIndex:uint = 0;
var currentContent:MovieClip;
// container movieclip
var container:MovieClip = new MovieClip();
container.y = 120;
addChild(container);
var imageLoader:Loader;
var xml:XML;
var xmlList:XMLList;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("gallery.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
var x_count:Number = 0;
var y_count:Number = 0;
// Everything in the function below loads and positions fine
function xmlLoaded(event:Event):void
xml = XML(event.target.data);
xmlList = xml.children();
for(var i:int = 0; i < xmlList.length(); i++)
// contentContainer
var contentContainer:MovieClip = new MovieClip();
contentContainer.graphics.beginFill(0xFFFFFF);
contentContainer.graphics.drawRect(0, 0, 1000, 500);
contentContainer.graphics.endFill();
contentContainer.width = 1000;
contentContainer.height = 500;
contentContainer.x = (contentContainer.width+400)*x_count;
contentContainer.y = 0;
// thumbInfo
var imageInfo:MovieClip = new MovieClip();
imageInfo.graphics.beginFill(0x000000);
imageInfo.graphics.drawRect(0, 0, 150, 100);
imageInfo.graphics.endFill();
imageInfo.x = 400;
imageInfo.width = 150;
imageInfo.height = 100;
addChild(imageInfo);
imageLoader = new Loader();
imageLoader.load(new URLRequest(xmlList[i].attribute("source")));
x_count++;
y_count = 0;
contentContainer.addChild(imageLoader);
contentContainer.addChild(imageInfo);
container.addChild(contentContainer);
function tweenCurrentImageF(){
currentContent=MovieClip(xmlList[currentContentIndex]); // PROBLEM CODE?
var targetX:Number = stage.stageWidth/2 - currentContent.x - currentContent.width/2;
var myTween:Tween = new Tween(container, "x", Strong.easeInOut, container.x, targetX, 1, true);
rightArrow.buttonMode = true;
rightArrow.addEventListener(MouseEvent.CLICK, right);
function right(e:MouseEvent):void {
currentContentIndex++;
if(currentContentIndex<xmlList.length){
tweenCurrentImageF();Hey again,
I understand what you are saying and I've omitted that problem code because it's code I'm trying to carry over from a gallery using an array of movieclips and, to me, it seems irrelevant to this code. I have moved some code around and the movieclip scrolls now but its scrolling directly to the last nested movieclip even though the "currentContentIndex" variable traces 0.
I moved the button and it's function code inside of the xmlLoaded function because it was recognizing "contentContainer.x" as an undefined term when it was outside of it (I just stated this in case this is the problem).
Thank you again!
Here is my new code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
var currentContentIndex:uint = 0;
// container movieclip
var container:MovieClip = new MovieClip();
container.y = 120;
addChild(container);
var imageLoader:Loader;
var xml:XML;
var xmlList:XMLList;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("gallery.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
var x_count:Number = 0;
var y_count:Number = 0;
function xmlLoaded(event:Event):void {
xml = XML(event.target.data);
xmlList = xml.children();
for(var i:int = 0; i < xmlList.length(); i++)
// contentContainer
var contentContainer:MovieClip = new MovieClip();
contentContainer.graphics.beginFill(0xFFFFFF);
contentContainer.graphics.drawRect(0, 0, 1000, 500);
contentContainer.graphics.endFill();
contentContainer.width = 1000;
contentContainer.height = 500;
contentContainer.x = (contentContainer.width+400)*x_count;
contentContainer.y = 0;
container.addChild(contentContainer);
imageLoader = new Loader();
imageLoader.load(new URLRequest(xmlList[i].attribute("source")));
contentContainer.addChild(imageLoader);
x_count++;
y_count = 0;
var imageText:TextField = new TextField();
imageText.x = 400;
imageText.y = 30;
imageText.text = xmlList[i];
imageText.autoSize = TextFieldAutoSize.LEFT;
contentContainer.addChild(imageText);
function tweenCurrentImageF(){
var targetX:Number = stage.stageWidth/2 - contentContainer.x - contentContainer.width/2;
var myTween:Tween = new Tween(container, "x", Strong.easeInOut, container.x, targetX, 2, true);
rightArrow.buttonMode = true;
rightArrow.addEventListener(MouseEvent.CLICK, right);
function right(e:MouseEvent):void {
currentContentIndex++;
if(currentContentIndex<xmlList.length()){
tweenCurrentImageF(); -
Function to change alpha of a movie clip
Hi all, I am having this bit of code not working for me. I want to have a function 'thisAplha'to analyze a mc's alpha stage, and depending on it either appear or disappear it. Basically I am trying to disappear/appear on screen the inv0 mc when you click it.
Actionscripit:
stop(); var mbx = _root.page.MsgBox; var mouseXspace = this._xmouse+20; var mouseYspace = this._ymouse+20; var css = new TextField.StyleSheet(); cssurl = "includes/default.css"; css.load(cssurl); css.onLoad = function(success) { if (success) { for (i=0; i<=6; i++) { this.eval("txt"+i).html = true; this.eval("txt"+i).multiline = true; this.eval("txt"+i).wordWrap = true; this.eval("txt"+i).styleSheet = css; eval("txt"+i).htmlText = eval("_root.page.data.label"+i); } } }; inv0.onRelease = function() { thisAlpha(inv0); //inv0._alpha = 100; mbx.lockCenter(false); mbx.lockWidth("300"); mbx.setAutoSize(); mbx._x = mouseXspace; mbx._y = mouseYspace; mbx.setMsgBoxStyle(_root.page.lessonTwo); mbx.popup(_root.page.data.text1); }; inv1.onRelease = function() { inv1._alpha = 100; mbx.lockCenter(false); mbx.lockWidth("300"); mbx.setAutoSize(); mbx._x = mouseXspace; mbx._y = mouseYspace; mbx.setMsgBoxStyle(_root.page.lessonTwo); mbx.popup(_root.page.data.text2); }; inv2.onRelease = function() { inv2._alpha = 100; mbx.lockCenter(false); mbx.lockWidth("300"); mbx.setAutoSize(); mbx._x = mouseXspace; mbx._y = mouseYspace; mbx.setMsgBoxStyle(_root.page.lessonTwo); mbx.popup(_root.page.data.text3); }; function thisAlpha(yeah:MovieClip) { if (this[yeah]._alpha <= 50) { this[yeah]._alpha = 100; trace; } if (this[yeah]._alpha >= 51) { this[yeah]._alpha = 0; } else { this[yeah]._alpha = 40; } }
Thank you all.
Mauriciocode:
stop();
var mbx = _root.page.MsgBox;
var mouseXspace = this._xmouse+20;
var mouseYspace = this._ymouse+20;
var css = new TextField.StyleSheet();
cssurl = "includes/default.css";
css.load(cssurl);
css.onLoad = function(success) {
if (success) {
for (i=0; i<=6; i++) {
this.eval("txt"+i).html = true;
this.eval("txt"+i).multiline = true;
this.eval("txt"+i).wordWrap = true;
this.eval("txt"+i).styleSheet = css;
eval("txt"+i).htmlText = eval("_root.page.data.label"+i);
inv0.onRelease = function() {
thisAlpha(inv0);
//inv0._alpha = 100;
mbx.lockCenter(false);
mbx.lockWidth("300");
mbx.setAutoSize();
mbx._x = mouseXspace;
mbx._y = mouseYspace;
mbx.setMsgBoxStyle(_root.page.lessonTwo);
mbx.popup(_root.page.data.text1);
inv1.onRelease = function() {
inv1._alpha = 100;
mbx.lockCenter(false);
mbx.lockWidth("300");
mbx.setAutoSize();
mbx._x = mouseXspace;
mbx._y = mouseYspace;
mbx.setMsgBoxStyle(_root.page.lessonTwo);
mbx.popup(_root.page.data.text2);
inv2.onRelease = function() {
inv2._alpha = 100;
mbx.lockCenter(false);
mbx.lockWidth("300");
mbx.setAutoSize();
mbx._x = mouseXspace;
mbx._y = mouseYspace;
mbx.setMsgBoxStyle(_root.page.lessonTwo);
mbx.popup(_root.page.data.text3);
function thisAlpha(yeah:MovieClip) {
if (this[yeah]._alpha <= 50) {
this[yeah]._alpha = 100;
trace;
if (this[yeah]._alpha >= 51) {
this[yeah]._alpha = 0;
} else {
this[yeah]._alpha = 40; -
I have a function that tells a movie clip to hover around, how do i turn it off though?
on roll over? I'd like to have it so that when you roll over
an invisible button over the movieclip, it will stop the motion
created by this function.
HOW is this done? I mean, I can call a function, but how can
I stop it? And then restart it when you roll off the invisible
button.
The following code is on frame 1 of my file....
Please save from this hellish problem....Thanks.
function floatMc(float_mc:MovieClip, range_num:Number,
frames_num:Number):Void {
var xMin:Number = float_mc._x-range_num;
var xMax:Number = float_mc._x+range_num- 7;
var yMin:Number = float_mc._y-range_num ;
var yMax:Number = float_mc._y+range_num - 14;
var frames:Number = frames_num;
//number of seconds for the tween to take, and how often to
start a new tween
var me:MovieClip = float_mc;
function newTween() {
//adjust the easing class as needed
var xNew:Number = (Math.random()*(xMax-xMin))+xMin;
var yNew:Number = (Math.random()*(yMax-yMin))+yMin;
xTween = new mx.transitions.Tween(me, "_x",
mx.transitions.easing.Regular.easeInOut, me._x, xNew, frames,
false);
yTween = new mx.transitions.Tween(me, "_y",
mx.transitions.easing.Regular.easeInOut, me._y, yNew, frames,
false);
var IntID:Number = setInterval(newTween, (frames*(1000/31)));
floatMc(penthouse, 12, 72);
floatMc(midnight, 12, 82);
floatMc(photo, 12, 62);
floatMc(meeting, 12, 66);
floatMc(everything, 12, 80);
floatMc(space, 12, 77);i just answered this.
-
Change Movieclips Parameters-Variables
Hi,
Im working on the following code and i need some help to
change part of the code:
The code is a slider to view pictures loaded from external
file. I changed the size of the stage(1000x1000), the big pictures
are displayed above(1000x400) and i would like to do 3 things:
1.The slider has the size(400x50). I changed its
size(500x80), the thumbnails move but at some point the slider
remains half empty and then fills up again. This happens when i
have small amount of pictures. I would like not to double but
treble the No of the thumbnails so the slider wont remains empty.
2.Move the thumbnails on the right-half part of the stage.
When i only change the coordinates(x,y) of the slider it doesnt
work.They r loaded on the right part, but when placing the cursor
above they disappear.
3.Is it possible when placing the cursor over a thumbnails to
show text(small description of each pic)????
Heres the URL of the code working:
http://www.flash-creations.com/notes/dynamic_slidingviewer.php
Thanks
Theo
Heres the code:
/********* DECLARE AND INITIALIZE VARIABLES
// names of folder and pictures, in the order to put them
into the slider
var picnames:Array = [
"flower_orange",
"flower_yellow",
"flower_pink",
"flower_red",
"flower_purple"
// constants
var PICPATH:String = "flowers/"; // folder with jpgs
var NPICS:Number = picnames.length; // number of pictures to
load
var PICX:Number = 10; // x loc of big picture
var PICY:Number = 10; // y loc
var THUMBHOLDERX:Number = 0; // x location of thumbnail
holder movieclip
var THUMBHOLDERY:Number = 240; // y location
var THUMBW:Number = 72; // width of each thumbnail
var THUMBH:Number = 40; // height
var MARGIN:Number = 10; // margin between thumbnails
var TOTALBYTES:Number = 212000; // approx sum of bytes in all
jpgs (x 2)
var MAXPIXELS:Number = 12; // max number of pixels to move
slider per frame
// mask definition; mask is assumed to cover some part of the
thumbnail slider (here the numbers
// were chosen so that there are margins between the mask and
the right and left edges of the movie
// (which is 420 x 290), and enough space above and below the
thumbs to show them when they 'grow'
// on mouseover
var MASKX:Number = 10; // start x location of mask
var MASKW:Number = 400; // mask width
var MASKY:Number = 230; // start y location of mask
var MASKH:Number = 60; // mask height
var totalloaded:Number = 0; // running tally of bytes loaded
from all pics
// index into pictures array, used for loading
var ipic:Number;
// set up loader, an instance of MovieClipLoader
var loader:MovieClipLoader = new MovieClipLoader();
// use the main timeline to listen to and respond to loader's
broadcast events
loader.addListener(this);
/********* DEFINE FUNCTIONS, INCLUDING INIT FOR MOVIE SETUP
// thumbnail rollover handler
function grow() {
this.onEnterFrame = function() {
if (this._width < THUMBW * 1.2) {
this._x -= this._width * .025;
this._y -= this._height * .025;
this._width *= 1.05;
this._height *= 1.05;
} else delete this.onEnterFrame;
// thumbnail rollout handler
function shrink() {
this.onEnterFrame = function() {
if (this._width > THUMBW) {
this._width /= 1.05;
this._height /= 1.05;
this._x += this._width * .025;
this._y += this._height * .025;
} else delete this.onEnterFrame;
// function to move thumbnail slider ("this" = thumbs_mc)
function sliderControl() {
var w:Number = this._width/2;
var hw:Number = mask_mc._width/2;
var npixels:Number;
// only do when mouse over slider mask
if (_ymouse > mask_mc._y && _ymouse <
mask_mc._y + mask_mc._height) {
// mouse over left half of slider:
if (_xmouse > mask_mc._x && _xmouse <
mask_mc._x + hw) {
npixels = (hw - _xmouse) / hw * MAXPIXELS;
this._x += npixels;
if (this._x >= 0) this._x = this._x - w;
// mouse over right half of slider:
} else if (_xmouse > mask_mc._x + hw && _xmouse
< mask_mc._x + mask_mc._width) {
npixels = (_xmouse - hw) / hw * MAXPIXELS;
this._x -= npixels;
if (this._x <= -w) this._x = this._x + w;
// thumbnail click (onrelease) handler
function openPic() {
pic_mc.loadMovie(PICPATH + picnames[this.i] + ".jpg");
// assign event handlers (called when all jpgs are loaded)
function setupHandlers() {
pct_txt.removeTextField(); // don't need loading indicator
any more
thumbs_mc.onEnterFrame = sliderControl;
for (var i:Number = 0; i < NPICS*2; i++) {
thumbs_mc["mc"+i].onRollOver = grow;
thumbs_mc["mc"+i].onRollOut = shrink;
thumbs_mc["mc"+i].onRelease = openPic;
// listener function for broadcast 'done' message (for each
pic)
// onLoadInit gets executed when the movieclip has been
loaded into _mc AND
// its width and height data are available.
// (_mc = the movieclip being loaded into)
// this routine sets the size and position of each thumbnail
clip as its jpg
// is loaded and starts the next one loading. When all have
been loaded,
// a random picture is loaded into pic_mc and setupHandlers
is called to
// assign handlers to each thumbnail movieclip
function onLoadInit(_mc:MovieClip) {
// this gets done when the jpg is completely loaded:
_mc._width = THUMBW;
_mc._height = THUMBH;
_mc._alpha = 99; // for image clarity
// give the movieclip a property to remind it who it is
// (used by openPic to know which big picture to open)
_mc.i = (ipic >= NPICS ? ipic-NPICS : ipic);
// add picture size to totalloaded variable
totalloaded += loader.getProgress(_mc).bytesTotal;
// now load the next one (if there are more) or set up
handlers if done
ipic++;
if (ipic == NPICS * 2) {
// start with a random photo displayed when all thumbs
loaded
pic_mc.loadMovie(PICPATH +
picnames[Math.floor(Math.random()*NPICS)] + ".jpg");
setupHandlers();
} else if (ipic >= NPICS) {
// load jpg into duplicate thumbnail (will already be
cached)
loader.loadClip(PICPATH + picnames[ipic-NPICS] + ".jpg",
thumbs_mc["mc"+ipic]);
} else {
// load jpg into thumbnail
loader.loadClip(PICPATH + picnames[ipic] + ".jpg",
thumbs_mc["mc"+ipic]);
// listener function to handle broadcast progress messages
// make pct_txt show cumulative loading progress
function onLoadProgress(_mc:MovieClip, loaded:Number) {
var loadedsofar:Number = totalloaded + loaded;
pct_txt.text = Math.floor(loadedsofar / TOTALBYTES * 100) +
function init() {
// create holder for pictures
createEmptyMovieClip("pic_mc", 1);
pic_mc._x = PICX;
pic_mc._y = PICY;
// create (and draw) holder for thumbnails
createEmptyMovieClip("thumbs_mc", 2);
thumbs_mc.beginFill(0, 100); // black
thumbs_mc.moveTo(0, 0);
thumbs_mc.lineTo(2 * (MARGIN + THUMBW) * NPICS, 0);
thumbs_mc.lineTo(2 * (MARGIN + THUMBW) * NPICS, THUMBH);
thumbs_mc.lineTo(0, THUMBH);
thumbs_mc.endFill();
// drawing the thumb holder at 0, 0 and then moving it makes
its reg point = upper left
thumbs_mc._x = THUMBHOLDERX;
thumbs_mc._y = THUMBHOLDERY;
// create, draw and enable mask over thumbs (could use
different variables to define mask
// if desired)
createEmptyMovieClip("mask_mc", 3);
mask_mc.beginFill(0x0000cc, 100);
mask_mc.moveTo(0, 0);
mask_mc.lineTo(MASKW, 0);
mask_mc.lineTo(MASKW, MASKH);
mask_mc.lineTo(0, MASKH);
mask_mc.endFill();
mask_mc._x = MASKX;
mask_mc._y = MASKY;
thumbs_mc.setMask(mask_mc);
// create loading textfield indicator
createTextField("pct_txt", 4, 200, 100, 40, 100);
var tf:TextFormat = new TextFormat();
tf.align = "center";
tf.size = 12;
tf.font = "Verdana";
tf.color = 0xFFFF00;
pct_txt.setNewTextFormat(tf);
// make empty movieclips in thumbs_mc for each pic to go
into
// make double the number so the slider can move
continuously and show content
for (var i:Number = 0; i < NPICS * 2; i++) {
var mc:MovieClip = thumbs_mc.createEmptyMovieClip("mc"+i,
i+1);
mc._x = i*(MARGIN + THUMBW);
mc._y = 0;
// set the pointer to the first jpg in the array picnames
ipic = 0;
// start loading jpgs (ipic is initialized to 0)
loader.loadClip(PICPATH + picnames[ipic] + ".jpg",
thumbs_mc["mc"+ipic]);
/********* CALL THE INIT FUNCTION TO START THE MOVIE
init();Hi,
Thanks for the quick reply.
The problem here is there variables are again used in calculating some other variable values either single value or intervals. Also there are many queries which use these variable I am discussing about. So, in this case it will be really hectic to change all these queries. Even though if we change these variable properties, I think as these are mandatory customer exit default value variables, there wont be any effect. If at all any exists can you please let me know what type?
What do you suggest?
Regards,
Ravi
Maybe you are looking for
-
HT4796 windows migration assistant has errors in preparing data on my PC
Hi, just got my new iMac and want to migrate files from my Windows XP machine using Windows Migration Assistant for Lion. It seemed to install OK on the PC but it will not run. It comes up with an message saying found errors in preparing data. Any id
-
I lost my iphone 5s installed with iOS7 and immediately turned on lost mode and erased it using icloud. But a week later i found it, now there is a message displayed whenever I turned on the phone that was suposed to warn the thief. Is there any way
-
Using Methods not Defined in a class that you are calling them from
For one of my assignment I have had to create a class with methods and then create another class to test the methods. I keep getting the error message "cannot resolve symbol" And the error points to the line where I am calling the class. I have put t
-
How to add drop down list in toolbar?
Hi SAP CRM Experts, After save the personalization of the view, there will be a drop down list appeared in the toolbar in the view, the drop value contain the personalization you just saved and the standard one. Could someone let me know how to enhan
-
Well I'm done typing, how do I get out of it?
Click another tool, wonderful, how about shortcuts? When I finish typing something, I'd much rather just press two buttons than drag the mouse over to a tool I don't need just to end the type. Is that really the only way out?