Flex 3 : Easy Deep Linking Question - apache-flex

I'm having a problem with deeplinking on my Flex 3 site. I want people to be able to link to different parts of the site. I also want to be able to type a url into the browser bar and be taken to a particular part of my site. Also, I need the default to open to #view=2.
I'm having problems setting the default #view=2. So, it's supposed to check the browser fragment to see whether its a valid section of the site. If it is then it should call parseUrl() and open that section of the site. So far, so good. The problem is how do I set the default to view=#2, if the loop doesn't find a valid view number?
Here's my code:
private function initBrowserManager(): void {
browserManager = BrowserManager.getInstance();
browserManager.addEventListener(BrowserChangeEvent.BROWSER_URL_CHANGE, parseUrl);
browserManager.init("","My Website");
if(browserManager.fragment != null){
for (var j:uint = 0; j < ComboBoxDP.length; j++){
if(browserManager.fragment == "view="+ComboBoxDP[j].series){
parseUrl();
break;
}
}
}
}
I've tried to add this line: else{browserManager.setFragment("view="+ 2); parseUrl();} everywhere I could think of, but no luck so far. I know that the answer will be really simple. Any suggestions?
Thank you.
-Laxmidi

I'm assuming some of the intent of the code, but I'd use a boolean:
var initialFragmentValid:Boolean = false;
if(browserManager.fragment != null){
for (var j:uint = 0; j < ComboBoxDP.length; j++){
if(browserManager.fragment == "view="+ComboBoxDP[j].series){
initialFragmentValid = true;
break;
}
}
}
if (!initialFragmentValid) {
// set the default
browserManager.setFragment("view=2");
}
// always parse initially because we'll have a fragment regardless
parseUrl();

Related

How to refresh Factbox

I have a form, when i click on my button.It adds to my table A (what my factbox shows)is it possible to refresh the factbox with X++ code? I can't figure out how to refresh my infopart or query which factbox uses.
For an infopart you can call an update of the data source of the infopart's form run:
void clicked()
{
PartList partList;
int i;
FormRun infoPartFormRun;
FormDataSource infoPartDataSource;
super();
partList = new PartList(element);
for (i = 1; i <= partList.partCount(); i++)
{
infoPartFormRun = partList.getPartById(i);
if (infoPartFormRun.name() == identifierStr(MyInfoPart))
{
infoPartDataSource = infoPartFormRun.dataSource();
if (infoPartDataSource)
{
infoPartDataSource.research();
}
}
}
}
I added the check for the infoPartDataSource because I first tested this with a cue group fact box, which does not have a data source (or at least I could not figure out how to get the data source of one of the cues in the cue group and since you asked for an infopart fact box, I did not investigate further).
Update: The issue seems to be popular at the moment, Martin DrĂ¡b also wrote in his blog about it: Refreshing form parts

TypeError: $it0.hasNext is not a function

Running a few canvases which work fine in chrome but fail in the latest version of Mozilla. I know this was an issue a while back and I thought the new processing-1.4.1.js was fixed to accommodate for the for loop failure seen here. Does anyone know if they did or if not, why this is happening and how to fix it?
edit:
Test code that will not work:
void setup() {
String names[] = {"Alexis", "Thomas", "Antoine"};
for(String name : names) {
alert(name); // doesn't on Firefox 17+, bug?
}
}
void draw() {
}
This is a problem with Processing.js and some recent changes in Firefox as discussed here.
You have two options:
Solution 1 is to hack Processing.js file as discussed by alexbbrown in the aforementioned link (a harsh and nasty solution), essentially finding the actual Processing.js file, editing it with your favourite text editor and change lines 291-292 from:
if (obj.iterator instanceof
Function) return obj.iterator();
to:
if (obj.iterator instanceof Function && obj.hasNext instanceof Function)
return obj.iterator();
Solution 2 is to change your code and live without the lovely for-each syntax (a softer, compromising solution), replacing the lines:
for (String name : names) {
alert(name); // doesn't on Firefox 17+, bug?
}
with the common for syntax:
for (int i = 0; i < names.length; i++) {
alert(names[i]);
}
whatever you do, may the for be with you...

Sound editing in flash

