spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
  Home » ACTIONSCRIPT » Page 1
AS3 - preventDefault() doesn't work in fullscreen (AIR)
I created a new project (FlashDevelop) targeting AIR 14 (also successfully tried AIR 3.9) with the following document class file: package { import flash.desktop.NativeApplication; import flash.display.NativeWindow; import flash.display.NativeWindowInitOptions; import flash.display.NativeWindowRenderMode; import flash.display.NativeWindowSystemChrome; import flash.display.

Categories : Actionscript

Accessing variables on Document class from a child class
Your "problem" is that AS3 is OOP, which means that classes work separately and you need to connect them. The old "way" of doing this (using root) is absolutely wrong when dealing with bigger projects. There are many ways to do the connection between classes. First, your Main class acts like root (if defined as base class through Properties in Flash IDE). So if you create a class that is DisplayO

Categories : Actionscript

ActionScript 3 stage width
Your problem, is likely this line: if(kugla1.y<=kugla1.height/2 || kugla1.height>=stage.stageHeight-kugla1.height/2) In the second part (after the ||) you are comparing the height of kugla1 instead of the y position. Another issue you could run into, is your ball could potentially meet the same condition for longer than one frame, so it would be best to separate your speed from the c

Categories : Actionscript

Keep item at same monitor position regardless of window size/position
To get your started: Something along these lines is what you'll need to do: stage.align = StageAlign.TOP_LEFT; //you'll need to running a top-left no-scale swf for this to work stage.scaleMode = StageScaleMode.NO_SCALE; var itemPoint:Point = new Point(150,150); //the point on the monitor the object should reside //call this anytime the item needs to be redrawn (eg when the window changes siz

Categories : Actionscript

AS3 - Is there a way to write this with lesser code
You can encapsulate button creation, for example: private function addButton(menu:Sprite, clickHandler:Function):void { var button:Sprite = new Sprite(); button.addEventListener(MouseEvent.CLICK, clickHandler); menu.addChild(button); } Also, you can use anonymous functions like that: button.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void { doStuff(); }); Bu

Categories : Actionscript

receive multiple incoming streams in netgroup p2p multicast (adobe cirrus)
When you use Netstream with GroupSpecifier, you need to create a Netgroup with the same GroupSpecifier. Then Publisher 1: Netstream.publish("stream1") Publisher 2: Netstream.publish("stream2") // etc. And Clients: Netstream.play("stream1"); Netstream.play("stream2"); // etc.

Categories : Actionscript

AS3 : CLOSE EXTERNAL SWF AND GET BACK TO MAIN TIMELINE
You need to add button from your main "swf" (which is main all the time, just the secondary is added on top of it). Otherwise you need to make call from the secondary back to the primary (which is potentially bad, risky and awful practice, but in your case maybe good enough): MovieClip(parent).callPublicFunction(); // Secondary.as removeChild(loadcase1); // Main.as - removes the loade ("secondar

Categories : Actionscript

AS3: fullscreen mode issue
You can be notified of fullscreen enter/exit events by adding a listener to the Stage: stage.addEventListener(FullScreenEvent.FULL_SCREEN, ...) Here is a link to the Stage documentation: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Stage.html#event:fullScreen For the imgZoom issue you need to move the definition outside the btnClick function. The imgZoom varia

Categories : Actionscript

