Resize handler randomly works?!


Hi all.

I have a main swf which I load in a few different external swf. For each of the external swf I have resize handlers which make sure my loaded swf are position in the correct place when window is resized. It works almost perfect.. but let say 1 out of 4 times the resize handler stops and nothing happens. Why does it sometimes work only

I know I should not have function within a function but in this case I do not know how to do it in any other way!

I have attached the code for one of the functions:

Thankful for all advice.

Code: function eventsLoaded(event:Event):void { mcExt = MovieClip(contentLoader.contentLoaderInfo.content) loadedMovieClip="events"; preloader_mc.visible = false; this.stage.addEventListener(Event.RESIZE, resizeEvent, false,0,true); eventsBG_mc.width = stage.stageWidth; eventsBG_mc.height=stage.stageHeight; eventsBG_mc.x=stage.stageWidth; contentLoader.x=stage.stageWidth; contentLoader.y=stage.stageHeight/2-contentLoader.height/2; addChild(eventsBG_mc); addChild(contentLoader); var timeline:TimelineLite = new TimelineLite(); timeline.append( new TweenLite(contentLoader, 1, {x:305, ease:Sine.easeOut}) ); timeline.append( new TweenLite(eventsBG_mc, 1, {x:305, delay:-1, ease:Sine.easeOut}) ); //resize handler function resizeEvent(){ eventsBG_mc.height=stage.stageHeight; contentLoader.y=stage.stageHeight/2- contentLoader.height/2; } }
Posted On: Thursday 3rd of January 2013 10:20:40 PM Total Views:  301
View Complete with Replies

RELATED TOPICS OF Flash / ActionScript PROGRAMMING LANGUAGE




mc isn't located orrectly until browser is resized

Hi , New to posting on Kirupa. I do read through older posts and threads for help but I haven't found a great answer to my little problem, so I thought I'd post. I have a full-browser flash site, with a movie clip horizontal nav bar at the bottom of the page. I've got everything working well (the background rescaling to fill the browser when the browser window size changes, the horizontal nav bar at the bottom....) for the most part. One thing is really getting to me however. Check out the example I made here: http://www.rachelahampton.com/mon.html Upon loading, the nav bar sits in the middle of the page. The moment you re-size the browser, it pops into the deed location near the bottom and stays there, even if you continue to re-size. However I want it to appear where it should at the bottom of the window on page load, without having to re-size the browser window. In the following code, main is the placeholder for the image slideshow that runs in the full browser, menu_mc is the menu. import com.greensock.TweenLite; import fl.motion.easing.*; import flash.events.MouseEvent; //set stage for FBF //set stage for FBF stage.align = "TL"; stage.scaleMode = "noScale"; //define dynamic aspect ratios var mainHeight = main.height / main.width; var mainWidth = main.width / main.height; //add event listener to the stage stage.addEventListener(Event.RESIZE, sizeListener); //conditional statement to account for various initial browswer sizes and proportions function scaleProportional():void { if ((stage.stageHeight / stage.stageWidth) < mainHeight) { main.width = stage.stageWidth; main.height = mainHeight * main.width; } else { main.height = stage.stageHeight; main.width = mainWidth * main.height; }; } //center picture on stage function centerPic():void { main.x = stage.stageWidth / 2; main.y = stage.stageHeight / 2; } // make listener change picture size and center picture on browser resize function sizeListener(e:Event):void { scaleProportional(); centerPic(); } //run initial locations and size scaleProportional(); centerPic(); stage.addEventListener(Event.RESIZE, resizeListener); function resizeListener (e:Event):void { menu_mc.x = 960; menu_mc.y = stage.stageHeight-75; } TweenLite.to(main, 1, {alpha:1}); TweenLite.to(menu_mc, 1, {alpha:1});
VIEWS ON THIS POST

168

Posted on:

Thursday 25th October 2012
View Replies!

Using an event handler to call multiple events you want (temporarily) invisible

Is there a tutorial out there on a way to use an event handler (i.e. a button) to call up one visible event, and another number (i.e. three ">) more) to be invisible on the stage, with the other invisible items to be made visible by another button (or buttons) I've had an idea I've been experimenting with for awhile that I've not yet made work...now I'm trying a different tactic.
VIEWS ON THIS POST

216

Posted on:

Thursday 25th October 2012
View Replies!

call an event handler function with out useing eventListener?

I want to call the same event handler function with a click and also with a custom event. the problem is the event type that needs to be passed to the function. Is there are generic event type that can be used to call the function from both places Code: menuBtn.addEventListener(MouseEvent.CLICK, menuOpen ); function menuOpen(event:MouseEvent){ trace("yes"); } function otherFunction(e:CustomEventClass){ menuOpen(); }
VIEWS ON THIS POST

78

Posted on:

Thursday 25th October 2012
View Replies!

I have a problem with position object when use event.resize

Hi Guys, I'm a newbie in flash as3. And also now I have some problem when expanded with browser scale then my text menu will overlap away. How can i reset the position here is screen, import fl.transitions.easing.*; import fl.transitions.*; import flash.text.TextField; stage.scaleMode = "noScale"; stage.align = "TL"; stage.addEventListener(Event.RESIZE,sizeHandlers); stage.dispatchEvent(new Event(Event.RESIZE)); var logo:MovieClip = new mcLogo(); logo.x = logo.y =10; this.addChild(logo); var home:MovieClip; var work:MovieClip; var what:MovieClip; var who:MovieClip; var careers:MovieClip; var contact:MovieClip; function sizeHandlers(e:Event){ home= new mainMenu(); home.x = stage.stageWidth - 40; home.y = 40; this.addChild(home); work= new mainMenu(); this.addChild(work); work.txt1.text="THE WORK"; work.txtButton.txt2.text ="THE WORK"; work.x =home.x; work.y =home.y+25; what= new mainMenu(); this.addChild(what); what.txt1.text="WHAT WE DO"; what.txtButton.txt2.text ="WHAT WE DO"; what.x =work.x; what.y =work.y+25; who = new mainMenu(); this.addChild(who); who.txt1.text="WHO WE ARE"; who.txtButton.txt2.text ="WHO WE ARE"; who.x =what.x; who.y =what.y+25; careers = new mainMenu(); this.addChild(careers); careers.txt1.text="CAREERS"; careers.txtButton.txt2.text ="CAREERS"; careers.x =who.x; careers.y =who.y+25; contact = new mainMenu(); this.addChild(contact); contact.txt1.text="CONTACT"; contact.txtButton.txt2.text ="CONTACT"; contact.x =careers.x; contact.y =careers.y+25; home.buttonMode = true; home.useHandCursor = true; home.mouseChildren = false; what.buttonMode = true; what.useHandCursor = true; what.mouseChildren = false; work.buttonMode = true; work.useHandCursor = true; work.mouseChildren =false; who.buttonMode = true; who.useHandCursor = true; who.mouseChildren = false; careers.buttonMode = true; careers.useHandCursor =true; careers.mouseChildren =false; contact.buttonMode =true; contact.useHandCursor =true; contact.mouseChildren =false; home.addEventListener("mouseOver", mouseRollOver); what.addEventListener("mouseOver", mouseRollOver); work.addEventListener("mouseOver", mouseRollOver); who.addEventListener("mouseOver", mouseRollOver); careers.addEventListener("mouseOver", mouseRollOver); contact.addEventListener("mouseOver", mouseRollOver); home.addEventListener("mouseOut", mouseRollOut); what.addEventListener("mouseOut", mouseRollOut); work.addEventListener("mouseOut", mouseRollOut); who.addEventListener("mouseOut", mouseRollOut); careers.addEventListener("mouseOut", mouseRollOut); contact.addEventListener("mouseOut", mouseRollOut); home.addEventListener("click", mouseClick); what.addEventListener("click", mouseClick); work.addEventListener("click", mouseClick); who.addEventListener("click", mouseClick); careers.addEventListener("click", mouseClick); contact.addEventListener("click", mouseClick); resizePosition(); //stage.addEventListener(Event.RESIZE,resizePosition ); } function mouseRollOver(e:MouseEvent){ var easingFunc = Back.easeOut; var ysa = 39.8; var yfa =10.8; var duration =0.5; var myTween:Tween = new Tween(e.target.txtButton, "y", easingFunc, ysa, yfa, duration, true); var easingFunc2 = Regular.easeOut; var ysa2 = -18.8; var yfa2 = -45.8; var duration2 =0.5; var myTween2:Tween = new Tween(e.target.txt1, "y", easingFunc2, ysa2, yfa2, duration2, true); } function mouseRollOut(e:MouseEvent) { var easingFunc3 = Regular.easeOut; var ysa3 = 10.8; var yfa3 =39.8; var duration3 = 0.5; new Tween(e.target.txtButton, "y", easingFunc3, ysa3, yfa3, duration3, true); var easingFunc4 = Regular.easeOut; var ysa4 = -45.8; var yfa4 = -18.8; var duration4 = 0.5; new Tween(e.target.txt1, "y", easingFunc4, ysa4, yfa4, duration4, true); } function mouseClick(e:MouseEvent){ clearColor(); var colorOrange:uint = 0xFF6600; var colorGray:uint = 0xCCCCCC; switch (e.target){ case home: e.currentTarget.txt1.textColor=colorOrange; break; case work: e.currentTarget.txt1.textColor=colorOrange; break; case who: e.currentTarget.txt1.textColor=colorOrange; break; case what: e.currentTarget.txt1.textColor=colorOrange; break; case careers: e.currentTarget.txt1.textColor=colorOrange; break; case contact: e.currentTarget.txt1.textColor=colorOrange; break; default : e.currentTarget.txt1.textColor=colorGray; } } function clearColor():void{ home.txt1.textColor=0xCCCCCC; work.txt1.textColor=0xCCCCCC; what.txt1.textColor=0xCCCCCC; who.txt1.textColor=0xCCCCCC; careers.txt1.textColor=0xCCCCCC; contact.txt1.textColor=0xCCCCCC; } function resizePosition():void{ home.x = stage.stageWidth - home.y; work.x =home.x; what.x =work.x; who.x =what.x; careers.x =who.x; contact.x =who.x; }
VIEWS ON THIS POST

91

Posted on:

Thursday 25th October 2012
View Replies!

How do I resize a movieClip?

I understand that this is something really, really basic, but for all my Googling I can't seem to find a clear answer. I have a movieClip with around 1500px of vertical content inside (a grid of images). But when I trace its height, it says it's only 400px high. I need it to actually report a height of 1500px, or it doesn't scroll properly. But this doesn't work: Code: content.height = 1500; It stretches out the content. And this doesn't work: Code: content.height = 1500; content.scaleX = content.scaleY; It just makes the content HUUUUUUUGE. And, I mean, I understand that in Flash setting a width and height messes with the scale, so this should be entirely expected. But there has to be a way to set the height of a movieClip. One suggestion I found was to add another movieClip or sprite inside of the movieClip you're trying to set the height of. I added another movieClip with a height of 1500px, but it didn't have any affect: Code: var sizer:Sprite = new Sprite(); sizer.height = 1500; content.addChild(sizer); I still get around 400px. So, what's the correct way of doing this There's no way it could be this hard to do something as simple as set a height. What am I missing
VIEWS ON THIS POST

72

Posted on:

Thursday 25th October 2012
View Replies!

Stage minimum resize

I've got a resize listener where I change my movieclips' dimensions and positions Code: stage.addEventListener (Event.RESIZE, resizeListener); But how I set the minimum allowed resize of the stage I don't want the stage to be smaller than 1024x600 for example.
VIEWS ON THIS POST

65

Posted on:

Thursday 25th October 2012
View Replies!

AS3 works on mac but not pc

I've been working on a flash animation with some actionscript 3, which basically is the main.swf that calls upon 5 other swf and txt files that I am embedding into a web template. It all works fine on my mac but when I test on a pc I am able to call upon the other swfs and it pops up but the close button does not work. I assume that it has something to do with my actionscript with the children swf. But just in case I will show both. Main Code: stop(); var popUpLoader:Loader = new Loader(); function rcPopUp(event:MouseEvent):void{ popUpLoader.load(new URLRequest(event.target.name + ".swf")); addChild(popUpLoader); } discovery.addEventListener(MouseEvent.CLICK, rcPopUp); creative.addEventListener(MouseEvent.CLICK, rcPopUp); strat.addEventListener(MouseEvent.CLICK, rcPopUp); resultsmg.addEventListener(MouseEvent.CLICK, rcPopUp); horizon.addEventListener(MouseEvent.CLICK, rcPopUp); Children (There are 5 files but all with the same code except calling the txt) Code: stop(); var content_req:URLRequest = new URLRequest("strategy.txt"); var content_1dr:URLLoader = new URLLoader(content_req); content_1dr.addEventListener(Event.COMPLETE, onComplete); function onComplete(event:Event):void { content_txt.htmlText = event.target.data; } function scrollUp(event:MouseEvent):void { content_txt.scrollV --; } function scrollDown(event:MouseEvent):void { content_txt.scrollV ++; } up.addEventListener(MouseEvent.CLICK, scrollUp); down.addEventListener(MouseEvent.CLICK, scrollDown); import flash.events.MouseEvent; if(closeButton.hasEventListener(MouseEvent.CLICK) == false) closeButton.addEventListener(MouseEvent.CLICK , removeMe); function removeMe(evt:MouseEvent):void { closeButton.removeEventListener(MouseEvent.CLICK , removeMe); if(this.parent) this.parent.removeChild(this); } I tried debugging on a pc and went back to the browser and refreshed and it seemed to have worked. Checking on a browser that I did not just download the Flash debugger for does not work though. Any suggestions
VIEWS ON THIS POST

79

Posted on:

Thursday 25th October 2012
View Replies!

resize constrain

Heres my code //from circlecube blog function resizeMe(mj:MovieClip, maxW:Number, maxH:Number=0, constrainProportions:Boolean=true):void { maxH = maxH == 0 maxW : maxH; mj.width = maxW; mj.height = maxH; if (constrainProportions) { mj.scaleX < mj.scaleY mj.scaleY = mj.scaleX : mj.scaleX = mj.scaleY; } } function loaderComplete(myEvent:Event) { var loader = new Loader(); themovie.addChild(loader); loader.load(new URLRequest("2kro.jpg")); } this.loaderInfo.addEventListener(Event.COMPLETE, loaderComplete); resizeMe(themovie, 100, 300); ------------ Simple enough. But no picture loads unless I comment out the resizeme. An example of what I'm tring to achieve is putting a picture (i.e. 2kro.jpg) inside the center of a tv and a cellular phone pic (they both have different size and are on the same stage). I plan on doing this dynamically and got all the querystring-javascript-flashvar and html working and out of the way. But I'm stuck with the simple resizing I can't find a reason why this resizeme function isn't working.
VIEWS ON THIS POST

82

Posted on:

Thursday 25th October 2012
View Replies!

Simple event handler for MC (AS3)

This should be easy, but I am unable to make it work. I am simply trying to start a timer when a dynamic movieclip ("mySlide") has finished playing. Here's my code: Code: mySlide.addEventListener(Event.COMPLETE, startTimer); function startTimer(e:Event):void { trace ("timer started"); } I must be doing some simple thing wrong, as the COMPLETE event triggers nothing (whereas, ENTER_FRAME causes the trace statement to fire). What am I doing wrong here In a nutshell, what I am trying to accomplish is to have an MC play... then hold for a determinable amount of time, then script a new function which will replace the MC with a fresh MC.
VIEWS ON THIS POST

69

Posted on:

Thursday 25th October 2012
View Replies!

my Flash RSS Reader - works only sometimes

I have created a Flash (CS4) RSS Reader using actionscript 3 and posted the reader at the following URL: http://pacificempirecorporation.com/rss/rsstest.html On my home computer (Windows Vista) I can view all the Feeds in both IE and Firefox. Two other people I asked to test it (both using Windows XP) can view all but 4 of the feeds in IE (Sports, Lifestyle, Strange, Internet) but they can view all the feeds in Firefox. Can anyone help why this might be The .fla file is larger than the max filesize to include here, so if you need to view it you can get it from my rss directory (it's viewable) - the code you would want to look at would be the middle line rss content (rssfeedmc movieclip). Also can anyone let me know if they can view the feeds and if so or if not, include what browser and OS you are using I'd appreciate any and all help I can get with this. Thank you!
VIEWS ON THIS POST

85

Posted on:

Thursday 25th October 2012
View Replies!

My app works, but not when I load it into another swf??

I have a map application I've built using Flash CS4 and ActionScript 3 .as files. It's working fine on my local machine. I'm trying to build a preloader for it. My usual way of doing that is to create a shell .swf file which exists just to load the main movie and show the user preloading progress. Unfortunately, whenever I try to load in a movie that uses external .as files, stuff breaks. I'm assuming that it has to do with the LoaderContext and ApplicationDomain, but I've tried every ApplicationDomain option, and I always get the same errors. In my map application, I've got a constructor function called Imap() that simply calls an init() function which then sets everything in motion. As I said, when I run the map app, things run smoothly. When I load it into my loader swf, I get (the functions trace out their names as they begin to run): Imap() init() TypeError: Error #1009: Cannot access a property or method of a null object reference. at com.[domain].imap::Imap/init() at com.[domain].imap::Imap() The code in my (as yet uncompleted) preloader swf is: package { import flash.display.*; import flash.system.*; import flash.net.*; public class Preloader extends MovieClip { var loader:Loader = new Loader(); var outline:Sprite = new Sprite(); var fill:Sprite = new Sprite(); var w:Number = 100; var h:Number = 10; var loaderContext:LoaderContext = new LoaderContext() public function Preloader() { loaderContext.applicationDomain = new ApplicationDomain(); // I've also tried // new ApplicationDomain(ApplicationDomain.currentDomain) , // ApplicationDomain.currentDomain, and // new ApplicationDomain(null) // all to no effect [...] loader.load(new URLRequest("map.swf"), loaderContext); addChild(loader); } } } This problem has vexed me in the past as well, and I've never found a solution for it. If anyone could help me out, that would be great. As an alternative, if anyone would like to suggest a preloading solution that would avoid this whole problem, I would appreciate that as well.
VIEWS ON THIS POST

88

Posted on:

Thursday 25th October 2012
View Replies!

Preloader not working in Safari , works fine in Firefox?

my site is comprised of several images loaded dynamically and added to the display list. i declare a bunch of loaders on the first frame, and add a preloader progress listener to the largest image to have one preloader for all the assets. I then added a COMPLETE listener to the same image, and add that image, along with all the others in the onComplete function. i have two issue. the preloader doesnt work in Safari. but works fine in Firefox and i'm totally stumped on what it could be another compatibility issue that seems to be arising is that one of the galleries of my site which corresponds to the "drawn" link. also does not seem to be working in Safari, but works in Firefox. its a fairly simple xml based image gallery, which loads thumbs on to the stage, and then loads a larger version of each, when the corresponding thumbnail is clicked. the other galleries of the site work fine in safari, and are basically the same code wise. heres my code for the loading and preloader in the first frame Code: import caurina.transitions.*; stop(); // declaring loaders for BG images var backgroundImage:Loader = new Loader(); var _targetLoaderInfo:LoaderInfo; _targetLoaderInfo = backgroundImage.contentLoaderInfo; // preloader graphic var preloader:Preloader = new Preloader; var animationLink:galarrowleft = new galarrowleft; var digitalLink:galarrowright = new galarrowright; var sketchLink:sketchlink = new sketchlink; var resumeLink:resumeMainText = new resumeMainText; // loader instances for BG image assets var clouds1:Loader = new Loader(); var clouds2:Loader = new Loader(); var bottomPark:Loader = new Loader(); var topRibbon:Loader = new Loader(); var Haze:Loader = new Loader(); var digitalBG:Loader = new Loader(); var nightSky:Loader = new Loader(); var midCity:Loader = new Loader(); var stars:Loader = new Loader(); var moon:Loader = new Loader(); var sun:Loader = new Loader(); var topPlanet:Loader = new Loader(); var sketchBG:Loader = new Loader; var sketchBorderR:Loader = new Loader(); var sketchBorderL:Loader = new Loader(); var Title:Loader = new Loader(); // declaring a variable for the bytesloaded to bytesTotal ratio needed for preloader progress var _loadPercent:Number; //Loading initial BG images stars.load(new URLRequest("img/Site2dElements/nightOrn.png")); moon.load(new URLRequest("img/Site2dElements/moon.png")); midCity.load(new URLRequest("img/Site2dElements/site_BG_Mid5.png")); sketchBG.load(new URLRequest("img/Site2dElements/DigitalGalBG.png")); sketchBorderR.load(new URLRequest("img/Site2dElements/sketchBorderR.png")); sketchBorderL.load(new URLRequest("img/Site2dElements/sketchBorderL.png")); digitalBG.load(new URLRequest("img/Site2dElements/DigBorder.png")); sun.load(new URLRequest("img/Site2dElements/sun1.png")); clouds2.load(new URLRequest("img/Site2dElements/clouds4.png")); topPlanet.load(new URLRequest("img/Site2dElements/siteBorder_top.png")); Title.load(new URLRequest("img/Site2dElements/3dHeader.png")); Haze.load(new URLRequest("img/Site2dElements/SiteOuterHaze2.png")); topRibbon.load(new URLRequest("img/Site2dElements/siteRibbon.png")); backgroundImage.load(new URLRequest("img/Site2dElements/bluesky.png")); clouds1.load(new URLRequest("img/Site2dElements/clouds1.png")); bottomPark.load(new URLRequest("img/Site2dElements/siteBG_bottom.png")); // position and add preloader graphic to display List preloader.x = 726; preloader.y = 350; addChild(preloader); // preloader flashes unless its visibility is turned off preloader.visible = false; _targetLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressListener); function progressListener (e:ProgressEvent):void{ _loadPercent = _targetLoaderInfo.bytesLoaded / _targetLoaderInfo.bytesTotal; preloader.visible = true; preloader.progBar.scaleX = _loadPercent; percent_txt.text = Math.ceil(_loadPercent*100).toString()+"%"; } backgroundImage.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete); function onComplete(e:Event):void{ // clean out preloader assets removeChild(preloader); removeChild(percent_txt); percent_txt = null; _targetLoaderInfo.removeEventListener( ProgressEvent.PROGRESS, progressListener ); _targetLoaderInfo.removeEventListener( Event.COMPLETE , onComplete ); // positioning, and adding all loaded assets var resumeLinkX:Number = 710; var resumeLinkY:Number = 60; var digitalLinkX:Number = 610; var digitalLinkY:Number = 75; var animationLinkX:Number = 850; var animationLinkY:Number = 60; var sketchLinkX:Number = 490; var sketchLinkY:Number = 50; addChild(backgroundImage); addChild(clouds1); addChild(bottomPark); addChild(Haze); addChild(topRibbon); addChild(Title); addChild(animationLink); addChild(sketchLink); addChild(digitalLink); addChild(resumeLink); Title.x = 425; Title.y = 125; digitalLink.x = digitalLinkX; digitalLink.y = digitalLinkY; animationLink.x = animationLinkX; animationLink.y = animationLinkY; resumeLink.x = resumeLinkX; resumeLink.y = resumeLinkY; sketchLink.x = sketchLinkX; sketchLink.y = sketchLinkY; animationLink.alpha = 0; digitalLink.alpha = 0; resumeLink.alpha = 0; sketchLink.alpha = 0; Title.alpha = 0; Haze.x = 0; Haze.y = 0; clouds1.x = 0; clouds1.y = -1200; bottomPark.x = 0; bottomPark.y = 240; topRibbon.x = 0; topRibbon.y = 0; backgroundImage.x = 0; backgroundImage.y = 0; // proceed in timeline gotoAndPlay("main"); } any insite on what the problem could be or if i'm just missing a compatibility thing with Safari, i would much appreciate
VIEWS ON THIS POST

83

Posted on:

Thursday 25th October 2012
View Replies!

Preloader works on one server but not another.

Hi I have a big problem with preloader for my flash site. It works on one server but when i try it on another server it does not work. On site where it does not work it displays Infinity in IE and all the time 100% in firefox but in flash when traced preloader works and on another server too. It is the same file. Is there any specific function or mode that server must have or enable for a preloader to work. working: www.asm.si/test not working www.animedija.si/test/animedija It is really annoying since the one not working is where i am hosting my page. any advice would be great Luka
VIEWS ON THIS POST

77

Posted on:

Thursday 25th October 2012
View Replies!

loaded swf not visible until resize

ive come across a strange problem, maybe. Im loading in my main swf, which will take the place of the preloader(which consists of the entrance) like so... Code: var entrance:Entrance = new Entrance(); addChild(entrance); import gs.TweenLite; import gs.easing.*; stage.addEventListener(Event.RESIZE, onStageResize); stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; function onStageResize(evt:Event):void { entrance.x = stage.stageWidth/2; entrance.y = stage.stageHeight/2.4; entrance.width = stage.stageWidth/5; entrance.height = stage.stageHeight/1.7; } entrance.x = stage.stageWidth/2; entrance.y = stage.stageHeight/2.4; entrance.width = stage.stageWidth/5; entrance.height = stage.stageHeight/1.7; var req:URLRequest = new URLRequest("waterLight2.swf"); var loader:Loader = new Loader(); loader.load(req); addChild(loader); loader.alpha = 0; loader.contentLoaderInfo.addEventListener(Event.COMPLETE, done); function done(evt:Event):void { entrance.play() addEventListener(Event.ENTER_FRAME, entranceHandler); } function entranceHandler(evt:Event):void { removeEventListener(Event.ENTER_FRAME, entranceHandler); TweenLite.to(entrance, 1.5, {alpha:0, ease:Strong.easeIn}); addEventListener(Event.ENTER_FRAME, removeEntrance); } function removeEntrance(evt:Event):void { if (entrance.currentFrame == 30) { TweenLite.to(loader, 1.5, {alpha:1, ease:Strong.easeOut}); removeChild(entrance); removeEventListener(Event.ENTER_FRAME, removeEntrance); } } However, for some reason or other, my loaded swf isnt visible until i resize the stage. Ive been trying various things with the way the preloading is done, but it doesnt seem to change anything, and also ive tried taking out the tweens but that doesnt do anything either. Has anyone had this problem before If so, some advice would be much appreciated.
VIEWS ON THIS POST

127

Posted on:

Thursday 25th October 2012
View Replies!

Managing filters (applying and removing randomly)

Hi , Here is some code I thought you would like. Ever had trouble with adding and removing different filters to a display object and bumping into that wall with that annoying filters copy behavior Here is a nice way to get rid of all your troubles. var filterDic=new Dictionary(); DisplayObject.prototype.applyFilter = function (filter) { if (!filterDic[this]) filterDic[this]=this.filters; filterDic[this].push(filter); trace("apply"+(filterDic[this].length-1)) this.filters=filterDic[this]; } DisplayObject.prototype.removeFilter = function (filter) { trace(filterDic[this].indexOf(filter)); filterDic[this].splice(filterDic[this].indexOf(filter), 1); this.filters=filterDic[this]; } //Example use var glowFilter = new GlowFilter(0x00FFFF, 1.0, 8, 8, 6, 2); var redFilter = new ColorMatrixFilter([ 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]); DO.applyFilter (glowFilter); DO.applyFilter (redFilter ); DO.removeFilter (glowFilter); //red stays!! I didn't write it in a class, since it involves prototype syntax and I don't know if that's adviced in a class. (Isn't there a include statement or can "import" also include non-classes).
VIEWS ON THIS POST

89

Posted on:

Thursday 25th October 2012
View Replies!

Problem with transition stops randomly

Hi lads, ive just convertet from as2 to as3 so please bare with the non-tight coding. Im loading 5 images from an xml file into flash. all loaded into an array and randomnized in another array. then the first image is loaded into a movieclip: function playImage(){ if(imgCounter
VIEWS ON THIS POST

96

Posted on:

Thursday 25th October 2012
View Replies!

Actionscript Tween not working when within TweenEvent handler

I have an interesting problem here that I can't figure out. Here's the problem: This code works: var xMoveTween:Tween = new Tween(this, "x", Strong.easeOut, this.x, stage.mouseX, 3, true); var yMoveTween:Tween = new Tween(this, "y", Strong.easeOut, this.y, stage.mouseY, 3, true); It moves my object to the position of the mouse. Now this following code does NOT work var xMoveTween:Tween = new Tween(this, "x", Strong.easeOut, this.x, stage.mouseX, 3, true); xMoveTween.addEventListener(TweenEvent.MOTION_FINI SH, moveToY); function moveToY(event:TweenEvent):void { var yMoveTween:Tween = new Tween(this, "y", Strong.easeOut, this.y, stage.mouseY, 3, true); trace("interesting"); } As you can see, I want the object to move in the x direction, then once it's done that I want it to move in the y direction instead of just doing both at once and going diagonal. One thing that is "interesting" is that the trace still spits out the word to the output window. But the object in the end has only moved to the x destination and never gets to the y. Any ideas on how to fix this or an alternate way to make the object move in the x direction followed by the y icekube12jr
VIEWS ON THIS POST

80

Posted on:

Thursday 25th October 2012
View Replies!

Flash website resize according to browser's size

I've searched google and kirupa but I haven't managed to find anything. How do I get the website to change it's size according to the browser's size and Have a max and min size the site can resize to
VIEWS ON THIS POST

89

Posted on:

Thursday 25th October 2012
View Replies!

Elastic menu component works in test but not in publish

I purchased an elastic menu flash component that uses AS3. Unfortunately, I've only just waded into AS2. I'm trying to replace the generic colored background with an image that is masked. Unfortunately, turning the layer into a mask breaks the functionality. The weird thing is that it works fine in Test Mode (Ctrl+Enter) and if published as an EXE. It just doesn't work as an swf. Has anyone run into this weird inconsistency before Also, what is the best way to get into that component and possibly modify it
VIEWS ON THIS POST

78

Posted on:

Thursday 25th October 2012
View Replies!

BitmapData not displaying after AIR app install (though it works great in Flash)

Everyone, I'm encountering the most headache-inspiring problem I have yet faced with Flash and I absolutely cannot find a solution: I'm developing an AIR rss video-widget that pulls video and image data from an xml file located on my server. When inside of flash and I test the movie everything works great -- the images and the video load successfully and everything plays as it should. The problem: When I create the AIR file and install it (like you would install any air application) it loads the XML file successfully but doesn't display any bitmap data --that is, no image-thumbnails load and neither does the video or even sound from the video. Testing it locally I can see that the images load and the onComplete event fires, but when I deploy it and test it through Arthropod (like flash-trace) I can see that it doesn't even get to that point. It just hangs up forever. Is this a security problem A sandbox problem Who knows! But my head is pounding terribly... Please help --
VIEWS ON THIS POST

94

Posted on:

Thursday 25th October 2012
View Replies!

Passing objects to eventhandlers

Hy Guys! Let me first introduce myself: I am Marcel, I live in the Netherlands.. I'm fairly new to Kirupa, that is, new to posting my problems/findings. I'm using flash (CS 3) now for allmost a year, and the threads in kirupa helped me through sometimes! Now, my problem. I'm making my own Portfolio, and i have a problem with eventhandlers. I have a couple different objects, lets call em A, B, etc. I want to do the same things to these objects, when i hover over, or click on them. I want to do this with, obviously, event handlers. The tricky part is, i want to make a bunch of eventhandlers for every object, but all handlers have to call the same function. To do this, i have to put the object as an variable in the event handler. Only, this is not possible in AS3! How can i do this Since this is my first thread here, i hope it is clear for you ! If it isn't, just ask! Greetings! Marcel
VIEWS ON THIS POST

57

Posted on:

Thursday 25th October 2012
View Replies!

SWF resize on browser resize causes Nav Buttons to no longer work.

. I have a full browser width/height resizing swf. I can't figure out why, but the navigation rollover states no longer work after resizing the browser. My rollovers are handled by a button class linked to each nav button movie clip within the library. Other things of note. I am using the 3 frame AS3 preloading technique which holds all my assets in its own movie clip on frame 3. My document class only really handles preloading. And a class for all my assets, acting as the "real" doc class is linked to that MC on frame 3. Here is the URL to the problem: http://spiritservices.mindgrabmedia.com/stmary/
VIEWS ON THIS POST

74

Posted on:

Thursday 25th October 2012
View Replies!

Quirky AS3 browser resize Help Please!

- I have been battling against this browser resize issue for what seems like monthes. After several variations, my code is more effective, less concise and still not stable. I am basically trying to make my bg resize to the full browser and my site movieclip to center. If the browser gets smaller than the site MC then the site MC should constrain to fit in the browser. What I have right now works like 98% of the time, but still screws up and makes the site tiny or too big sometimes. I was hoping that someone else has gone through this and may be able to comment or drop in some good code. As I said mine got uglier and uglier as time went. I kind of hate this code. If I didn't write it, I'd say the author was insane... which I kind of am. anyhow, any help is mucho appreciated. here's the code for a look. Code: import gs.TweenLite; stage.align=StageAlign.TOP_LEFT; stage.scaleMode=StageScaleMode.NO_SCALE; var siteHeight:Number = 600; var siteWidth:Number = 850; var siteRealHeight:Number = 600; var siteRealWidth:Number = 850; var siteAspectRatio:Number = 850/600; var theFactor:Number; var stageOldHeight:Number = 600; var stageOldWidth:Number = 850; var resizetimer:Timer = new Timer(1500,3); resizetimer.addEventListener("timer", firstResizeHandler); init(); function init() { stage.addEventListener(Event.RESIZE, resizeHandler); TweenLite.to(site, 1, {scaleX:1, scaleY:1}); resizetimer.start(); } function firstResizeHandler(event:TimerEvent):void { position(); } function resizeHandler(event:Event):void { position(); } function position(){ bg.width = stage.stageWidth; bg.height = stage.stageHeight; if(stage.stageWidth < siteWidth) { siteResizeWidth(); } if(stage.stageWidth > stageOldWidth && stage.stageWidth < 850) { siteResizeWidth(); } if(stage.stageHeight < siteHeight) { siteResizeHeight(); } if(stage.stageHeight > stageOldHeight && stage.stageHeight < 600) { siteResizeHeight(); } var siteX:Number = (stage.stageWidth)/2 ; var siteY:Number = (stage.stageHeight)/2 ; TweenLite.to(this.site, 0.5, {x:siteX, y:siteY}); stageOldHeight = stage.stageHeight stageOldWidth = stage.stageWidth; } function siteResizeWidth(){ theFactor = stage.stageWidth/stageOldWidth; site.width = (site.width*theFactor); siteWidth = (siteWidth*theFactor); siteHeight = siteHeight*theFactor; site.height = site.height*theFactor; } function siteResizeHeight(){ theFactor = stage.stageHeight/stageOldHeight; site.height = (site.height*theFactor); siteHeight = (siteHeight*theFactor); siteWidth = siteWidth*theFactor; site.width = site.width*theFactor; }
VIEWS ON THIS POST

70

Posted on:

Thursday 25th October 2012
View Replies!

Loader image resize

Hi I have been looking though a lot of threads regarding reszing of images, but I havent been able to get it to work. So maybe you can help me I'm very new to AS, so be gentle ;-) I have a C# program, that uses a swf file to show some dynamically loaded images. The image loading works, but I have two things that I havent been able to solve. 1) When images are loaded, the previos one is not cleared. The previous image should of cause be leared, as it is not needed anymore. 2) I would like to resize all imges to 250 x 250 px no matter what. I'm not sure how to do that... I'm not sure if the way I do it is the right way Is it better to use a Sprite, what is the best/easies way for this Here you can see what I have now: Code: import flash.external.ExternalInterface; ExternalInterface.addCallback("ShowAlbumArt",doShowAlbumArt); function doShowAlbumArt(url:String):void { if (ldr != null){ removeChild(ldr); } var rect:Shape = new Shape(); rect.graphics.beginFill(0xFFFFFF); rect.graphics.drawRect(750, 30, 250, 250); rect.graphics.endFill(); addChild(rect); var ldr:Loader = new Loader(); ldr.mask = rect; addChild(ldr); ldr.x = 750; ldr.y = 30; try { ldr.load(new URLRequest(url)); } catch ( error: Error ) {} }
VIEWS ON THIS POST

62

Posted on:

Thursday 25th October 2012
View Replies!

Source Code for creating expanding ad swf that works in Safari?

Hi I'm wondering if anyone has some sample code I can check out for making a swf in AS 3 that grows over page content and is compatible with Safari (preferably 2 or higher) I've been googling and searching through these and other forums and haven't been able to find anything usable in Safari, though I'm sure it exists. I've seen it on some ads around.
VIEWS ON THIS POST

127

Posted on:

Thursday 25th October 2012
View Replies!

resize tool

hey, does anyone know a small app that can resize an image proportionally by just dragging the corner of it It only has to be a movieclip, no bitmaps involved. Senocular's transform manager is great but a little too complex for what I need. I tried making one myself but I didn't have much luck.
VIEWS ON THIS POST

55

Posted on:

Thursday 25th October 2012
View Replies!

Play a movie clip continuously throughout different scenes

Here's what i'm trying to do: I have a movie clip playing throughout my movie to simulate an old computer screen, but when i change scenes, the movie clip starts over at the beginning. How do I have the movie clip play continuously without restarting when i change scenes
VIEWS ON THIS POST

362

Posted on:

Monday 29th October 2012
View Replies!

Referencing dynamicaly created child movie clip

I have used AS3 in frame 1 of the timeline to create a holding MC 'opening_Mc' into which 7 sub MCs are loaded when the user presses each of 7 buttons. When each of the sub MCs loads it is populated with images using XML. When the button is presses 'opening_Mc' slides to reveal the position of the respective sub MC. I dynamically create each sub MC and reset it's name to the respective section name... so if the user presses button 1 the sub MC will end up with the name 'section_1'. The button mode of the sub MC is set to 'true' so that a larger image can be loaded when the user clicks on each of the images.
VIEWS ON THIS POST

44

Posted on:

Monday 29th October 2012
View Replies!

ads in flash air android and ios

I am developing a test app for both android and ios to learn flash and actionscript. I have developed my app using flash professional and now would like to see how to integrate ads. I am signed up with admob right now, but now have no idea how to integrate this to my app. I have researched and googled many links, but have not been able to find a clear and recent guide how to do this. I am very new to the whole flash thing and actionscript, so if someone could explain step by step how to add ads to a flash app that would be greatly appreciated. Cheers
VIEWS ON THIS POST

102

Posted on:

Monday 26th November 2012
View Replies!

Check if are there movieclips on a speficif position

folks, i was asked to do an exercise in which every time i click on a button called create, an avatar is added to the stage. The positioning of each avatar is random and every picture is resized to fit 95x95 pixels. I have done everything but checking if the place where i insert a new avatar is "empty" How can I check if I have positioned an avatar over an existing one I am trying to avoid positioning them in the same space.. Thank you!
VIEWS ON THIS POST

54

Posted on:

Friday 30th November 2012
View Replies!

Flash looking for a game designer

hello , I am looking for a game designer i need him to be very good in designing to work with me as a team to publish games on the internet. And i am the programmer , I am professional in AS3 (OOP) , I have created alot of games that aren't good enough due to the crappy design ! if anyone is interested and is good enough in designing games Contact me at that email : a.kareem_3d@yahoo.com.
VIEWS ON THIS POST

63

Posted on:

Sunday 30th December 2012
View Replies!

Flash navigate from movieclip to scene1

i want to gor from movieclip to scene 1, where i have set my menu on timeline. Actually i have main movieclip on main timeline of scene 1, and inside that main movieclip , i'm having number of sub movieclips, so from that any movieclip i want go back return to scene 1. Is there any way to do this If this problem is unable to understand let me know, i will try to explore it.
VIEWS ON THIS POST

32

Posted on:

Sunday 30th December 2012
View Replies!