php - Using flashvar inside actionscript

29

I am working on a live streaming media platform and have a Flash interface. I need the instance string to be unique to each user profile it sits on. I have the following in my PHP.

var flashvars = {};
flashvars.instance =  escape('<?php $global $user; $drupaluserid = $user->uid?>');

The AS3 is where the string needs to be set, I have this.

private var INSTANCE:String = "default";
public function setInstanceName(inst:String):void{
        INSTANCE = inst;
    }

Not sure how to proceed before I compile the Flash app to grab the flashvar.

853

Answer

Solution:

In your case you may want to use a Singleton class to be initiated in your main constructor, then Called from anywhere in your code:

https://github.com/mikatalk/AS3-goodies/blob/master/utils/FlashVarsHelper.as

// initialize in your Main.as doc:
FlashVarsHelper.initialize(loaderInfo.parameters.instance);
// then call it from anywhere:
FlashVarsHelper.getValueByName("instance");

Note that this library is not case sensitive to prevent external typo errors.

438

Answer

Solution:

Flash vars come into your Flash movie asloaderInfo.parameters which is an Object. In your case you would have to write

var instance:String = loaderInfo.parameters.instance;

in your Document Class or main class.

More info here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/LoaderInfo.html#parameters

People are also looking for solutions to the problem: php - HTML/CSS: Image Not being displayed

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.