This is really very bizarre and I've wasted too much time on this - the following code works in a .fla perfectly (Flash Pro project), but when I try and use it in my ActionScript Project compiled with Flash Builder the input textfield doesn't recognize or display the new text. Even setting up eventhandlers to track the change do not work. I can use this.tf.text = 'blah' and it will work, but it will not accept user input.
this.tf = new TextField();
this.tf.x = 100;
this.tf.y = 100;
this.tf.width = 100;
this.tf.height = 20;
this.tf.type = TextFieldType.INPUT;
this.tf.restrict = null;
this.addChild(this.tf);
Has anyone come across this before? I've uninstalled Flash Builder Pro and reinstalled it, too.
Related
I've encountered strange behavior when using AS3's TouchEvents to handle multi-touch. The touch lags considerably in certain situations, but Flash's frame rate isn't affected. It's as though the touches are getting buffered and the events just aren't dispatched until several seconds after the touch.
I've uploaded a demonstration here: https://youtu.be/omkCDqljfio
I've only managed to reproduce this touch lag in the ActiveX version of Flash Player, but I've reproduced it in both Windows 10 and Windows 7. So what I have here is a C# application that's hosting my AS3 test suite, but it can also be observed if the swf is viewed in Internet Explorer.
Since my application already involves hosting the SWF in a WPF window, I've been attempting to create a solution where touch is received in C# and then communicated to the AS3. It would work perfectly but it seems my WPF window isn't receiving touch frames when the touch is on a WindowsFormsHost. So there's another problem that I have to solve.
FlashDevelop project: https://drive.google.com/file/d/0BxC2eCzurT9rd0gzSGc4TUdQLTQ/view
Visual Studio solution: https://drive.google.com/file/d/0BxC2eCzurT9rUThmRHBKWHZmbzA/view
AS3 touch events:
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
stage.addEventListener(TouchEvent.TOUCH_BEGIN, stage_touchBegin);
stage.addEventListener(TouchEvent.TOUCH_MOVE, stage_touchMove);
stage.addEventListener(TouchEvent.TOUCH_END, stage_touchEnd);
Creating the display objects that contribute to the lag, presumably because of the touch event capture phases:
for (var i:int = 0; i < 500; i++)
{
Dotter.createBGDot(_bgLayer, _shapesOn ? Shape : Sprite);
}
...
static public function createBGDot(bgLayer:Sprite, dotClass:Class):void
{
var dot:* = new dotClass();
var color:Color = new Color();
color.brightness = Math.random();
dot.graphics.beginFill(color.color);
dot.graphics.drawCircle(0, 0, Math.random() * 400 + 40);
dot.x = Math.random() * bgLayer.stage.stageWidth;
dot.y = Math.random() * bgLayer.stage.stageHeight;
bgLayer.addChild(dot);
}
I know this is sort of an unusual situation, but I appreciate any advice about how to resolve these issues.
Now that I've used Adobe Scout I think it is a rendering issue after all. The frame rate still shows 30fps because the processing time just barely manages to hit the 30fps mark. Lowering the frame rate fixes the problem.
It is still strange that the touch events would have such a long delay when the frame rate is just barely falling short, though.
I need to send a query string from Flash so that it appears in address bar of a browser. Basically, I need to make a Flash version of this HTML code:
link
Seems simple... When I try to do this from Flash the browser cuts off the query string. So instead of getting Portfolio.htm?image=4, I only get Portfolio.htm This is the actionscript I am using:
var url:String = "Portfolio.htm";
var variables:URLVariables = new URLVariables();
variables.image = '4';
var newRequest:URLRequest = new URLRequest(url);
newRequest.data = variables;
newRequest.method = URLRequestMethod.POST;
navigateToURL(newRequest);
This actionscript works great when I click the button from the Flash player. It stops working when I try to put the swf into a HTML wrapper.
The query string image=4 is not going to PHP file. Portfolio.htm uses Javascript to strip the variable from the URL. Most of the questions surrounding this topic deal with PHP files and don't care if the query string appears in the browser address bar.
Try changing the URLRequestMethod to GET instead of POST.
newRequest.method = URLRequestMethod.GET;
Or simply leave it out because GET is the default method.
Im probably some 4 hours old working with flash CS5, and im trying to create a website that just displays a goggle map with two text fields that the user would enter some details(its for demo purposes), Have no issue with the google Map Part, but i have probably the dumbest Question ever, how do i create a textfield in flash. Or am i using the wrong tool for the task?
Thank You
If you are trying to do so via AS3, it's really simple. Given some parent clip you'd like the textfield to be placed into
var tfTextfieldName:TextField = new TextField();
tfTextfieldName.type = TextFieldType.INPUT;
tfTextfieldName.border = true;
tfTextfieldName.x = 10;
tfTextfieldName.y = 10;
tfTextfieldName.multiline = true;
tfTextfieldName.wordWrap = true;
parentClip.addChild(tfTextfieldName);
I took this straight from the Adobe doc page for the Textfield Class. There you'll all the events/properties available.
I have a textField on my stage named 'adBuy', which when clicked I want to open up my browser with the defined in URL request. However when I click on the 'adBuy' textField on my SWF it opens Coda, the piece of software I'm using to write this small piece of code?
I am puzzled. Here is my code:
adBuy.defaultTextFormat = adFormat;
adBuy.textColor = 0xFF65CB;
adBuy.x = 640;
adBuy.y = 455;
adBuy.text = "Buy Now";
parent.addChild(adBuy);
adBuy.addEventListener(MouseEvent.CLICK, buyAdvert);
var request:URLRequest = new URLRequest("http://www.google.co.uk");
function buyAdvert(event:MouseEvent):void {
navigateToURL(request, "_blank");
trace("link clicked");
}
Is there an error in my code, or is this a common problem for which there is an answer?
Sorry, I have solved my problem.
It appears the reason it was not opening a web browser with the URL it because I was running the SWF through 'Test Movie' in Flash. This appears to have been stopping the code working.
It did however work fine when I ran it in Flash Player.
I am trying to put a vertical scrollbar onto a dynamic TextField in Flash CS4. When I do this in Scene 1, everything works just fine. However, if I move the TextField+Scrollbar to Scene 2, it breaks. The errors I get when I run the code indicate that Flash is loading the scrollbar right away and then trying to find the associated TextField. The problem is that, since the TextField doesn't load until you get to Scene 2, Flash throws an error.
I tried a lot of things to solve this issue. What it mostly came down to was that I needed to create the TextField and Scrollbar in actionscript (instead of from the component library) so that I could control when each was created. To create the TextField, I typed:
//create a textfield for the story
import flash.text.TextField;
var story_txt:TextField = new TextField();
//story_txt.multiline = true;
story_txt.x = 154;
story_txt.y = 233.5;
story_txt.width = 348;
story_txt.height = 104.5;
story_txt.border = true;
story_txt.type = "dynamic";
story_txt.backgroundColor = 0xffffff;
story_txt.background = true;
story_txt.wordWrap = true;
story_txt.multiline = true;
and to create the scrollbar, I then typed:
import fl.controls.UIScrollBar;
//add the story_txt to the stage
addChild(story_txt);
var mySb:UIScrollBar = new UIScrollBar();
mySb.direction = "vertical";
// Size it to match the text field.
mySb.setSize(story_txt.width, story_txt.height);
// Move it immediately to the right of the text field.
mySb.move(story_txt.x, story_txt.height + story_txt.y);
// put them on the Stage
mySb.scrollTarget = story_txt;
//mySb.scrollTargetName = "story_txt";
stage.addChild(mySb);
The only problem is that this code only works if I make the ScrollBar horizontal and turn off wordwrap. For some reason, the vertical scrollbar will not work with wordrap on (and w/o wordwrap, Flash thinks that there's no need for a vertical scrollbar, as it sees only a single line of text.
Getting a textfield w/a scrollbar should be a simple process, but this is really out of hand. Any ideas on how to get the ScrollBar to work when wordWrap is turned on?
Basically you should never use Scenes in Flash. There are a lot of known issues with them.
This thread might help.
Scene usage is generally bad practice. They are a legacy feature left in to keep current versions of flash compatible with earlier versions. If you must use the IDE to place things on stage you should use distinct frames on the main timeline in place of scenes, and place things that need the timeline to animate inside their own movieclips. The flash IDE actually reduces all the scenes down to one timeline at compile time any way but with many anomalies that wouldn't be present in manual timeline manipulation.
disadvantages of scenes from adobe: http://help.adobe.com/en_US/Flash/10.0_UsingFlash/WSd60f23110762d6b883b18f10cb1fe1af6-7eb3a.html