HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Retrieve Username From Ocportal to Flash Game

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#99602 (In Topic #19568)
Avatar

Fan in training

Hi!
I was wondering if there's any flash developers in this forum that has experience with ocportal.
I wanted to try and make a game for my ocportal site, and I'd like to be able to retrieve the logged in user's username in order to collect their score points to write to database.
Is there anyone that knows a simple way of doing this? Maybe a way to read a piece of text from html of the site where the username is displayed?

Regards
Sarah
Back to the top
 
Posted
Rating:
#99605
Avatar

So usually Flash would be inserted in HTML via an <object> tag, and take various <param> attributes, which Flash can read. If you write the HTML into an ocPortal Comcode page, template, or just some field that supports Comcode (e.g. a news article), you can use {$USERNAME*} to put it into a <param> value of your HTML.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#99606
Avatar

Fan in training

Ok thank you so much for your quick response! :)

I will look up on how to do this.

Regards Sarah.
Back to the top
 
Posted
Rating:
#99646
Avatar

Fan in training

Hi again!
So i've been experimenting with it in different ways and looking up tutorials on how to do it. But for some reason it's not working.

As a test, this is what I put in the html:

Code

<object height="418" id="swf" width="478"><param name="movie" value="ASwfUsernameTest.swf" /><param name="FlashVars" value="name2=koala" /><embed height="418" src="my-source-here" width="478"></embed></object>

Then in As3 I put:

Code

var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters.name2;

var textPlace:TextField = new TextField();      
textPlace.border = false;
textPlace.selectable=false;
textPlace.text = paramObj.toString();
textPlace.width=800;
textPlace.height=300;
textPlace.y=5;
textPlace.x=5;

stage.addChild(textPlace);



Doesn't seem to work at all. The swf works correctly tho. If I just put in any other text value in the textplace.text it will display.
Any idea on what I'm doing wrong?

Regards
Sarah
Back to the top
 
Posted
Rating:
#99647
Avatar

Fan in training

Never mind. I got it working! :)
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: