I'm using swfobject to embed my flash. It's doing weird things.
I've created a simple textfield using FlexBuilder. It's an AS3 project, which extends Sprite. I've set its width to be 640 and height to 450. Then, in the swfobject parameters of the page, I've also set 640 x 450. I've made the background nice and red and ugly so you can see it. :)
http://www.brighttext.com/flash/TextFieldSetFormat.html
It seems to be the right dimensions. BUT I've got a textfield which is supposed to be almost the same size and height. This runs fine in FlexBuilder (is the right size) but is all messed up once I add swfobject Can anyone see what is happening?
EDIT NOTE: I just looked at it and it looks ok. But then I refreshed the page and the textfield is postage-stamp size (again -- this is the original behavior I saw.) It's now looking OK in firefox but not in IE8. Flash is supposed to look the same in all browsers !!??
AS3 code:
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.Font;
[SWF(width="640", height="450", backgroundColor="#FFFFFF", frameRate="30")]
public class TextFieldSetFormat extends Sprite
{
[Embed(source='C:/WINDOWS/Fonts/ArialBD.TTF', fontWeight = 'bold', fontName='ArialBold')]
[Embed(source='C:/WINDOWS/Fonts/Arial.TTF', fontWeight = 'regular', fontName='Arial')]
public function TextFieldSetFormat()
{
var tf2:TextFormat = new TextFormat();
tf2.size = 16;
tf2.font = "Arial";
Font.registerFont(_VerdanaFontBold);
Font.registerFont(_VerdanaFont);
var pad:Number = 10;
var brightTextField:TextField = new TextField;
brightTextField.backgroundColor = 0xDDF3B2;
brightTextField.background = true;
brightTextField.embedFonts = true;
brightTextField.border = true;
brightTextField.defaultTextFormat = tf2;
brightTextField.wordWrap = true;
brightTextField.multiline = true;
brightTextField.width = stage.stageWidth - (4 * pad);
brightTextField.height = stage.stageHeight - (3 * pad);
brightTextField.x = 2*pad;
brightTextField.y = 2*pad;
brightTextField.text = "Dear Senators, I have become concerned over the idea that some in the Senate will oppose the public option because of a group of wild-eyed, overbearing but misinformed ideologues. These people mistakenly equate insurance reform with Socialism and call our first African-American President unprintable epithets. This is unacceptable. The public option is the choice of more than 70% of Americans, a majority of the House and a great many opinion leaders. Passing insurance reform without a public option persists the current broken system. I am aware that many Senators would prefer to pass a reform bill with bipartisan support. But we cannot allow this critical debate to be hijacked by extremists or corporate profiteers. Thank you, and I look forward to hearing from you.";
addChild(brightTextField);
}
}
}
Try tracing the value of stage.stageWidth/Height and use a plugin like Flash Tracer to see what its outputting.
You might just need to add an event listener for Event.ADDED_TO_STAGE/INIT and execute your setup code within that listener.
OK, well, I've figured this out.
The problem is in using stage.stageWidth and stage.stageHeight. I'm not yet sure why this is so, but in the spirit of agile development, it's a fix. :)
Instead of using stage.stageWidth, just use a number of pixels. (640 x 450, in my case). The problem then goes away.
I'll post more about this -- including screenshots I took, and tests I did, soon on my blog and will post a link here.
Related
I am trying to find out how to get a mouse working inside RPCS3 emulator for a game (Ghost Recon Future Soldier with patch 1.05)
There is a library that supports injecting the mouse but doesn't support the game I am trying to play. After a lot of digging, I found a library that actually implements mouse injection in a few games.
Sample implementation for the KillZone3 game to support mouse injection looks like this in C#
using KAMI.Core.Cameras;
using KAMI.Core.Utilities;
using System;
namespace KAMI.Core.Games
{
public class Killzone2PS3 : Game<HVecVACamera>
{
DerefChain m_hor;
DerefChain m_vert;
public Killzone2PS3(IntPtr ipc, string version) : base(ipc)
{
uint baseAddress = version switch
{
"01.01" => 0x117e740 + 0x234,
"01.29" => 0x11B0540 + 0x234,
_ => throw new NotImplementedException($"{nameof(Killzone2PS3)} [v'{version}'] is not implemented"),
};
var baseChain = DerefChain.CreateDerefChain(ipc, baseAddress, 0x0);
m_vert = baseChain.Chain(0x80).Chain(0x5c).Chain(0x11c).Chain(0x78);
m_hor = baseChain.Chain(0x78).Chain(0x0).Chain(0x68).Chain(0xc).Chain(0x90);
}
public override void UpdateCamera(int diffX, int diffY)
{
if (DerefChain.VerifyChains(m_hor, m_vert))
{
m_camera.HorY = IPCUtils.ReadFloat(m_ipc, (uint)m_hor.Value);
m_camera.HorX = IPCUtils.ReadFloat(m_ipc, (uint)(m_hor.Value + 4));
m_camera.Vert = IPCUtils.ReadFloat(m_ipc, (uint)m_vert.Value);
m_camera.Update(diffX * SensModifier, -diffY * SensModifier);
IPCUtils.WriteFloat(m_ipc, (uint)m_hor.Value, m_camera.HorY);
IPCUtils.WriteFloat(m_ipc, (uint)(m_hor.Value + 4), m_camera.HorX);
IPCUtils.WriteFloat(m_ipc, (uint)m_vert.Value, m_camera.Vert);
}
}
}
}
Main lines in the above program are those addresses which I believe are associated with the camera pointer stored in memory obtained mostly with Cheat Engine.
What is the process required to find these pointers for my game. I am aware that is may be different for each game but I could really use some direction here. Where do I start? How do I narrow down till I arrive at this pointer
What a coincidence, I am also doing the exact same thing on RPCS3 right now. After digging around I've found some videos that discuss into how to use Cheat Engine to find where a player's position and camera would be stored. It involves making a lot of separate scans in Cheat Engine to search for unknown values that are increasing/decreasing.
This video seems to be the closest thing to what you are looking for:
https://www.youtube.com/watch?v=yAl_6qg6ZnA
You should also make sure you set up Cheat Engine so it works with RPCS3 correctly as shown here:
https://exvsfbce.home.blog/2019/08/24/basic-cheat-engine-setup-on-rpcs3/
After you've found the correct pointer for the camera it should be fairly easy to implement it into the library by making your own class in the Games folder.
I'm new to Flex and am trying to port a pure Flash/AS3 card game to Flex 4.5.
It works mostly well, but I'm missing few puzzle parts there:
I've created a custom component based on UIComponent representing a deck of cards (which are an array of Sprites or MovieClips):
In the original pure Flash/AS3 game I was using Tween for the 3 cards at the table - to show the game user, who has put which card (by sliding them towards playing table middle):
import fl.transitions.*;
import fl.transitions.easing.*;
public class Deck extends UIComponent {
private var _card:Array = new Array(3);
private var _tween:Array = new Array(3);
....
override protected function createChildren():void {
_tween[YOU] = new Tween(_card[0], 'y', Regular.easeOut, _card[0].y + 40, _card[0].y, .5, true);
_tween[LEFT] = new Tween(_card[1], 'x', Regular.easeOut, _card[1].x - 40, _card[1].x, .5, true);
_tween[RIGHT] = new Tween(_card[2], 'x', Regular.easeOut, _card[2].x + 40, _card[2].x, .5, true);
....
However Flash Builder 4.5 doesn't seem to know fl.transitions.* packages at all?
Does anybody please have an advice on how to use Tween here?
Like I've written the rest (my custom Flex component, moving card-Sprites around, etc.) works well. Only the Tween lines had to be commented.
Thank you!
Alex
Take a look at the Tweener class on Google Code. With it you can specify and object, and a map of its properties and their desired values, along with time, and it will 'tween' those properties from their current to their desired values.
Tweener.addTween(yourCard, {y:50, time:1});//for a 1 second tween
My first knee-jerk reaction has been to add flash.swc (delivered by Flash CS Pro) to the Flex build path and then:
import fl.transitions.*;
import fl.transitions.easing.*;
can be used again.
But in the long-term I will probably write my own function to move the playing cards and run it on Event.ENTER_FRAME. Because I don't want to include Tweener or Tweenlite libraries for mere card sliding.
_tween[0] = _card[0].y;
_tween[1] = _card[1].x;
_tween[2] = _card[2].x;
....
_card[0].y = _tween[0] + 20;
addEventListener(Event.ENTER_FRAME, slideCardYou);
_card[1].x = _tween[1] - 20;
addEventListener(Event.ENTER_FRAME, slideCardLeft);
_card[2].x = _tween[2] + 20;
addEventListener(Event.ENTER_FRAME, slideCardRight);
....
private function slideCardYou(event:Event):void {
if (_card[0].y-- < _tween[0])
removeEventListener(Event.ENTER_FRAME, slideCardYou);
}
private function slideCardLeft(event:Event):void {
if (_card[1].x++ > _tween[1])
removeEventListener(Event.ENTER_FRAME, slideCardLeft);
}
private function slideCardRight(event:Event):void {
if (_card[2].x-- < _tween[2])
removeEventListener(Event.ENTER_FRAME, slideCardRight);
}
Also I've looked at mx.effects.Tween and spark.effects.Animate but they seem to be more appropriate for UIComponents and not Sprites as in my case.
i wonder if it is possible to pre-configurate Flex Elements on the Server. I have the Problem with a custom ItemRenderer which turns out to be very slow. It would be very cool to pre-process such an element on the server instead in the clients browser... somehow? Maybe it is possible to produce the MXML dynamically on the server for that.
This is it basically. I create a Label for each data entry in an array list. This entry is added to a BorderContainer and this goes to the containing element as a whole here. Sometimes i add 200 - 300 items this way which is costing very high computing cost at client side. So i wonderd if i could just pass this as a whole dynamic mxml element to the client.
override public function set data(value:Object):void {
_data = value as WordResultObject;
var data:WordResultObject = _data as WordResultObject;
this.removeAllElements();
if(_data!=null)
{
_l.text = data.wordform;
_l.setStyle("fontSize", data.fontSize);
_l.setStyle("color", data.color);
_l.toolTip = "Frequency: " + data.freq;
if(data.date != null)
{
_l.toolTip += "\nDate: " + AppUtils.TimeString(data.date as Date);
_l.addClickEvent(data.id as int, data.date as Date);
}
_border.addElement(_l);
this.addElement(_border);
}
}
Thank you
Andreas
I wonder if it is possible to
pre-configurate Flex Elements on the
Server.
Not that I know of. Perhaps if you go back to Flex 1 / 1.5 which was primarily a server based platform. I do not expect rolling your code back to an "old" server would improve efficiency at all, though. How would you expect this work? What benefit are you expecting to receive.
I have the Problem with a custom
ItemRenderer which turns out to be
very slow.
Show your code; and perhaps we can help you with writing your renderer to be more efficient.
We need to be able to handle a "playable" (play/pause/seek) effect in which the nature of the effect cannot be determined at compile time.
The problem we are running into is resetting the target(s) state after the effect has completed. If we manually drag the seek slider back to the beginning, everything works fine. However, if we set the playheadTime of the composite effect back to 0, the effected targets retain their original value until the playheadTime gets to the correct position to effect the target.
Here is a simplified (as much as I could) test case with view source enabled:
http://www.openbaseinteractive.com/_tmp/PlayableEffectTest/
The problem is demonstrated if you let it play to the end, and then hit the play button to start it over.
What is the best way to go about manually resetting the target values given that the exact nature of the effect is unknown?
Many thanks for your time!
edit
I forgot to mention we are using Flex 4.5 preview release.
Have you tried:
effect.reverse()
More info
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/effects/IEffect.html
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/effects/IEffect.html#reverse()
Well it's a little kludgy, but I was able to accomplish this by calling some internal methods on the effect to capture the start values, then assigned those values to the targets on a reset.
import mx.core.mx_internal;
use namespace mx_internal;
private var _propertyChangesArray:Array;
protected function captureStartValues(effect:Object):void
{
effect.captureStartValues();
_propertyChangesArray = effect.propertyChangesArray;
}
protected function reset(effect:Object):void
{
for each(var change:PropertyChanges in _propertyChangesArray)
{
var target:Object = change.target;
for(var p:String in change.start)
{
if(target.hasOwnProperty(p))
{
var startVal:* = change.start[p];
var endVal:* = target[p];
if(!isNaN(startVal) && startVal != endVal)
{
target[p] = startVal;
}
}
}
}
effect.playheadTime = 0;
}
I don't know if this is the best way to accomplish this, but it seems to be working so far. I am absolutely open to suggestions for a better method.
Cheers!
I'm trying to request a HTTP resource that requires basic authorization headers from within an Adobe AIR application. I've tried manually adding the headers to the request, as well as using the setRemoteCredentials() method to set them, to no avail.
Here's the code:
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
private function authAndSend(service:HTTPService):void
{
service.setRemoteCredentials('someusername', 'somepassword');
service.send();
}
private function resultHandler(event:ResultEvent):void
{
apiResult.text = event.result.toString();
}
private function resultFailed(event:FaultEvent):void
{
apiResult.text = event.fault.toString();
}
]]>
</mx:Script>
<mx:HTTPService id="apiService"
url="https://mywebservice.com/someFileThatRequiresBasicAuth.xml"
resultFormat="text"
result="resultHandler(event)"
fault="resultFailed(event)" />
<mx:Button id="apiButton"
label="Test API Command"
click="authAndSend(apiService)" />
<mx:TextArea id="apiResult" />
However, a standard basic auth dialog box still pops up prompting the user for their username and password. I have a feeling I'm not doing this the right way, but all the info I could find (Flex docs, blogs, Google, etc.) either hasn't worked or was too vague to help.
Any black magic, oh Flex gurus? Thanks.
EDIT: Changing setRemoteCredentials() to setCredentials() yields the following ActionScript error:
[MessagingError message='Authentication not supported on DirectHTTPChannel (no proxy).']
EDIT: Problem solved, after some attention from Adobe. See the posts below for a full explanation. This code will work for HTTP Authentication headers of arbitrary length.
import mx.utils.Base64Encoder;
private function authAndSend(service:HTTPService):void
{
var encoder:Base64Encoder = new Base64Encoder();
encoder.insertNewLines = false; // see below for why you need to do this
encoder.encode("someusername:somepassword");
service.headers = {Authorization:"Basic " + encoder.toString()};
service.send();
}
Finally received some attention from Adobe and got an answer on this. The problem with long HTTP Authentication headers is that, by default, the Base64Encoder class will inject newline characters every 72 characters. Obviously that causes a chunk of the base-64 encoded string to be interpreted as a new header attribute, which causes the error.
You can fix this by setting (in the above example) encoder.insertNewLines = false; The default setting is true.
I've fixed the above code to work for arbitrarily long Authentication strings.
Ah. The pain, the suffering. The sheer misery.
While you've figured out how to add a header before making your call, the nasty truth is that somewhere deep down in the Flash/browser integration space your headers are being removed again.
From my blogpost last year at verveguy.blogspot.com
So I have unraveled the Truth. (I think)
It's more tortured than one would imagine
1/ All HTTP GET requests are stripped of headers. It's not in the Flex stack so it's probably the underlying Flash player runtime
2/ All HTTP GET requests that have content type other than application/x-www-form-urlencoded are turned into POST requests
3/ All HTTP POST requests that have no actual posted data are turned into GET requests. See 1/ and 2/
4/ All HTTP PUT and HTTP DELETE requests are turned into POST requests. This appears to be a browser limitation that the Flash player is stuck with. (?)
What this boils down to in practical terms is that if you want to pass headers in all requests, you should always use POST and you should find another way to communicate the semantics of the operation you "really wanted". The Rails community have settled on passing ?_method=PUT/DELETE as a work around for the browser problems underlying 4/
Since Flash adds the wonderful header stripping pain on GET, I'm also using ?_method=GET as a workaround for that. However, since this trips up on 3/,
I am passing a dummy object as the encoded POST data. Which means my service needs to ignore dummy posted data on a ?_method=GET request.
Crucial at this point to know about 2/. That wasted a bunch of my time.
I've built all of this handling into a new RESTService class with MXML markup support so it's possible to pretend this doesn't exist on the client side.
Hope this helps someone.
The setCredentials() & setRemoteCredentials() methods are intended for use with Flex/LiveCycle Data Services, so they probably don't apply in your case.
This ought to work for you. I was able to reproduce this behavior on my server, and this fix seems to have done the trick; it still seems a bit odd this isn't more API-user-friendly, considering how common a use case you'd think it were, but nonetheless, I've tested and verified this works, given a valid SSL cert:
private function authAndSend(service:HTTPService):void
{
var encoder:Base64Encoder = new Base64Encoder();
encoder.encode("someusername:somepassword");
service.headers = {Authorization:"Basic " + encoder.toString()};
service.send();
}
Hope it helps! And thanks for posting -- I'm sure I would've run into this one sooner or later myself. ;)
This really has helped me! Thanks!
I use Flex Builder 3
One note: WebService's property headers is read only.
So I tried to use httpHeaders. It works!
var encoder:Base64Encoder = new Base64Encoder();
encoder.insertNewLines = false;
encoder.encode("test:test");
sfWS.httpHeaders = {Authorization:"Basic " + encoder.toString()};
I had the same problem while consuming HTTP Basic Authenticated Webservice. This is my solution; it works fine:
private function authAndSend(service:WebService):void
{
var encoder:Base64Encoder = new Base64Encoder();
encoder.insertNewLines = false;
encoder.encode("user:password");
service.httpHeaders = { Authorization:"Basic " + encoder.ToString() };
service.initialize();
}
usage
authAndSend(WebService( aWebServiceWrapper.serviceControl));
Try using setCredentials rather than setRemoteCredentials and failing that, using Fiddler/Charles to find out what headers are being sent with the request.
Also, just so other people don't spend 10 minutes working out why the correct example doesn't quite work asis, you need to import the mx.utils.Base64Encoder package eg:
import mx.utils.Base64Encoder;
At the beginning or somewhere within the CDATA area. I'm new to flex so this wasn't quite obvious at first.
This is how its done.
import mx.utils.Base64Encoder;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
var _oHttp:HTTPService = new HTTPService;
var sUsername:String = "theusername"
var sPassword:String = "thepassword";
var oEncoder:Base64Encoder = new Base64Encoder();
oEncoder.insertNewLines = false;
oEncoder.encode(sUsername + ":" + sPassword);
_oHttp.method = "POST";
_oHttp.headers = {Authorization:"Basic " + oEncoder.toString()};