How to remove a function on the main timeline within a movie clip
How do you remove a function that is coded on a frame in the main timeline from within a movie clip? I tried this, but no dice:
infoGraphicDisparity.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene);
function fl_ClickToGoToScene(event:MouseEvent):void
parent.removeEventListener (Event.ENTER_FRAME, parent["enterFrameHandler"]);
MovieClip(this.root).gotoAndPlay("disparity");
this is the event I am trying to remove:
stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
any help would be appreciated as always.
Thanks!
from any frame (that executes after enterFrameHandler is defined) in any display object in the display list
stage.removeEventListener(Event.ENTER_FRAME, MovieClip(root).enterFrameHandler);
Similar Messages
-
Using Flach CS4 and action script 2.0 how do I advance to a specific frame of the main timeline when a movie clip instance come to the end of its timeline?
code on the last frame of your movieclip instance:
_root.gotoAndStop('whatever_frame'); // will work unless this swf is loaded into another swf. in that situation, you should use a relative path to the main timeline (eg, _parent or _parent._parent etc). -
How to play the main timeline after a movie clip is finished playing.
Ok so here is the problem, I have the main time line with three layers: My actions layer, a music layer, and the movie clip layer.
The movie clip is an actionscript movie which calls images from an external XML file and shows them as a slideshow. What i need to do is after the last image plays, stop the movie and move the main timeline to the next scene of the main movie. Everything logical in my brain is not working, and it may be that I have been staring at this project for too long but for the life of me i can't make this work.
Any help or input would be greatly appreciated!
Thanks in advance.
Meghanbetter yet, here is the whole code. With your suggestion entered...
import flash.display.BitmapData;
import gs.*;
import gs.easing.*;
import gs.plugins.*;
TweenPlugin.activate([BlurFilterPlugin]);
OverwriteManager.init();
var xml:XML = new XML();
xml.ignoreWhite = true;
_root.xmlPath == undefined ? xml.load("jake.xml") : xml.load(_root.xmlPath);
//when xml is loaded
xml.onLoad = function(succes:Boolean) {
if (succes) {
//position the slideshow. remember size.
__width = Number(xml.firstChild.attributes.width);
__height = Number(xml.firstChild.attributes.height);
mcMask._width = mcBlack._width=mcHyper._width=__width;
mcMask._height = mcBlack._height=mcHyper._height=__height;
//preloader
mcPreloader._x = __width/2;
mcPreloader._y = __height/2;
(new Color(mcPreloader).setRGB(Number(xml.firstChild.attributes.preloaderColor)));
//buttons
var buttonLoader:MovieClipLoader = new MovieClipLoader();
var buttonListener:Object = new Object();
buttonListener.onLoadInit = function(cButton:MovieClip) {
if (cButton._parent == btnNext) {
cButton._parent._x = __width-cButton._width;
} else if (cButton._parent == btnPrev) {
cButton._parent._x = 0;
} else {
cButton._parent._x = (__width-cButton._width)/2;
cButton._parent._y = (__height-cButton._height)/2;
buttonLoader.addListener(buttonListener);
buttonLoader.loadClip(xml.firstChild.attributes.prevButton,btnPrev.holder);
buttonLoader.loadClip(xml.firstChild.attributes.nextButton,btnNext.holder);
buttonLoader.loadClip(xml.firstChild.attributes.playButton,btnPlay.holder);
buttonLoader.loadClip(xml.firstChild.attributes.pauseButton,btnPause.holder);
xml.firstChild.attributes.slideshowOn == "true" ? [_slideshow=true, btnPlay._visible=false] : [_slideshow=false, btnPause._visible=false];
for (var i:Number = 0; i<xml.firstChild.childNodes.length; i++) {
//create empty movieclip for each picture. create mask movieclip for each picture. save transition and ken burns settings for each picture. save other properties for each picture.
mcTemp.createEmptyMovieClip("mcPhoto"+i,mcTemp.getNextHighestDepth());
mcHolder.createEmptyMovieClip("mcPhoto"+i,mcHolder.getNextHighestDepth());
mcHolder["mcPhoto"+i].createEmptyMovieClip("photo",mcHolder["mcPhoto"+i].getNextHighestDe pth());
//attach text clip and set it up
mcHolder.attachMovie("square2","mcBack",mcHolder.getNextHighestDepth());
mcText.attachMovie("text","text"+i,mcText.getNextHighestDepth());
mcText["text"+i].mcText._alpha = mcBack._alpha=0;
mcBack._width = mcText["text"+i].mcText._width=__width;
mcText["text"+i].mcText.autoSize = true;
mcBack._height = 0;
mcBack._y = __height;
(new Color(mcBack).setRGB(Number(xml.firstChild.attributes.textBackColor)));
mcHolder["mcPhoto"+i].transition = Number(xml.firstChild.childNodes[i].attributes.transition);
var burns:Array = String(xml.firstChild.childNodes[i].attributes.kenBurns).split(";");
mcHolder["mcPhoto"+i].burns = burns;
mcHolder["mcPhoto"+i].time = Number(xml.firstChild.childNodes[i].attributes.time);
mcHolder["mcPhoto"+i].src = String(xml.firstChild.childNodes[i].attributes.src);
mcHolder["mcPhoto"+i].txt = String(xml.firstChild.childNodes[i].firstChild.nodeValue);
mcHolder["mcPhoto"+i].url = String(xml.firstChild.childNodes[i].attributes.url);
mcHolder["mcPhoto"+i].target = String(xml.firstChild.childNodes[i].attributes.target);
//handle loading process. create loader objects. start "intelligent loading". set methods and actions for new newly loaded pictures.
var photoLoader:MovieClipLoader = new MovieClipLoader();
var photoListener:Object = new Object();
photoListener.onLoadInit = function(cPhoto:MovieClip) {
//transform image to bitmap
cPhoto._visible = false;
var tempBitmap:BitmapData = new BitmapData(cPhoto._width, cPhoto._height);
tempBitmap.draw(cPhoto);
var cPhoto2:Object = mcHolder["mcPhoto"+_loaded].photo;
cPhoto2.attachBitmap(tempBitmap,1,"auto",true);
photoLoader.unloadClip(cPhoto);
removeMovieClip(cPhoto);
cPhoto2._parent._visible = false;
//remember original size
cPhoto2._parent.width2 = cPhoto2._parent._width;
cPhoto2._parent.height2 = cPhoto2._parent._height;
cPhoto2._alpha = 0;
_loaded++;
cPhoto2._parent.loaded = true;
if (_loaded<xml.firstChild.childNodes.length) {
//load next picture
photoLoader.loadClip(mcHolder["mcPhoto"+_loaded].src,mcTemp["mcPhoto"+_loaded]);
if (_loaded == _index+1) {
//show this picture
showPicture(cPhoto2._parent);
photoLoader.addListener(photoListener);
photoLoader.loadClip(mcHolder.mcPhoto0.src,mcTemp.mcPhoto0);
//function that changes to the next photo(slideshow feature)
function nextPhoto() {
_index++;
if (_index == xml.firstChild.childNodes.length) {
//if picture is loaded, just show it. if not, wait until it loads
if (mcHolder["mcPhoto"+_index].loaded) {
showPicture(mcHolder["mcPhoto"+_index]);
} else {
TweenLite.to(mcPreloader,.5,{_alpha:0});
TweenLite.to(mcBlack,.5,{_alpha:100,onComplete:completeF});
function completeF(){
_root.gotoAndPlay("frame1_scene2");
//function that changes to the previous photo
function prevPhoto() {
_index--;
if (_index == -1) {
_index = xml.firstChild.childNodes.length-1;
//if picture is loaded, just show it. if not, wait until it loads
if (mcHolder["mcPhoto"+_index].loaded) {
showPicture(mcHolder["mcPhoto"+_index]);
} else {
TweenLite.to(mcPreloader,.5,{_alpha:100});
TweenLite.to(mcBlack,.5,{_alpha:80});
//buttons - roll overs
btnNext.onRollOver = btnPrev.onRollOver=btnPause.onRollOver=btnPlay.onRollOver=function () {
TweenLite.to(this,1,{_alpha:70});
btnNext.onRollOut = btnPrev.onRollOut=btnPause.onRollOut=btnPlay.onRollOut=btnNext.onReleaseOutside=btnPrev.o nReleaseOutside=btnPause.onReleaseOutside=btnPlay.onReleaseOutside=function () {
TweenLite.to(this,1,{_alpha:100});
//buttons - next
btnNext.onPress = function() {
if (!_transition) {
clearTimeout(nextT);
nextPhoto();
} else {
clearTimeout(nextT);
nextT = setTimeout(nextPhoto, 500);
//buttons - previous
btnPrev.onPress = function() {
if (!_transition) {
clearTimeout(nextT);
prevPhoto();
} else {
clearTimeout(nextT);
nextT = setTimeout(prevPhoto, 500);
//buttons - play
btnPlay.onPress = function() {
switchVisible(btnPlay);
switchVisible(btnPause);
_slideshow = true;
if (!_transition) {
clearTimeout(nextT);
nextPhoto();
} else {
clearTimeout(nextT);
nextT = setTimeout(nextPhoto, 500);
//buttons - pause
btnPause.onPress = function() {
switchVisible(btnPlay);
switchVisible(btnPause);
_slideshow = false;
clearTimeout(nextT);
//function that animates text(html for each picture)
function inText(cPhoto:Object) {
if (cPhoto.txt != "undefined") {
mcText["text"+_index].mcText.htmlText = cPhoto.txt;
mcText["text"+_index].mcText._y = mcBack._y-mcText["text"+_index].mcText._height-4;
TweenMax.to(mcText["text"+_index].mcText,0,{blurFilter:{blurX:15, blurY:15, quality:1}});
TweenMax.to(mcText["text"+_index].mcText,Number(xml.firstChild.attributes.textSpeed),{blu rFilter:{blurX:0, blurY:0}, _alpha:100});
TweenLite.to(mcBack,Number(xml.firstChild.attributes.textSpeed),{_alpha:Number(xml.firstC hild.attributes.textBackOpacity), _height:mcText["text"+_index].mcText._height+7});
} else {
mcText["text"+_index].mcText.htmlText = "";
TweenLite.to(mcBack,Number(xml.firstChild.attributes.textSpeed),{_alpha:Number(xml.firstC hild.attributes.textBackOpacity), _height:0});
function outText(cPhoto:Object) {
TweenLite.to(mcBack,.5,{_alpha:0});
TweenLite.to(mcText["text"+_index2].mcText,.5,{_alpha:0});
//function that applies the ken burns effect to a specific photo
function kenBurns(cPhoto:Object) {
//reset size and position
cPhoto.photo._xscale = cPhoto.photo._yscale=Number(cPhoto.burns[0]);
cPhoto.photo._x = returnPosition(cPhoto.burns[2], cPhoto.photo._width, cPhoto.photo._height, mcMask._width, mcMask._height).__x;
cPhoto.photo._y = returnPosition(cPhoto.burns[2], cPhoto.photo._width, cPhoto.photo._height, mcMask._width, mcMask._height).__y;
//start effect
TweenLite.to(cPhoto.photo,cPhoto.transition+Number(cPhoto.time)+1,{_xscale:Number(cPhoto. burns[1]), _yscale:Number(cPhoto.burns[1]), _x:returnPosition(cPhoto.burns[3], cPhoto.width2, cPhoto.height2, mcMask._width, mcMask._height).__x, _y:returnPosition(cPhoto.burns[3], cPhoto.width2, cPhoto.height2, mcMask._width, mcMask._height).__y, ease:Linear.easeNone});
//function that shows a picture(transition function)
function showPicture(cPhoto:Object) {
for (var i:Number = 0; i<xml.firstChild.childNodes.length; i++) {
if (i == _index || i == _index2) {
mcHolder["mcPhoto"+i]._visible = true;
}else{
mcHolder["mcPhoto"+i]._visible = false;
cPhoto.swapDepths(mcHolder.getNextHighestDepth());
setTimeout(hideOld,cPhoto.transition*1000,mcHolder["mcPhoto"+_index2]);
//text
outText(mcHolder["mcPhoto"+_index2]);
_index2 = _index;
inText(cPhoto);
kenBurns(cPhoto);
TweenLite.to(mcPreloader,.5,{_alpha:0});
TweenLite.to(mcBlack,.5,{_alpha:0});
//transition variable
_transition = true;
clearTimeout(transT);
transT = setTimeout(switchTransition, cPhoto.transition*1000);
cPhoto.photo._alpha = 0;
TweenLite.to(cPhoto.photo,cPhoto.transition,{_alpha:100});
if (_slideshow) {
//if slideshow is on
nextT = setTimeout(nextPhoto, (cPhoto.transition+cPhoto.time)*1000);
function hideOld(what:Object){
//hyperlinks
mcHyper.useHandCursor = true;
mcHyper.onPress = function() {
if (mcHolder["mcPhoto"+_index].url != "undefined") {
getURL(mcHolder["mcPhoto"+_index].url, mcHolder["mcPhoto"+_index].target);
//function that returns a number position from a given "compass position"(for the ken burns effect)
function returnPosition(pos:String, __width:Number, __height:Number, __width2:Number, __height2:Number):Object {
var returnObj:Object = new Object();
switch (pos) {
case "TL" :
returnObj.__x = 0;
returnObj.__y = 0;
break;
case "TC" :
returnObj.__x = -(__width-__width2)/2;
returnObj.__y = 0;
break;
case "TR" :
returnObj.__x = -(__width-__width2);
returnObj.__y = 0;
break;
case "ML" :
returnObj.__x = 0;
returnObj.__y = -(__height-__height2)/2;
break;
case "MC" :
returnObj.__x = -(__width-__width2)/2;
returnObj.__y = -(__height-__height2)/2;
break;
case "MR" :
returnObj.__x = -(__width-__width2);
returnObj.__y = -(__height-__height2)/2;
break;
case "BL" :
returnObj.__x = 0;
returnObj.__y = -(__height-__height2);
break;
case "BC" :
returnObj.__x = -(__width-__width2)/2;
returnObj.__y = -(__height-__height2);
break;
case "BR" :
returnObj.__x = -(__width-__width2);
returnObj.__y = -(__height-__height2);
break;
return returnObj;
function switchTransition() {
_transition == true ? _transition=false : _transition=true;
function switchVisible(obj:Object) {
obj._visible == true ? obj._visible=false : obj._visible=true;
mcTemp._x = -10000;
//mouse testing
var mouse_dx:Number = _xmouse;
var mouse_dy:Number = _ymouse;
var mouseSpeed:Number = 1;
function checkPosition(Void):Void {
if (_xmouse<mouseSpeed || _xmouse>(Stage.width-mouseSpeed) || _ymouse<mouseSpeed || _ymouse>(Stage.height-mouseSpeed)) {
//mouse outside - hide buttons
TweenLite.to(btnPrev,.5,{_alpha:0});
TweenLite.to(btnNext,.5,{_alpha:0});
TweenLite.to(btnPlay,.5,{_alpha:0});
TweenLite.to(btnPause,.5,{_alpha:0});
} else {
//mouse inside
TweenLite.to(btnPrev,.5,{_alpha:100});
TweenLite.to(btnNext,.5,{_alpha:100});
TweenLite.to(btnPlay,.5,{_alpha:100});
TweenLite.to(btnPause,.5,{_alpha:100});
checkPosition(Void);
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function():Void {
mouse_dx = Math.abs(mouse_dx-_xmouse);
mouse_dy = Math.abs(mouse_dy-_ymouse);
mouseSpeed = mouse_dx>mouse_dy ? mouse_dx : mouse_dy;
mouseSpeed += 1;
checkPosition(Void);
mouse_dx = _xmouse;
mouse_dy = _ymouse;
Mouse.addListener(mouseListener);
//global variables
var this2:Object = this;
var __width:Number;
var __height:Number;
var _index:Number = 0;
var _index2:Number = -1;
var _loaded:Number = 0;
var nextT:Number;
var transT:Number;
var _slideshow:Boolean = true;
var _transition:Boolean = false;
Stage.scaleMode = "noScale";
Stage.showMenu = false;
Stage.align = "TL"; -
Hello All,
I am working on ECC 6.00 SD module
I want to add partner function in the main screen of the sales order, that mean add more partner function beside Sold to party and the ship to party to be in the order header, Is it possible and how?
Regards
Jacopo FrançoiseHi
If you want in the sales order , above the sold to party as the box then you need to go for enhancements
Regards
Srinath
Edited by: sri nath on Jun 11, 2008 6:56 PM -
Load a MC on the main timeline from a MC. AS3
I have a movie clip (mc_menu) on that is on the main timeline.
This movie clip has buttons that I want to use to display other movie clips on the main (parent) timeline.Start here:
http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9 b90204-7e4e.html -
How do I set a variable on the main timeline from within a symbol?
Just getting started with Animate and coming to it from Flash, as may be apparent from my question. How do you set a variable to the main timeline from within a symbol?
I have 24 pairs of clickable elements, each in their own symbols, and all 24 of those symbols sit inside another symbol. I want all 24 to be able to set the same global variable when clicked. I can't find that this question is addressed anywhere, which makes me think I may be stuck in a Flash mindset and approaching the task in the wrong way. (There are however MANY discussions of how to address objects at different levels in the hierarchy. That's well covered.)
Relatedly, how do you access a function on the main timeline from within a symbol?
Adobe should consider putting together a support page (or pages) just for folks migrating form Flash. In the materials I've encountered so far there seems to be a studied effort to refrain from mentioning Flash in any way. I imagine there are a lot of people out there like me who have a deep background in Flash coding, but are just getting started with Animate. We don't need help with most of the basic concepts, but we may still have some pretty basic questions about how to accomplish some things in Animate because our Flash knowledge is getting in the way.Hi Bill,
There are plenty of threads on here about scope, but here's one way to create a global variable:
// code on Stage.compositionReady
sym.myGlobalVar = 1;
Then, anywhere in your project, you can check/set that var like so:
sym.getComposition().getStage().myGlobalVar = 2;
And here's one way to create a global function:
// code on Stage.compositionReady
sym.myGlobalFunction = function(){
console.log('myGlobalFunction');
Then, anywhere in your project, you can call that function like so:
sym.getComposition().getStage().myGlobalFunction(); -
Controlling a Movie Clip on the Main Timeline from a loaded SWF?
Is it possible to control a MovieClip on the main timelne from another loaded clip?
I see posts that control loaded clips, but most are all from the loader in the main timeline. I have a moviclip on the main timeline that I want to make visible or invisible depending on what keyframe is playing in another loaded swf.
If I try to call the movieClip from the loaded SWF I get "error #1119. Access of possibly undefined property...." because it doesn't exist in the loaded SWF, just the main timeline.
The old AS2 way just used "_root". Since "_root" doesn't exist any more, how do you control items on the main TimeLine from a loaded SWF?I am not clear what you mean because you are saying you are trying to target a movieclip that does not exist where you are trying to target it.
Try using a trace to see what you are targeting when you you target the MovieClip(parent.parent)....
trace(MovieClip(parent.parent));
The other approach I mentioned earlier is the more OOP-correct approach if you would rather try that way. Here's a rough outline of it...
AS3 - Dispatch Event
http://forums.adobe.com/thread/470135?tstart=120
Example:
Add something to trigger the event in the child (your loaded swf):
dispatchEvent(new Event("eventTriggered")); (
if dispatchEvent problem, see: http://www.kirupa.com/forum/showthread.php?p=1899603#post1899603)
In your loading/parent swf, listen for the complete event on the Loader.contentLoaderInfo. In the complete event handler, add a listener for the event on the loaded swf.
// event handler triggered when external swf is loaded
function loaderCompleteHandler(event:Event) {
MovieClip(event.currentTarget.content).addEventListener("eventTriggered", eventHandler);
function eventHandler(event:Event):void {
trace("event dispatched in loaded swf");
// this is where your main file can set the visible property of your movieclip -
Using cue points to trigger events on the main timeline...
Hi--
I have successfully placed an flv (video) file (progressive
download) on the main timeline of my movie with controls to play
and pause (Flash 8 Professional). So far, so good!
NOW TWO PROBLEMS: Does anyone know how to set it up so that
when a specific cue point is reached in the video, it triggers an
action on the main timeline? In this case, once the video is over,
I want the main timeline to gotoAndPlay frame 3. Specific script to
do this would be great!
The other action I'd like to happen is that when the video
begins, it targets a scrolling text mc ("text") in the main
timeline and tells it to gotoAndPlay frame 2.
Any advice would be GREATLY appreciated!!! Many
thanks!!!I usually start off solving problems with the livedocs, as I
recommend for anyone. The following link will take you to the
NetStream.onCuePoint handler. This is what you need.
http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context= LiveDocs_Parts&file=00002561.html
You can have this code on the main timeline. When the
cuepoint is hit, it will invoke this event handler and inside is
where your gotoAndPlay( ) should go.
Your other question about the text will get activated by the
same handler. Just have a conditional statement (if, switch, etc.)
to differentiate between the two events. The text itself can be
mask inside a movieclip.
Does this help? -
How to call a function in a class from the main timeline?
Hey Guys
I have a project in Flash with four external AS files, which are linked to items in the library using AS linkage.
What I want to do is call a function in one of these files from the main timeline, how would I go about doing this? I'm not currently using a document class, most of the code is in Frame 1 of the main timeline.
Thanks// change type to the class name from the instance
ClassNameHere(this.getChildByName('instance_name')).SomeFunction(); -
How can I reference the main timeline on a swf once it was loaded into another?
I have an swf with some custon animation functions using actionscript 3. I'm refering to the main timeline with Movieclip(root) and it works just fine.
However, this swf is going to be loaded inside another (a custom player), and when that happends, everything stops working.
I think it's because the Movieclip(root) is now referencing to the loader swf and not the loaded anymore, but I just can't find any information on how to fix that.This is basically what I´m doing here:
I'm placing this code on frame 1, and calling the function textAnimate() whenever I need to insert some text.
// This is a variable I created for tracking the timeline
var base:MovieClip = MovieClip(root);
function textAnimate(movieName:String, espera:Number):void {
//var espera:Number = 1; //Waiting time
var objeto:MovieClip = base[movieName]; //Variable to select the object
var posFinal:Number = objeto.x; // Object position
var posEnter:String = "-160"; // Animation start (relative)
var posExit:String = "+160"; // Animation end (relative)
// enter animation
TweenMax.from(objeto, 1, {x:posEnter, alpha:0, blurFilter:{blurX:40}, ease:Back.easeOut});
//call exitAnimation() after X seconds
TweenMax.delayedCall(espera,exitAnimation);
//exit animation
function exitAnimation() {
TweenMax.to(objeto, 1, {x:posExit, alpha:0, blurFilter:{blurX:40}, ease:Back.easeIn});
The swf works fine, but once it´s loaded into the player, nothing works anymore. Unfortunately, I don't have the code for the player, and can't change anything about it... :/ -
I am making a website based in flash actionscript 3.0 i have a button nested in its own movie clip, because I have the button expanding to be able to read it i have figured out the only way to do this is by creating it as a movie clipa nd inside the movie clip creating it as a button
I added an event listener to the blog button by saying,
blog.addEventListener(MouseEvent.ROLL_OVER,gotoblog);
function gotoblog(evtobj:MouseEvent){
gotoAndStop(2)
this part of the code works it goes to the 2nd frame of the timeline it is in and stops wich is a blown up version of the origanal symbol
i added on frame 2 a second command
blog.addEventListener(MouseEvent.CLICK.gotoblogpage);
function gotoblogpage(evtobj:MouseEvent){
gotoAndStop("blogframe")
trace("the blog button was clicked")
i have named the symbol blog and have name the frame of where the blog page is going to be "blogframe" this line of code at the bottom is where i run into trouble the output window in Flash is saying "The blog button was clicked" just like i want it to. no errors are accouring why than is the playhead not going to frame "blogframe"? if the button is working when i click it the code is right i belive the problem here is it does not want the playhead to go to the frame i want it to. So i gues my question is, how can i make a button withing a movie clip interact with the main timeline?I have a similar problem if could please help me i'd really apreciate it!!
So i have a looping animation of some thumbnails, the hierarchy goes like this
Scene1(main timeline) -> imgBar(MC)->imgBarB(MC within the imgBar MC)
My buttons symbols are in the last MC "imgBarB" where i have this code:
ss1.addEventListener(MouseEvent.CLICK, OneButtonClicked);
function OneButtonClicked(event:MouseEvent):void{
MovieClip(root).gotoAndStop("ssbox1");
I want to control the Btns in my "imgBarB" MC to play a labeled frame(named "ssbox1") on another MC on the main timeline,this other MC goes like this:
Scene1(main timeline)->ssbox_mc(MC where my labeled frame is) -
Calling a function in the main movie from a loaded swf
I realize this is probably a very basic question, but I have
loaded a SWF file into another movie. I now want to call a function
in the main SWF. Is there a way to do that? Alternatively, I have a
custom class where I could put the function, but I haven't been
able to figure out how to call it from the loaded SWF either. Do I
somehow need to associate the class with the main movie,
or...?Never mind - I was doing something very stupid and wasn't
calling the function as a method of a movie clip. I was simply
calling checkTarget(event) rather than
event.currentTarget.checkTarget(event); which seems to work. -
How do you reference the main timeline of swf1 from swf2 when swf2 is loaded into swf1?
on this link http://kb2.adobe.com/community/publishing/918/cpsid_91887.html
I found this script, but I can not use it can anyone help me
// create a variable to reference swf1's main timeline
var swf1Main_mc:MovieClip; // this assumes that swf1 is a movieclip.
// create your listener to ensure this loaded swf has been added to the display list and can therefore obtain a
// reference to its main timeline (which is always the main timeline of the loading swf).
this.addEventListener(Event.ADDED_TO_STAGE, initF);
function initF(e:Event):void{
swf1Main_mc = MovieClip(this.root);You don't make it clear what event finish is for. But let's assume that your MC is being loaded from the clip that you're referring to as root. In the main Document Class of that swf, you'd have
protected var customSwf:CustomSwf;//customSwf is the Class that defines your functionInSwf1protected function someFunction():void {
var loader:Loader = new loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE onLoaderLoaded);
//rest of your loader loading code here
protected function onLoaderLoaded(e:Event):void {
//add to display list (you already know how to do, so I'm not writing the code)
EventDispatcher(e.target).removeEventListener(Event.Complete, onLoaderLoaded);
//if you had a legitimate need for path (which you don't) in mcExternal, you'd set it like this:
this.mcExternal.path = LoaderInfo(e.target).content as MovieClip;
//this is what you actually need to care about to do this correctly
customSwf = LoaderInfo(e.target).content as CustomSwf;
Now, the Class that you apply to the library symbol you're using for mcExternal should have code similar to this:
protected function fEvent(e:Event):void {
dispatchEvent(new Event('giveYourEventADescriptiveNameBasedOnWhatYoureReallyDoingHere', true));
back in your main document Class:
//should probably call from the constructor or somewhere early in the process
protected function init():void {
//use your real event name--your code isn't expressive enough I could guess a good name
addEventListener('giveYourEventADescriptiveNameBasedOnWhatYoureReallyDoingHere', onEventHappened);
protected function onEventHappened(e:Event):void {
customSwf.customFunctioninSwf1();
customSwf.changeVisualState();//let custom swf change alpha and change the frame #
To the untrained I, this looks like about the same amount of code and slightly more trouble, but changing the design like this will make it much more tolerant of the changes that nearly all clients will want after you've built version 1. mcExternal's code doesn't have to change at all if swf1 changes, and your root Class already knows abotu swf1 anyway, since it's doing the loading, so having it work with it a little more doesn't hurt.
Moving the change of visual state into your custom swf means that changes in that swf won't affect your main document Class, though you will probably have to recompile the main document unless you go to using an Interface (a topic for another day). -
Toolkit for CreateJS: How to control the main timeline from outside the canvas.
Hey Everyone,
I'm currently trying to do something simple, but my animation breaks whenever I attempt to change my code. I have created a basic animation in Flash where an object moves from the left side of the canvas, to the right, and then loops from the last frame to the first frame. Nothing else. The animation is simply put on the main timeline. I exported the animation with Toolkit for CreateJS through Flash's extension and the animation runs as it should. I am trying to start and stop (restarting from the first frame) the animation with mouse over and mouse off events. I want the events to fire when moused over/off a div OUTSIDE the animation's canvas tag. Is this possible with CreateJS? I'm trying to figure out how to control the main timeline without being inside the canvas tag.
Example HTML:
http://www.thephotoncore.com/testing/example_test.html
Example Code:
<section id="container">
<canvas id="canvas" width="550" height="400" style="background-color:#cccccc"></canvas>
<section id="animation_control">
<p>Roll over to start and stop animation.</p>
</section>
</section>
Thanks again for the help!
-DJHi DjPhantasy5,
All movieclips on the stage are children of the stage,
So on the "mouseover" all movieclips on the stage could be stopped with stop and on the "mouseout" all children could be restarted with gotoAndPlay like this:
function Stop()
if (stage && stage.children)
var i, l = stage.children.length;
for (i = 0; i < l; i++)
var child = stage.children[i];
if ("stop" in child)
child.stop();
function Restart()
if (stage && stage.children)
var i, l = stage.children.length;
for (i = 0; i < l; i++)
var child = stage.children[i];
if ("gotoAndPlay" in child)
child.gotoAndPlay(0);
See http://www.liauw.nl/forums/adobe/djfantasy5/index.html
But it is also possible to expose "ball1", for example, by adding it to the document.
This can be done by adding code to "ball1" like so:
/* js
document.ball1 = this;
Then the stopping of the animation would look like:
function Stop()
if ("ball1" in document)
document.ball1.stop();
etc.
Have fun!
Ronald -
How to remove available downloads from the list
how to remove available downloads from the list without it resuming when i open itunes or check for available downloads?
There is not a way to remove them from the list. Just let them download, and then delete them from your library when they are done.
Maybe you are looking for
-
Actual line items report for multiple products
Hi All, We have 4 manufacturing plants and 100 fg /sfg materials are being amnufactured for each of the plants. Now we want to see the total actual cost incurred report for each of the fg/sfg materials for each plant in a single report. Kindly share
-
Is there a way to delete multiple photos from your iPhone?
I'm trying to free up some space on my iPhone by deleting photos. It is taking me forever though because I have to select them one by one to delete them and then do the same thing to permanently delete them. Is there a quicker solution?
-
Command F [find] function not working in Word 2011
It seems that my Command F function is not working properly...when I look for a term that I KNOW is in my document, sometimes it won't locate it. Sometimes it will only locate one instance of the word [in the sidebar] when the word actually appears m
-
Regarding directory structure in sap
At OS level in which directory oracle alerts are stored?
-
Hi; I searched the portal but could not find the solution about my problem which is WLC 526's corrupted image. Available commands : rub> help blocklist FILE boot bootp [--with-configfile] cat FILE chainloader [--force] FILE color NORMAL [HIGHLIGHT] c