Search Results

Search found 908 results on 37 pages for 'as3'.

Page 12/37 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • How to catch a HTTP 404 in Flash

    - by Quandary
    When I execute the (2nd) below code with a wrong url (number '1' added at the URL end), I get the below error. How can I catch this error, in case the url is wrong, so that I can give out an error message to the user ? Error opening URL 'http://localhost/myapp/cgi-bin/savePlanScale.ashx1?NoCache%5FRaumplaner=F7CF6A1E%2D7700%2D8E33%2D4B18%2D004114DEB39F&ScaleString=5%2E3&ModifyFile=data%2Fdata%5Fzimmere03e1e83%2D94aa%2D488b%2D9323%2Dd4c2e8195571%2Exml' httpStatusHandler: [HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=404] status: 404 Error: Error #2101: Der an URLVariables.decode() übergebene String muss ein URL-kodierter Abfrage-String mit Name/Wert-Paaren sein. at Error$/throwError() at flash.net::URLVariables/decode() at flash.net::URLVariables() at flash.net::URLLoader/onComplete() public static function NotifyASPXofNewScale(nScale:Number) { var strURL:String ="http://localhost/myapp/cgi-bin/savePlanScale.ashx1" // CAUTION: when called from website, RELATIVE url... var scriptRequest:URLRequest = new URLRequest(strURL); var scriptLoader:URLLoader = new URLLoader(); // loader.dataFormat = URLLoaderDataFormat.TEXT; // default, returns as string scriptLoader.dataFormat = URLLoaderDataFormat.VARIABLES; // returns URL variables // loader.dataFormat = URLLoaderDataFormat.BINARY; // to load in images, xml files, and swf instead of the normal methods var scriptVars:URLVariables = new URLVariables(); scriptLoader.addEventListener(Event.COMPLETE, onLoadSuccessful); scriptLoader.addEventListener(IOErrorEvent.IO_ERROR, onLoadError); scriptLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler); scriptLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError); scriptVars.NoCache_Raumplaner = cGUID.create(); scriptVars.ScaleString = nScale; scriptVars.ModifyFile = "data/data_zimmere03e1e83-94aa-488b-9323-d4c2e8195571.xml"; scriptRequest.method = URLRequestMethod.GET; scriptRequest.data = scriptVars; scriptLoader.load(scriptRequest); function httpStatusHandler(event:HTTPStatusEvent):void { trace("httpStatusHandler: " + event); trace("status: " + event.status); } function onLoadSuccessful(evt:Event):void { trace("cSaveData.NotifyASPXofNewScale.onLoadSuccessful"); trace("Response: " + evt.target.data); ExternalInterface.call("alert", "Die neue Skalierung wurde erfolgreich gespeichert."); //getURL("javascript:alert(\""+"Die neue Skalierung wurde erfolgreich gespeichert.\\nALLE Instanzen des Browsers schliessen und neu starten, damit die Änderung in Kraft tritt."+"\");"); if (evt.target.data.responseStatus == "YOUR FAULT") { trace("Error: Flash transmitted an illegal scale value."); ExternalInterface.call("alert", "Fehler: Flash konnte die neue Skalierung nicht abspeichern."); } if (evt.target.data.responseStatus == "EXCEPTION") { trace("Exception in ASP.NET: " + evt.target.data.strError); ExternalInterface.call("alert", "Exception in ASP.NET: " + evt.target.data.strError); } } function onLoadError(evt:IOErrorEvent):void { trace("cSaveData.NotifyASPXofNewScale.onLoadError"); trace("Error: ASPX or Transmission error. ASPX responseStatus: " + evt); ExternalInterface.call("alert", "ASPX - oder Übertragungsfehler.\\nASPX responseStatus: " + evt); //getURL("javascript:alert(\"" + "ASPX - oder Übertragungsfehler.\\nASPX responseStatus: " + receiveVars.responseStatus + "\");"); } function onSecurityError(evt:SecurityErrorEvent):void { trace("cSaveData.NotifyASPXofNewScale.onSecurityError"); trace("Security error: " + evt); ExternalInterface.call("alert", "Sicherheitsfehler. Beschreibung: " + evt); } }

    Read the article

  • actionscript3: reflect-class applied on rotationY

    - by algro
    Hi, I'm using a class which applies a visual reflection-effect to defined movieclips. I use a reflection-class from here: link to source. It works like a charm except when I apply a rotation to the movieclip. In my case the reflection is still visible but only a part of it. What am I doing wrong? How could I pass/include the rotation to the Reflection-Class ? Thanks in advance! This is how you apply the Reflection Class to your movieclip: var ref_mc:MovieClip = new MoviClip(); addChild(ref_mc); var r1:Reflect = new Reflect({mc:ref_mc, alpha:50, ratio:50,distance:0, updateTime:0,reflectionDropoff:1}); Now I apply a rotation to my movieclip: ref_mc.rotationY = 30; And Here the Reflect-Class: package com.pixelfumes.reflect{ import flash.display.MovieClip; import flash.display.DisplayObject; import flash.display.BitmapData; import flash.display.Bitmap; import flash.geom.Matrix; import flash.display.GradientType; import flash.display.SpreadMethod; import flash.utils.setInterval; import flash.utils.clearInterval; public class Reflect extends MovieClip{ //Created By Ben Pritchard of Pixelfumes 2007 //Thanks to Mim, Jasper, Jason Merrill and all the others who //have contributed to the improvement of this class //static var for the version of this class private static var VERSION:String = "4.0"; //reference to the movie clip we are reflecting private var mc:MovieClip; //the BitmapData object that will hold a visual copy of the mc private var mcBMP:BitmapData; //the BitmapData object that will hold the reflected image private var reflectionBMP:Bitmap; //the clip that will act as out gradient mask private var gradientMask_mc:MovieClip; //how often the reflection should update (if it is video or animated) private var updateInt:Number; //the size the reflection is allowed to reflect within private var bounds:Object; //the distance the reflection is vertically from the mc private var distance:Number = 0; function Reflect(args:Object){ /*the args object passes in the following variables /we set the values of our internal vars to math the args*/ //the clip being reflected mc = args.mc; //the alpha level of the reflection clip var alpha:Number = args.alpha/100; //the ratio opaque color used in the gradient mask var ratio:Number = args.ratio; //update time interval var updateTime:Number = args.updateTime; //the distance at which the reflection visually drops off at var reflectionDropoff:Number = args.reflectionDropoff; //the distance the reflection starts from the bottom of the mc var distance:Number = args.distance; //store width and height of the clip var mcHeight = mc.height; var mcWidth = mc.width; //store the bounds of the reflection bounds = new Object(); bounds.width = mcWidth; bounds.height = mcHeight; //create the BitmapData that will hold a snapshot of the movie clip mcBMP = new BitmapData(bounds.width, bounds.height, true, 0xFFFFFF); mcBMP.draw(mc); //create the BitmapData the will hold the reflection reflectionBMP = new Bitmap(mcBMP); //flip the reflection upside down reflectionBMP.scaleY = -1; //move the reflection to the bottom of the movie clip reflectionBMP.y = (bounds.height*2) + distance; //add the reflection to the movie clip's Display Stack var reflectionBMPRef:DisplayObject = mc.addChild(reflectionBMP); reflectionBMPRef.name = "reflectionBMP"; //add a blank movie clip to hold our gradient mask var gradientMaskRef:DisplayObject = mc.addChild(new MovieClip()); gradientMaskRef.name = "gradientMask_mc"; //get a reference to the movie clip - cast the DisplayObject that is returned as a MovieClip gradientMask_mc = mc.getChildByName("gradientMask_mc") as MovieClip; //set the values for the gradient fill var fillType:String = GradientType.LINEAR; var colors:Array = [0xFFFFFF, 0xFFFFFF]; var alphas:Array = [alpha, 0]; var ratios:Array = [0, ratio]; var spreadMethod:String = SpreadMethod.PAD; //create the Matrix and create the gradient box var matr:Matrix = new Matrix(); //set the height of the Matrix used for the gradient mask var matrixHeight:Number; if (reflectionDropoff<=0) { matrixHeight = bounds.height; } else { matrixHeight = bounds.height/reflectionDropoff; } matr.createGradientBox(bounds.width, matrixHeight, (90/180)*Math.PI, 0, 0); //create the gradient fill gradientMask_mc.graphics.beginGradientFill(fillType, colors, alphas, ratios, matr, spreadMethod); gradientMask_mc.graphics.drawRect(0,0,bounds.width,bounds.height); //position the mask over the reflection clip gradientMask_mc.y = mc.getChildByName("reflectionBMP").y - mc.getChildByName("reflectionBMP").height; //cache clip as a bitmap so that the gradient mask will function gradientMask_mc.cacheAsBitmap = true; mc.getChildByName("reflectionBMP").cacheAsBitmap = true; //set the mask for the reflection as the gradient mask mc.getChildByName("reflectionBMP").mask = gradientMask_mc; //if we are updating the reflection for a video or animation do so here if(updateTime > -1){ updateInt = setInterval(update, updateTime, mc); } } public function setBounds(w:Number,h:Number):void{ //allows the user to set the area that the reflection is allowed //this is useful for clips that move within themselves bounds.width = w; bounds.height = h; gradientMask_mc.width = bounds.width; redrawBMP(mc); } public function redrawBMP(mc:MovieClip):void { // redraws the bitmap reflection - Mim Gamiet [2006] mcBMP.dispose(); mcBMP = new BitmapData(bounds.width, bounds.height, true, 0xFFFFFF); mcBMP.draw(mc); } private function update(mc):void { //updates the reflection to visually match the movie clip mcBMP = new BitmapData(bounds.width, bounds.height, true, 0xFFFFFF); mcBMP.draw(mc); reflectionBMP.bitmapData = mcBMP; } public function destroy():void{ //provides a method to remove the reflection mc.removeChild(mc.getChildByName("reflectionBMP")); reflectionBMP = null; mcBMP.dispose(); clearInterval(updateInt); mc.removeChild(mc.getChildByName("gradientMask_mc")); } } }

    Read the article

  • Flash/ActionScript3 crashes on getPixel/32

    - by Quandary
    Question: The below code crashes flash... Why? The crash causing lines seem to be //var uiColor:uint = bmpd.getPixel(i,j); var uiColor:uint = bmpd.getPixel32(i,j); trace("Color: "+ uiColor); I am trying to take a snapshot of a movieclip and iterate through all pixels in the image and get the pixel's color. import flash.display.BitmapData; import flash.geom.*; function takeSnapshot(mc:MovieClip):BitmapData { var sp:BitmapData = new BitmapData(mc.width, mc.height, true, 0x000000); sp.draw(mc, new Matrix(), new ColorTransform(), "normal"); return sp; } var mcMyClip:MovieClip=new MovieClip() var xxx:cMovieClipLoader=new cMovieClipLoader(); xxx.LoadImageAbsSize(mcMyClip,"http://localhost/flash/images/picture.gif", 500,500) //this.addChild(mcMyClip); function WhenImageIsLoaded() { var bmpd:BitmapData=takeSnapshot(mcMyClip); var i,j:uint; for(i=0; i < bmpd.width;++i) { for(j=0; j < bmpd.height;++j) { //var uiColor:uint = bmpd.getPixel(i,j); var uiColor:uint = bmpd.getPixel32(i,j); trace("Color: "+ uiColor); } } var myBitmap:Bitmap = new Bitmap(bmpd); this.addChild(myBitmap); } setTimeout(WhenImageIsLoaded,1000);

    Read the article

  • YouTube API Security Error Flex

    - by 23tux
    Hi, I've tried to use the YoutTube API within a Flex project. But i got this error: *** Security Sandbox Violation *** SecurityDomain 'http://www.youtube.com/apiplayer?version=3' tried to access incompatible context 'file:///Users/YouTubePlayer/bin-debug/YouTubePlayer.html' Here are the two files: <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768" xmlns:youtube="youtube.*" creationComplete="init();"> <fx:Script> <![CDATA[ [Bindable] private var ready:Boolean = true; private function init():void { Security.allowInsecureDomain("*"); Security.allowDomain("*"); Security.allowDomain('www.youtube.com'); Security.allowDomain('youtube.com'); Security.allowDomain('s.ytimg.com'); Security.allowDomain('i.ytimg.com'); } private function changing():void { /* trace("currentTime: " + player.getCurrentTime()); trace("startTime: " + player.startTime); trace("stopTime: " + player.stopTime); timeSlider.value = player.getCurrentTime() */ } private function startPlaying():void { player.play(); } private function checkStartSlider():void { if(startSlider.value > stopSlider.value) stopSlider.value = startSlider.value + 1; } private function checkStopSlider():void { if(stopSlider.value < startSlider.value) startSlider.value = stopSlider.value - 1; } ]]> </fx:Script> <s:VGroup> <youtube:Player id="player" videoID="DVFvcVuWyfE" change="changing();" ready="ready=true"/> <s:HGroup> <s:Button label="play" click="startPlaying();" /> </s:HGroup> <s:HGroup> <s:HSlider id="timeSlider" width="250" minimum="0" maximum="{player.stopTime}" snapInterval=".01" enabled="{ready}"/> <s:Label id="currentTimeLbl" text="current time: 0" /> </s:HGroup> <s:HGroup> <s:HSlider id="startSlider" width="250" minimum="0" maximum="{player.stopTime}" snapInterval=".01" change="checkStartSlider();" enabled="{ready}" value="0"/> <s:Label id="startTimeLbl" text="start time: {player.startTime}" /> </s:HGroup> <s:HGroup> <s:HSlider id="stopSlider" width="250" minimum="0" maximum="{player.stopTime}" snapInterval=".01" change="checkStopSlider();" enabled="{ready}" value="{player.stopTime}"/> <s:Label id="stopTimeLbl" text="stop time: {player.stopTime}" /> </s:HGroup> </s:VGroup> </s:Application> Here is the player package youtube { import flash.display.Loader; import flash.events.Event; import flash.events.TimerEvent; import flash.net.URLRequest; import flash.system.Security; import flash.utils.Timer; import mx.core.UIComponent; [Event(name="change", type="flash.events.Event")] [Event(name="ready", type="flash.events.Event")] public class Player extends UIComponent { private var player:Object; private var loader:Loader; private var _startTime:Number = 0; private var _stopTime:Number = 0; private var _videoID:String; private var metadataTimer:Timer = new Timer(200); private var playTimer:Timer = new Timer(200); public function Player() { // The player SWF file on www.youtube.com needs to communicate with your host // SWF file. Your code must call Security.allowDomain() to allow this // communication. Security.allowInsecureDomain("*"); Security.allowDomain("*"); // This will hold the API player instance once it is initialized. loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit); loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3")); } private function onLoaderInit(event:Event):void { addChild(loader); loader.content.addEventListener("onReady", onPlayerReady); loader.content.addEventListener("onError", onPlayerError); loader.content.addEventListener("onStateChange", onPlayerStateChange); loader.content.addEventListener("onPlaybackQualityChange", onVideoPlaybackQualityChange); } private function onPlayerReady(event:Event):void { // Event.data contains the event parameter, which is the Player API ID trace("player ready:", Object(event).data); // Once this event has been dispatched by the player, we can use // cueVideoById, loadVideoById, cueVideoByUrl and loadVideoByUrl // to load a particular YouTube video. player = loader.content; // Set appropriate player dimensions for your application player.setSize(0, 0); } private function onPlayerError(event:Event):void { // Event.data contains the event parameter, which is the error code trace("player error:", Object(event).data); } private function onPlayerStateChange(event:Event):void { // Event.data contains the event parameter, which is the new player state trace("player state:", Object(event).data); } private function onVideoPlaybackQualityChange(event:Event):void { // Event.data contains the event parameter, which is the new video quality trace("video quality:", Object(event).data); } [Bindable] public function get videoID():String { return _videoID; } public function set videoID(value:String):void { _videoID = value; } [Bindable] public function get stopTime():Number { return _stopTime; } public function set stopTime(value:Number):void { _stopTime = value; } [Bindable] public function get startTime():Number { return _startTime; } public function set startTime(value:Number):void { _startTime = value; } public function play():void { if(_videoID!="") { player.loadVideoById(_videoID, 0); // add the event listener, so that all 200 milliseconds is an event dispatched metadataTimer.addEventListener(TimerEvent.TIMER, metadataTimeHandler); // if the timer is running, stop and reset it if(metadataTimer.running) metadataTimer.reset(); else metadataTimer.start(); } } private function metadataTimeHandler(e:TimerEvent):void { if(player.getDuration() > 0) { startTime = 0; stopTime = player.getDuration(); metadataTimer.reset(); metadataTimer.stop(); metadataTimer.removeEventListener(TimerEvent.TIMER, metadataTimeHandler); player.playVideo(); playTimer.addEventListener(TimerEvent.TIMER, playTimerHandler); dispatchEvent(new Event("ready")); } } private function playTimerHandler(e:TimerEvent):void { if(getCurrentTime() > _stopTime) { seekTo(startTime); } dispatchEvent(new Event(Event.CHANGE)); } public function getCurrentTime():Number { if(!player.getCurrentTime()) return 0; else return player.getCurrentTime(); } public function seekTo(time:uint):void { player.seekTo(time); } } } Hope someone can help. thx, tux

    Read the article

  • How to pass a reference to a JS function as an argument to an ExternalInterface call?

    - by Ryan Wilson
    Summary I want to be able to call a JavaScript function from a Flex app using ExternalInterface and pass a reference to a different JavaScript function as an argument. Base Example Given the following JavaScript: function foo(callback) { // ... do some stuff callback(); } function bar() { // do some stuff that should happen after a call to foo } I want to call foo from my flex app using ExternalInterface and pass a reference to bar as the callback. Why Really,foo is not my function (but, rather, FB.Connect.showBookmarkDialog), which due to restrictions on Facebook iframe apps can only be called on a button click. My button, for design reasons, is in the Flex app. Fortunately, it's possible to call ExternalInterface.call("FB.Connect.showBookmarkDialog", callback) to display the bookmark dialog. But, FB.Connect.showBookmarkDialog requires a JS callback so, should I want to receive a callback (which I do), I need to pass a reference to a JS function as the single argument. Real Example MXML: <mx:Button click="showBookmarkDialog();" /> ActionScript: function showBookmarkDialog() : void { ExternalInterface.registerCallback( "onBookmarkDialogClosed", onBookmarkDialogClosed ); ExternalInterface.call( "FB.Connect.showBookmarkDialog", /* ref to JS function onBookmarkDialogClosed ? */ ); } function onBookmarkDialogClosed(success:Boolean) : void { // sweet, we made it back } JavaScript: function onBookmarkDialogClosed() { var success; // determine value of success getSWF().onBookmarkDialogClosed(success); } Failed Experiments I have tried... ExternalInterface.call( "FB.Connect.showBookmarkDialog", "onBookmarkDialogClosed" ); ExternalInterface.call( "FB.Connect.showBookmarkDialog", onBookmarkDialogClosed ); ExternalInterface.call( "FB.Connect.showBookmarkDialog", function() : void { ExternalInterface.call("onBookmarkDialogClosed"); } ); ExternalInterface.call( "FB.Connect.showBookmarkDialog", function() { this["onBookmarkDialogClosed"](); } ); Of note: Passing a string as the argument to an ExternalInterface call results in FB's JS basically trying to do `"onBookmarkDialogClosed"()` which, needless to say, will not work. Passing a function as the argument results in a function object on the other side (confirmable with `typeof`), but it seems to be an empty function; namely, `function Function() {}`

    Read the article

  • bitmap data as movie clip

    - by Ross
    Hi, I import my images with imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete); imageLoader.load(imageRequest); and then try and cast as a movieclip: var newImage:MovieClip = imageLoader.content as MovieClip; addChild(newImage); i keep getting errors, is this possible? Thanks, Ross

    Read the article

  • tabIndex fails in an AS3 swf loaded into a flex app

    - by quoo
    I feel like I'm missing something really simple here. I'm loading a AS3 swf containing a form (created by one of our designers) into a flex app. The swf's tabIndex properties work fine when the swf is viewed by itself, however, once it's loaded into the flex app: <mx:SWFLoader source="form.swf" top="20" horizontalCenter="0" id="formSwf" complete="swfCompleteHandler(event)"/> the form fields stop receiving focus on tab. I've been looking at the FocusManager in flex, for some sort of solution, but I can't seem to find any examples, and I'm not entirely sure I'm looking in the right place. Am I stuck redoing this form in flex?

    Read the article

  • Papervision3D: mouseEnabled = false on DisplayObject3D

    - by Josh
    How do I make a DisplayObject3D have mouseEnabled = false. I have a Sprite behind the Papervision3D scene listening for mouse events and so i need to let it pick up those mouse events through some of the DisplayObject3D objects. I've tried adding the DisplayObject3D to a separate ViewportLayer and setting thats mouseEnabled to false but that doesn't seem to work. Please help! Thanks.

    Read the article

  • FileReference.load() does not as excepted

    - by Yang Bo
    I used Flash player 10, and Flex SDK 3.4. The code as followings: // Following comes callbacks function imageLoadOpenCallback(evt:Event):void { trace("in--open"); } function imageLoadCompleteCallback(evt:Event):void { trace("in--load"); var fr:FileReference = evt.target as FileReference; trace(fr.data); } function imageLoadErrorCallback(evt:IOErrorEvent):void { trace("in--ioerror"); } function imageSelectCancelCallback(evt:Event):void { trace("in cancel"); } function imageSelectCallback(evt:Event):void { trace("in -- select"); for (var i:int=0; i<frl.fileList.length; i++) { frl.fileList[i].addEventListener(Event.OPEN, imageLoadOpenCallback); frl.fileList[i].addEventListener(Event.COMPLETE, imageLoadCompleteCallback); frl.fileList[i].addEventListener(IOErrorEvent.IO_ERROR, imageLoadErrorCallback); frl.fileList[i].load(); trace(frl.fileList[i]); trace(frl.fileList[i].creationDate); trace(frl.fileList[i].creator); trace(frl.fileList[i].data); trace(frl.fileList[i].name); } } // Following comes UI handlers function onAddPictures():void { var imageFilter:FileFilter = new FileFilter("Images", "*.jpg;*.png"); frl.addEventListener(Event.SELECT, imageSelectCallback); frl.addEventListener(Event.CANCEL, imageSelectCancelCallback); frl.browse([imageFilter]); } Only the imageSelectCancelCallback handler get called when I select some files in the dialog. But no load/open/io_error handler get called at all. I have Google some code example, in which it used FileReference instead of FileReferenceList. I don't know the reason, could you please help me?

    Read the article

  • How can I have an mx:Window automatically resize to its content?

    - by Troy Gilbert
    I'm creating windows in a Flex application (AIR) using the mx:Window component. I'd like the window to be automatically sized to its content (because it will be dynamic), in the same way that an mx:Panel or mx:Box would be. I've customized components before, so I'm somewhat familiar with the UIComponent lifecycle, but I'm not quite sure how best to do the logic for auto-sizing a container. If it makes it easier, I'm not expecting that the window auto-size to its content at any time, thought that would be a bonus!

    Read the article

  • custom type face class by dinesh?

    - by dineshpeiris
    package typeface{ import flash.display.*; import flash.events.Event; import flash.filters.BitmapFilter; import flash.filters.BitmapFilterQuality; import flash.filters.BlurFilter; public class Main extends Sprite { private var typeSet:String="SEE > THINK > CREATE"; private var collectionSet:MovieClip; private var w:int = 1; public function Main():void { trace("start typeface application"); collectionSet = new MovieClip(); for (var n:int = 0; n < typeSet.length; n++) { var _x:int = 0 + (40 * n); var _y:int = 0; var Type:TypeCollector = new TypeCollector(_x, _y, stringToCharacter(typeSet, n), collectionSet); Type.addEventListener("action", actionHandler); } collectionSet.x = 100; collectionSet.y = (stage.stageHeight / 2) - 80; addChild(collectionSet); } private function actionHandler(event:Event):void { if (w == 16) { collectionSet.filters = [new BlurFilter(30, 30, BitmapFilterQuality.HIGH)]; removeChild(collectionSet); } w++; } public function stringToCharacter(str:String, n:int):String { if (str.length == 1) { return str; } return str.slice(n, n+1); } } } package typeface { import flash.display.*; import flash.events.Event; import flash.utils.Timer; import flash.events.TimerEvent; import flash.filters.BitmapFilter; import flash.filters.BitmapFilterQuality; import flash.filters.BlurFilter; import flash.events.EventDispatcher; public class TypeCollector extends EventDispatcher { private var TYPE_MC:typeMC; private var typeArray:Array = new Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "<", ">"); private var character:String; private var num:int = 0; private var TypeTimer:Timer; private var _xNum:int; private var _yNum:int; private var movieClip:MovieClip; public function TypeCollector(_x:int, _y:int, char:String, movie:MovieClip) { var totalNum:int = typeArray.length; _xNum = _x; _yNum = _y; movieClip = movie; character = char; TypeTimer = new Timer(100, totalNum); TypeTimer.addEventListener("timer", TypeRoutTimer); TypeTimer.start(); } public function TypeRoutTimer(event:TimerEvent):void { CreateTypeFace(num, _xNum, _yNum, character); num++; } public function CreateTypeFace(num:int, _x:int, _y:int, character:String) { if (character == " ") { } else { if (TYPE_MC != null) { TYPE_MC.filters = [new BlurFilter(30, 30, BitmapFilterQuality.HIGH)]; movieClip.removeChild(TYPE_MC); } if (typeArray[num] == character) { TYPE_MC = new typeMC(); TYPE_MC.x = _x; TYPE_MC.y = _y; TYPE_MC.typeTF.text = typeArray[num]; TYPE_MC.filters = [new BlurFilter(5, 5, BitmapFilterQuality.HIGH)]; movieClip.addChild(TYPE_MC); dispatchEvent(new Event("action")); TypeTimer.stop(); } else { TYPE_MC = new typeMC(); TYPE_MC.x = _x; TYPE_MC.y = _y; TYPE_MC.typeTF.text = typeArray[num]; TYPE_MC.filters = [new BlurFilter(10, 10, BitmapFilterQuality.HIGH)]; movieClip.addChild(TYPE_MC); } } } } }

    Read the article

  • Catch enter key press in input text field in AS3

    - by Jonathan Barbero
    Hello, I want to catch the enter key press when the user is filling an input text field in AS3. I think I have to do something like this: inputText.addEventListener(Event. ? , func); function func(e:Event):void{ if(e. ? == "Enter"){ doSomething(); } } But I can't find the best way to do this. By the way, the input text has a restriction: inputText.restrict = "0-9"; Should I add the enter key to the restrictions? inputText.restrict = "0-9\n"; Thanks in advance.

    Read the article

  • Let system time determine animation speed, not program FPS

    - by Anders
    I'm writing a card game in ActionScript 3. Each card is represented by an instance of a class extending movieclip exported from Flash CS4 that contains the card graphics and a flip animation. When I want to flip a card I call gotoAndPlay on this movieclip. When the frame rate slows down all animations take longer to finish. It seems Flash will by default animate movieclips in a way that makes sure all frames in the clip will be drawn. Therefor, when the program frame rate goes below the frame rate of the clip, the animation will be played at a slower pace. I would like to have an animation always play at the same speed and as a consequence always be shown on the screen for the same amount of time. If the frame rate is too slow to show all frames, frames are dropped. Is is possible to tell Flash to animate in this way? If not, what is the easiest way to program this behavior myself?

    Read the article

  • How to pass PHP variable as FlashVars via SWFObject

    - by Matt
    I am trying to take a PHP variable and pass it along to Flash via Flash vars. My end goal is to pass a string formatted as XML to Flash, but because I'm struggling I've stripped everything down to the basics. I'm just trying to pass a simple PHP string variable to Flash via FlashVars with SWFObject but something isn't right. The page won't load when I try to pass the variable inside of php tags, but it will load if I just pass a hard coded string. The basic structure of my page is that I have some PHP declared at the top like so: PHP <?php $test = "WTF"; ?> Some HTML (excluded here for simplicity sake) and then the JavaScript SWFObject Embed within my HTML: <script type="text/javascript" src="js/swfobject2.js"></script> <script type="text/javascript"> // <![CDATA[ var swfURL = "swfs/Init-Flash-PHP.swf"; var flashvars = {}; flashvars.theXML = <?php print $test ?>; var params = {}; //params.menu = "false"; params.scale = "showAll"; params.bgcolor = "#000000"; params.salign = "TL"; //params.wmode = "transparent"; params.allowFullScreen = "true"; params.allowScriptAccess = "always"; var attributes = {}; attributes.id = "container"; attributes.name = "container"; swfobject.embedSWF(swfURL, "container", '100%', '100%', "9.0.246", "elements/swfs/expressinstall.swf", flashvars, params, attributes); // ]]> </script> And the bare essentials of the ActionScript 3 Code: _paramObj = LoaderInfo(stage.loaderInfo).parameters; theText_txt.text = _paramObj['theXML']; How do I pass a PHP variable using SWFObject and FlashVars? Thanks.

    Read the article

  • EventDispatcher between an as and an fla?

    - by Christopher Richa
    Hi everyone. I am making a fighting game in Flash and while I have everything running, I am missing something: a victory/loss screen. Logically, I know how to do it: if character.hp < 0 { character.dead = true; dispatchevent("death", event) } My problem is that I have no idea as to how to code it. I know I will use two classes and my two .fla files (unless I am wrong). I have two .fla files that are in play here: the Menu.fla file and the Arena.fla file. Menu.fla contains the entire navigation of the game, options, character selection screens, etc. and when it is time for the player to engage in battle, it loads the Arena.fla file, which contains only the backgrounds (depending on the selected stage) and for now is set to a length of one frame only. For Arena.fla, the real action happens in my classes, but logically, I would only need HP.as and Character.as. In Character.as, I have declared the following variable: var isDead:Boolean = false; //is character dead? In HP.as, believe I should have the following: if(currentHp<0) { currentHp = 0; character.isDead = true; //declared as var `character:Object;` EventDispatcher.dispatchEventListener("playerDead", playerDead); } And finally, in Arena.fla, I want to be able to detect the above-mentioned eventlistener and simply move on to a second frame which will display a message in the style of "PLAYER ONE HAS WON" or "PLAYER ONE HAS LOST" with a button that will allow me to go back to the character selection screen. This is the first part in which I am stuck: how do I detect the dispatched event listener in my main .fla file? Secondly, if the player clicks on the "CONTINUE" button, which displays regardless if the player has won or lost, how can my Menu.fla (which loads the Arena.swf) detect this click event, unload the game, and go back to the character selection screen? Thank you in advance for helping me out. I realize this is a lot of text but it's the most descriptive I can be. If you have any questions or need any clarification concerning my question, feel free to speak up. -Christopher

    Read the article

  • Changing a sprites bitmap

    - by numerical25
    As of right now, I am trying to create a tiling effect for a game I am creating. I am using a tilesheet and I am loading the tiles to the sprite like so... this.graphics.beginBitmapFill(tileImage); this.graphics.drawRect(30, 0,tWidth ,tHeight ); var tileImage is the bitMapData. 30 is the Number of pixels to move retangle. then tWidth and tHeight is how big the rectangle is. which is 30x30 This is what I do to change the bitmap when I role over the tile this.graphics.clear(); this.graphics.beginBitmapFill(tileImage); this.graphics.drawRect(60, 0,tWidth ,tHeight ); I clear the sprite canvas. I then rewrite to another position on tileImage. My problem is.... It removes the old tile completely but the new tile positions farther to the right then where the old bitmap appeared. My tile sheet is only 90px wide by 30px height. On top of that, it appears my new tile is drawn behind the old tile. Is there any better way to perfect this. again, all i want is for the bitmap to change colors

    Read the article

  • Flex remoting and progress events?

    - by Cambiata
    Is there a way to monitor the loading progress (percent progress bar style) when using Flex remoting? I'm trying out Flash Builder 4 with it's new data services features, but I can't find any pgrogress event stuff somewhere. This article by Robert Taylor http://www.roboncode.com/articles/144 indicates that it might not be possible...

    Read the article

  • Returning errors from AMFPHP on purpose.

    - by Morieris
    When using flash remoting with amfphp, what can I write in php that will trigger the 'status' method that I set up in my Responder in Flash? Or more generally, how can I determine if the service call has failed? The ideal solution for me would be to throw some exception in php serverside, and catch that exception in flash clientside... How do other people handle server errors with flash remoting? var responder = new Responder( function() { trace("some normal execution finished successfully. this is fine."); }, function(e) { trace("how do I make this trigger when my server tells me something bad happened?"); } ); myService = new NetConnection; myService.connect("http://localhost:88/amfphp/gateway.php"); myService.call("someclass.someservice", responder);

    Read the article

  • This codes in Actionscript-2, Can anyone help me translate it into AS-3 please ?.......a newby pulli

    - by Spux
    this.createEmptyMovieClip('mask_mc',0); bg_mc.setMask(mask_mc); var contor:Number=0; // function drawCircle draws a circle on mask_mc MovieClip of radius r and having center to mouse coordinates function drawCircle(mask_mc:MovieClip):Void{ var r:Number = 20; var xcenter:Number = _xmouse; var ycenter:Number = _ymouse; var A:Number = Math.tan(22.5 * Math.PI/180); var endx:Number; var endy:Number; var cx:Number; var cy:Number; mask_mc.beginFill(0x000000, 100); mask_mc.moveTo(xcenter+r, ycenter); for (var angle:Number = Math.PI/4; angle<=2*Math.PI; angle += Math.PI/4) { xend = r*Math.cos(angle); yend = r*Math.sin(angle); xbegin =xend + r* A *Math.cos((angle-Math.PI/2)); ybegin =yend + r* A *Math.sin((angle-Math.PI/2)); mask_mc.curveTo(xbegin+xcenter, ybegin+ycenter, xend+xcenter, yend+ycenter); } mask_mc.endFill(); } // contor variable is used to hold if the mouse is pressed (contor is 1) or not (contor is 0) this.onMouseDown=function(){ drawCircle(mask_mc); contor=1; } // if the mouse is hold and moved then we draw a circle on the mask_mc this.onMouseMove=this.onEnterFrame=function(){ if (contor==1){ drawCircle(mask_mc); } } this.onMouseUp=function(){ contor=0; }

    Read the article

  • Flash Double-click an externally loaded SWF

    - by Trist
    OK. I've got a class (which extends MovieClip) that loads in an external SWF (made in pdf2swf). That is added to another class which has declared doubleClickEnabled = true and I'm listening for DOUBLE_CLICK events. Problem is when the SWF is loaded my code picks up no DOUBLE_CLICK events, only CLICK events. I've tried it without adding the SWF to the stage and it does pick up DOUBLE_CLICK events. Anybody come across this before? class ParentClass{ ... public function ParentClass(){ ... mcToLoadSWF = new MovieClip(); addChild(mcToLoadSWF); doubleClickEnabled = true; addEventListener(MouseEvent.DOUBLE_CLICK, doubleClickHandler); ... } } I've also tried adding the event listener to the mcToLoadSWF as well. No dice. Cheers Tristian

    Read the article

  • Trace() method doesnt work in FlashDevelop

    - by numerical25
    When I put a trace("test"); at the entry point of my flashdevelop project and run it. The application runs fine but I do not see the trace in the output. Below is my code package { import flash.display.Sprite; import flash.events.Event; /** * ... * @author Anthony Gordon */ public class Main extends Sprite { public function Main():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void { trace("test"); removeEventListener(Event.ADDED_TO_STAGE, init); // entry point var game:Game = new Game(stage); addChild(game); } }

    Read the article

  • AS3 Font embedding problem in ComboBox on a loaded movie clip

    - by Arafat
    Hi all, I have three movie clips, say, LoaderMC, ChildMC1, and ChildMC2. ChildMC1 has TLFTextfields in it with embedded fonts. ChildMC2 has both TLFTextfields as well as combo boxes.(with embedded fonts) When I compile those movieclips separately, I can view the combo box texts without any problem. If I load the ChildMC1 and ChildMC2 into the LoaderMC, the texts doesn't appear at all on both TLFtextfields and Combo Boxes. I tried embedding the fonts in the LoaderMC, then, TLFTextfields was able to show the texts but still the ComboBoxes couldn't display the text. If I don't embed the fonts in the combo box, I can able to view the texts. What could be the problem? I read an article which says, "No one has completely understood the font embedding in flash AS3, we just have to do trial and error, to get it done" I don't know how far it is true, but in my case it seems, I should agree! Please help me...

    Read the article

  • SoundChannel object plays small portion after being stopped and played again

    - by gok
    SoundChannel object is stopped and played again. When played again it plays small portion from the previous position and suddenly jumps back to the beginning. It doesn't play the whole sound before looping. This happens only once, then it loops normally. It happens again if I stop and play. public function play():void { channel = clip.play(trimIn); volume(currentVolume); isPlaying = true; timer.start(); channel.addEventListener(Event.SOUND_COMPLETE, loopMusic); } public function loopMusic(e:Event=null):void { if (channel != null) { timer.stop(); channel.removeEventListener(Event.SOUND_COMPLETE, loopMusic); play(); } } Do I need to somehow reset the soundChannel?

    Read the article

  • Flash hit detect area

    - by Quandary
    With Flash, is it possible to detect whether an object is fully ontop of another ? E.g. I have a rectangle (floor surface) and a circle (furniture). Now I want to detect whether the circle is fully in (=over) the rectangle, and not just whether it hits the rectangle somewhere. Is that possible ? How ?

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >