0

This is driving me nuts... Based on my research I should be able to pass QueryString parameters directly to a swf object like so:

http://localhost:3000/SomeFlash/bin-debug/myFlash.swf?userId=827419

In the mxml oncreationcomplete method I have tried the following:

// oncreationcomplete method
    var userIdTest1:String = FlexGlobals.topLevelApplication.parameters[0];
    var userIdTest2:String = Application.application.parameters.userId;
    var userIdTest3:String = this.parameters.userId;


    // External Interface
    ExternalInterface.addCallback("OnGameLoad", ClientParams);


// callback method
   protected function ClientParams(userId:String):void
   {
        this.userId = userId;           
   }    

source http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf626ae-7feb.html

I am using Flashbuilder 4.5 with Flex 4.5.1 compiler. I am using a mxml with an html wrapper, but I am trying to pass the parameters via url to the swf directly.

2 Answers 2

2

ExternalInterface is not available if you're launching the swf directly.

Likewise, I suspect that's the reason that the queryString is not available.

Try hitting the hosting HTML page instead. (ie., http://localhost:3000/SomeFlash/bin-debug/myFlash.html?userId=827419)

Sign up to request clarification or add additional context in comments.

2 Comments

Good idea, having a hosted HTML page is always a better idea generally. I can't think of a reason why to call the SWF directly in a browser other than for the sake of fast distribution to friends so they can try your project out.
The swf is used in a 3d application which uses swfs directly, so I can't have an html wrapper
1

After lots of testing and some dumb luck I found that the following will work for getting querystring parameters.

// In the oncreationcomplete method

this.userId = this.parameters.userId;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.