Is there any way to make a flash sound editing application with Action Script ?
I'm pretty sure that there is no way around that but i want to make sure . also if not then as a relevant can i use flex to do that . if not then i have to ask what to use to do that . I'm planning to publish that over the web .
thanks in advance . and forgive my ignorance
Yes, you can!
Use flash.media.Sound.extract to get raw data and modify it however you want.
Small example from docs:
function processSound(event:SampleDataEvent):void
{
var bytes:ByteArray = new ByteArray();
sourceSnd.extract(bytes, 4096);
event.data.writeBytes(upOctave(bytes));
}
function upOctave(bytes:ByteArray):ByteArray
{
var returnBytes:ByteArray = new ByteArray();
bytes.position = 0;
while(bytes.bytesAvailable > 0)
{
returnBytes.writeFloat(bytes.readFloat());
returnBytes.writeFloat(bytes.readFloat());
if (bytes.bytesAvailable > 0)
{
bytes.position += 8;
}
}
return returnBytes;
}
Also you may want to use flash.media.SoundTransform if you want some simple transformations.

Asp.Net Change a value from another page

Hi
I have 2 webpage in my asp.net project.
I defined a int value in second page.
i want to change int value from first page. How can I make this?
You can't change the variable directly. But you can use Session to achieve this.
In Page 1
Session["session-name"] = "5";
In Page 2
if (Session["session-name"] != null) // check the session if it is exist
{
int a;
try
{
a = int.Parse(Session["session-name"].ToString());
}
catch
{
a = 0; // you can set null too. Whatever you want
}
}
You likely want to use Session Variables. You can start learning here.

How to automatically refresh a web-page using ASP.NET?

I have an asp.net application that would 'simulate' real-time video. I did that acquiring multiple picture from an mysql database.
The problem is how would it be displayed on the web-page.? I refresh the page 1 second per picture, the result is the pictures are choppy and flickery.
Response.AppendHeader("Refresh", "1")
How can I make the refresh rate of the page 4times per second? or is there any implementation for it to be displayed in a continent way.
I would really appreciate if you will reply. good day (^_^)...
here is the script that i am using to read the images from the database,.
If dr.Read Then
dr.Read()
Response.ContentType = "image/jpeg" 'gets or sets the type of output stream
Response.BinaryWrite(dr.Item("file")) 'writes a stream of binary characters to the
http output stream
Else
Response.Write("There is no current active webccast.")
End If
dr.Close()
create a javascript method to change the image using xmlhttpobject and recursively set a timer
function Timer() {
setTimeout("getImage(['imageContainer1'])", 200);
t = setTimeout("Timer()", 100);
}
function getImage(params) {
var request=getXMLhttpObject();
makeRequest("ajax/ObtainImage.aspx?name='myimage'+param[1]+'.jpg",request, imageResponseHandler(request, params));
}
function getXMLhttpObject() {
return (navigator.appName == "Microsoft Internet Explorer")? new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
}
function makeRequest(url,request, Handler) {
request.open("GET", url, true);
request.onreadystatechange = Handler;
request.send(null);
}
function imageResponseHandler(request,params) {
return function() {
if (request.readyState == 4)
document.getElementById(params[0]).src = request.responseText;
}
}
I would either use some Javascript/Ajax to change the content or the meta-refresh (probally not the best for fast refresh).
Maybe you need to think about loading more than one picture onto the page and using javascript to cycle between them. Rather than refreshing the page you could get the pictures using AJAX.
If you really want to simulate video, you need to be able to display at least 15 pictures each second (15fps). Making that many requests per second isn't a great idea.
If you absolutely must do this, I'd suggest "buffering" the pictures first, before displaying them, and if possible, fetching them in batches:
buffer = [] // cache loaded images
bufferSize = 30 // load 30 images before playing
function loadImage(src) {
var img = new Image()
img.src = src
buffer.push(img)
}
function animate(target) {
if (buffer.length > 0) {
var img = buffer.shift()
document.getElementById(target).src = img.src
}
}
function bufferImages() {
for (var i=0; i<bufferSize; i++) {
loadImage('/ajax/ObtainImage.aspx?name=img')
}
}
setInterval("animate('imgTarget')", 65) // should give us about 15fps
setInterval("bufferImages()", 1000) // every second
Add this to the head of your html document.
Not the most efficient way, but it will work.
<meta http-equiv="refresh" content=".25" />

Resources