Load MovieClip With Click Btn
This line stage.addEventListener(Event.ENTER_FRAME,clickHandler); is clashing with function clickHandler(event:MouseEvent):void You have to decide which one it's going to be.. either its a mouse event (when mouse does something like clicked or moved) or it's an enterFrame event (your Flash Player screen updates 24 times every second, so on each update (frame) you can use enterframe to change som

Categories : Actionscript

AS3 Object Movement
Firs of all: to generate a random number, use Math.random() This generates a random number between 0 and 1. To get a number between 0 and 400, you can multiply this number by 400 and then use Math.round(number) To move the asteroids, first you will need to create an array to store them all in. var asteroids:Array = new Array; You will need a timer with an event listener to add them. va

Categories : Actionscript

AS3 Math.random generating the same number
You are generating random number outside of event listener. So you are never changing myNum. You need to move that inside the creakers method. function creakers(e:Event):void { var myNum:Number = Math.floor(Math.random() * 2000); trace(myNum); }

Categories : Actionscript

Want to programmatically set zoom on yworks GraphCanvasComponent with ActionScript
I spoke with the yworks engineers and they said that after the RoundtripHandler has finished it schedules a fitContent call. Since this will be executed asynchronously it will overwrite the zoom settings. The solution is to the set fitContentOnUpdate property to false on the RoundtripHandler. When you do this then the fitContent call does not happen.

Categories : Actionscript

is there any practical difference between these two if() statements?
The main difference is that in the first example, if the value of myVar changes between the two blocks to false, the second statement will still execute. In the second example, even if myVar becomes false after the first block completes, the else clause will not be executed because the associated if clause has already been executed (only one of them will run). As far as performance and code quali

Categories : Actionscript

add value to current value of text input in flash AS3?
You can concatenate strings using the addition operator (+). For example: trace(btn1.clickTitle + btn2.clickTitle + btn3.clickTitle); //traces "BALLBookPen" Adding on to an existing string is done with addition assignment (+=). Since you want a comma and space between each string, this is how you'd rewrite your function: function clipClick(e:Event):void { MovieClip(root).main.loginHolder.r

Categories : Actionscript

AS3 embedded video player
What the...?? This.code worked? So anyway.. You've got var video:Video = new Video(480,204); but you go on to say addChild(this.video123); so where is this this.video123 coming from?? If you want to add the video object you just created in the first line then it should be addChild(video); or else... If video123 is a movieClip on stage then use video123.addChild(video); Further down you should c

Categories : Actionscript

How to select audio sources from a list Flash + ActionScript3
Microphone.names is a static property, meaning that you must access it from the class itself. You're trying to access it from an class instance, microphone. You should do this: sourceVideoLabel.text += Microphone.names; Note the capital M, meaning you're accessing the class not the instance. Microphone.name, on the other hand, is non-static, and is accessed through the instance microphone to g

Categories : Actionscript

Error: Call to a possibly undefined method crearNotaS through a reference with static type Class
ActionScript is an object oriented Language. Classes are supposed to be objects too and when you want to access their methods you either need to make an instance of them first or make sure the target function is of type "Static", which has limitations of its own. This is all about core concepts which you need to know before running your code. I suggest taking a look at some tutorials about classes

Categories : Actionscript

Alternative to using "math.round" in Google Banner ads? (Flash AS3)
Math.random() returns a number between 0 and 1. When you call getRan(20) you're asking for a number between 0 and 20. According to the documentation, the default for the function is 1 so in your case you should be able to call it without any parameters: getRan(); // Give me a random number between 0 and 1

Categories : Actionscript

Access class instance from another function - getDefinitionByName(AS3)
I figured it out. I just forgot to cast as a DisplayObject. public class Main extends MovieClip{ private var sceneNumber:int = 1; private var SceneRef:Class; private var sceneString:String; public function Main(){ sceneLoader(); responseHandler(); } private function sceneLoader():void{ addChild(getScene() as DisplayObject); } private fun

Categories : Actionscript

Flash Button Linking and Toggle
I'd recommend creating a small class for all your buttons, it shall contain its value. You also need an object that will contain a list of these buttons, let's call it Application. When user clicks on Button1, it will set a field inside Application indicating the toggle - product of all values or just the button that was pressed. This then sets the actual text to whatever was passed (I've called i

Categories : Actionscript

Flash Pro Admob Banners
maybe you can try to run this flash file.it is a file by flash pro cc https://github.com/lilili87222/Admob-ANE/blob/master/demo.fla

Categories : Actionscript

Cannot open webpage from flash button
This is due to security measures. Change '_self' to '_blank' within your AS or set 'allowScriptAccess' to 'always' within your html. Refer to this page for more info.

Categories : Actionscript

Redefining the hitbox of objects?
Well yeah flash does that, it needs some time to properly add movieclips to Stage. It's the reason why Event.ADDED_TO_STAGE exists, read this article to understand it better. But I'd say you would be pretty safe to go with a simple if statement making sure shark and shark.hitto are properly initialized and are sitting on stage. if(shark && shark.hitto) { // Do collisions }

Categories : Actionscript

How to access class functions during events from currentTarget object in AS3
//use this code it will work function clickEvent(evt:MouseEvent):void { var Obj:SampleClass = evt.currentTarget as SampleClass; trace (Obj.getStr()); }

Categories : Actionscript

Is there any way to run two instances of flash professional debug
This is not an answer to your question but a suggestion to take a different approach. The Flash IDE and it's debugger are inadequate but for most trivial programs. Variable inspection and breakpoints work randomly and it's next to impossible to drill down into more complex objects. Flash IDE is all right for creating the visual resources for Flash programs but for any serious coding, it just fall

Categories : Actionscript

AIR App, load swf from server, call parent function?
Instead of listening to Event.ENTER_FRAME, you could dispatch a custom event from within your child swf: dispatchEvent(new Event("childComplete")); Then you'd listen for only that event in your AIR app.

Categories : Actionscript

ActionScript 3 not showing jpg
Here's a nice way to go about creating a convenient container for all your graphics using starling: public class Art { [Embed(source = "../textures/foo.jpg")] private static const FooBitmap:Class; public static var FooTexture:Texture = MakeTexture(FooBitmap); private static function MakeTexture(_Texture:Class):Texture { var bitmap:Bitmap = new _Texture(); return Text

Categories : Actionscript

Possible to call a Flash (AS3) function when dynamic scrolling text has reached the bottom?
Something like this should do the trick: myTextField.addEventListener(Event.SCROLL, scrollHandler); function scrollHandler(e:Event):void { if (myTextField.scrollV >= myTextField.maxScrollV) { trace("You've Reached The End - It happens to us all eventually"); //do your animation } }

Categories : Actionscript

Why do I have to manually add Flex libraries in ActionScript Project
Create a new Flex project instead of an Actionscript project. On the File menu, choose "New > Other", then expand Flash Builder and choose "Flex Project" The Flex SDK will be included automatically.

Categories : Actionscript

Try/catch issue - code not executing? AS3
I know you already figured it out but for the sake of the community, please give the solution as an accepted answer in future so anyone browsing the site can tell if it's answered or not (this helps both experts and learners). The practice of answering your own questions is actually promoted quite strongly in the FAQ's. The problem occurred when the file that was trying to be deleted didn't

Categories : Actionscript

Adobe FLASH AS3 textfield change color
TextField.setTextFormat only affects the characters you specify. In order to change the color for all text, you'll want to set the default text format of the TextField: myTextP1.defaultTextFormat = format; Conversely, you could also just set it via the textColor property of the TextField: myTextP1.textColor = 0xFF0000;

Categories : Actionscript

Going to a specific frame on key press
You committed these mistakes: KEY.getCode() // KEY in capital letters key.addListener(cheat) // key in lowercase letters The Key class By convention all the classes begin with a capital letter. The correct spelling for the Key class is Key. The correct code var keyListener:Object = new Object(); keyListener.onKeyDown = function():Void { if (Key.getCode() == Key.SPACE) {

Categories : Actionscript

Supplying compiler constants using Jenkins to build an Adobe AIR project
I found the following resource which referenced how to achieve this: <project> <build> <sourceDirectory>src</sourceDirectory> <plugins> <plugin> <!-- Allows SWF to be compiled --> <groupId>org.sonatype.flexmojos</groupId> <artifactId>flexmojos-maven-plugin</artifactId>

Categories : Actionscript

If hitTestObject = true return current position on screen?
If you don't want fireboy1 to go past the basePlatform, you should probably do something like: fireboy1.y = basePlatform.y - fireboy1.height Please note that this all depends on both fireboy1 and basePlatform having top-left orientation.

Categories : Actionscript

Controlling ActionScript 3 with dynamically loaded text file
In this case, you can use the this[string] syntax against root.loaderInfo.parameters. Then, if your loaded text file says there should be a clickTag2 variable, available via string variableName, you use that in your function like this: function fl_ClickToGoToWebPage_2(event:MouseEvent):void { var click_url:String = root.loaderInfo.parameters[variableName]; // here you are, now your functi

Categories : Actionscript

AS3 movie clip button is not working
The code as is should work, so I can only guess the issue. When you advance the timeline, the buttons you add actions to need to be present at all times. If the timeline advances to somewhere that the button does not exist, the action is removed, when you then go back, where the button exists, you will no longer have that action available. You can solve this by having the buttons present at all

Categories : Actionscript

Any idea why my boolean variables aren't working?
In your releaseKey function you have an extra = in the following statement: keyCollected == true; Which just evaluates to a boolean and does nothing. If you change it to keyCollected = true, the if statement in the open function should evaluate to true.

Categories : Actionscript

Making objects chase another (AS3)
I would suggest using Math.min (when dx or dy is negative) and Math.max (when dx or dy is positive) with a value you define to be your max speed ie: var maxSpeed:Number = 20; if (dx >= 0){ dx = Math.max(dx,maxSpeed) }else{ dx = Math.min(dx,maxSpeed) } repeat for dy

Categories : Actionscript

Flickering rectangle using AS3 and drawRect() when using math for coordinates
Instead of redrawing the rectangle each frame you could simply scale it. var mc:MovieClip = new MovieClip(); mc.graphics.beginFill(0xFF1230); mc.graphics.drawRect(0,0,1,1); mc.graphics.endFill(); addChild(mc); stage.addEventListener(Event.ENTER_FRAME, loop); function loop(e:Event) { mc.scaleX = mouseX; mc.scaleY = mouseY; }

Categories : Actionscript


Recently Add
Select screen in AS3
AS3 - preventDefault() doesn't work in fullscreen (AIR)
Accessing variables on Document class from a child class
ActionScript 3 stage width
Keep item at same monitor position regardless of window size/position
AS3 - Is there a way to write this with lesser code
receive multiple incoming streams in netgroup p2p multicast (adobe cirrus)
AS3 : CLOSE EXTERNAL SWF AND GET BACK TO MAIN TIMELINE
AS3: fullscreen mode issue
Load MovieClip With Click Btn
AS3 Object Movement
AS3 Math.random generating the same number
Want to programmatically set zoom on yworks GraphCanvasComponent with ActionScript
is there any practical difference between these two if() statements?
add value to current value of text input in flash AS3?
AS3 embedded video player
How to select audio sources from a list Flash + ActionScript3
Error: Call to a possibly undefined method crearNotaS through a reference with static type Class
Alternative to using "math.round" in Google Banner ads? (Flash AS3)
Access class instance from another function - getDefinitionByName(AS3)
Flash Button Linking and Toggle
Flash Pro Admob Banners
Cannot open webpage from flash button
Redefining the hitbox of objects?
How to access class functions during events from currentTarget object in AS3
Is there any way to run two instances of flash professional debug
AIR App, load swf from server, call parent function?
ActionScript 3 not showing jpg
Possible to call a Flash (AS3) function when dynamic scrolling text has reached the bottom?
Why do I have to manually add Flex libraries in ActionScript Project
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.