..:: MX Studio Fóruns ::..: Sistema de Notícia - ..:: MX Studio Fóruns ::..

Jump to content

Publicidade




ATENÇÃO

Para evitar posts desnecessários e que não influam para o andamento e desenvolvimento do fórum, clique aqui e leia todas as regras.
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Sistema de Notícia Sistema de notícias em AS + PHP + MySQL

#1 User is offline   isapgarcia 

  • Group: Membros
  • Posts: 11
  • Joined: 02-August 06

Posted 02 August 2006 - 11:21 AM

dry.gif gente eu consegui montar um sistema bem legal em AS, catando um pouco dali e um pouco daqui, pesquisando e imendando, de notícias,


porem eu preciso de uma barra de rolagem no lado esquerdo, onde aparecem os títulos das notícias QUE SÃO botões, acho q tem q criar um CLIp q traga esses botões, mas dai se eu faço isso nao funciona mais nada


. e nao sei como criar sad.gif



lá vai o código
==================================================


var my_font:TextFormat = new TextFormat();
my_font.font = "arial";
my_font.color = 0xFFFFFF;
my_font.size = 11;

_root.createTextField("noti",0,477,143,242,250);
noti.wordWrap = true;
noti.multiline = true;
noti.type = 'dynamic';
noti.html = true;
//noti.autoSize = true;


noti.setNewTextFormat(my_font);


meuMenu = new LoadVars();

// criamos a função quando chegarmos no evento on Load


meuMenu.onLoad = function(ok) {

// Se OK, continuar a função ...
if (ok) {

// distancia em pixels de um botão e o outro.
var distancia:Number = 25;
// aqui criamos uma váriavel denominada "Array" que pega os dados da variavel nomes do php.
var meuNome:Array = meuMenu.nomes;
// Cada dado antes e após a virgula, é um botão, então precisamos filtra-lo, para isso usa-se o split();
var meuNome = meuNome.split(",");

// colocando os dados vindos do php em ordem alfabética
//meuNome.sort();
// Declarando a variavel Links, é a mesma coisa dos nomes, só muda as letras.

var meuLink:Array = meuMenu.links;

// Filtrando os campos preenchidos no php

var meuLink = meuLink.split(",");

// colocando os links vindos do php em ordem alfabética
//meuLink.sort();
// Aqui iniciamos o nosso laço até chegar onde queremos.
// Muitas pessoas usam o for mas não sabem direito como ele funciona.
// Explicando ...
// var i=0; Declaramos uma variavel com valor 0 para atribuir ao laço.
// i<meuNome.length -> Quando a variavel i for menor que meuNome.length, ou seja, o tamanho da array meuNome.
// i++ -> adicionar na variavel i sempre + 1 ao valor que esta atribuido no array

for (var i=0; i<meuNome.length; i++) {

// Chamamos a instancia exportada como linkage da biblioteca
// O Que é esse getNextHighestDepth() ??
// Ele é o comando que quando executado envia toda instancia que está no Stage para a camada UP, sempre estará no ponto de cima do stage a instância.

_root.attachMovie("bt","bt"+i,_root.getNextHighestDepth());

// Atribuindo ao campo de texto que está dentro do movie clip os dados.

_root["bt"+i].nome_bt.text = meuNome[i];
// Aqui, criamos uma variavel temporaria para ser executada dentro do onRelease do botão.

eval("_root.bt"+i).id = meuLink[i];

// Evento do botão, para que quando ser clicado, aparecer o link correspondente.


_root["bt"+i].onRelease = function() {

// atribuindo valores do array MeuNome na nossa variavel temporária chama id.

notici = 1;

_root.meuNome = this.id;

// Imprimindo os valores.
//_root.detalhes.text = this.id;

var envia:LoadVars = new LoadVars;

var recebe:LoadVars = new LoadVars;

envia.id_noticia =this.id;

envia.sendAndLoad("http://localhost/coltex/noticia.php",recebe,"POST");

recebe.onLoad = function():Void {

//for (var ia=0; ia<total2; ia++)

//{
//variavel = this.imagem;
//variavel = this['ima'+ia];
if(this.imagem>0) {

variavel = "<img src='noticias/"+this.imagem+".jpg'>";

} else {
delete variavel;
}



//}

_root.noti.htmlText = this.datanot +"<br>"+ this.titulo +"<br><br>";

if(this.imagem>0) {

_root.noti.htmlText += variavel+"<br>";

}
_root.noti.htmlText += this.noticia;

notici==1;

};

};

// Adicionando o evento RollOver no botão acessado.
_root["bt"+i].onRollOver = function() {

// indo para o frame 2 do mc 'over'

this.over.gotoAndPlay(2);
};
// Adicionando o evento RollOut no botão
_root["bt"+i].onRollOut = function() {
// indo para o frame 11 do mc 'over'
this.over.gotoAndPlay(11);
};
// Colocando todos os botões criados na altura de 10 pixels.
_root["bt"+i]._y = 148;
// Colocando todos os botões criados na largura de 10 pixels.
_root["bt"+i]._x = 310;
// Colocando o botão duplicado abaixo, somando com a variavel distancia, lembram dela lá em cima ? ou seja , dist6ancia é igual a 23 pixels, 23 pixels de altura para baixo, aparecerá outro botão, assim, até acabar o laço for.
_root["bt"+i]._y = _root["bt"+i]._y+i*distancia;
}
} else {

// Se (ok) não for carregado é porque, o arquivo não foi carregado com sucesso!

trace("Erro ao carregar o arquivo");
}
if(notici<>1){

notic = new LoadVars();

notic.onLoad = function() {


var total2 = this.total;


_root.noti.htmlText = this.datanot+"<br>"+this.titulo+"<br><br>";

//for (var ia=0; ia<total2; ia++)

//{
if(this.imagem > 0) {

variavel = "<img src='noticias/"+this.imagem+".jpg'>";

}

//variavel = this['ima'+ia];

//trace("<img src='noticias/"+variavel+".jpg'>");

//}

_root.noti.htmlText = this.datanot +"<br>"+ this.titulo +"<br><br>";
if(this.imagem>0) {
_root.noti.htmlText += variavel+"<br>";
}
_root.noti.htmlText += this.noticia;


}

}

notic.load("http://localhost/coltex/noticia.php");

}

// Carregando o arquivo .php;
meuMenu.load("http://localhost/coltex/php.php");



////////// anteriores

_root.anteriores.onRelease = function() {

// atribuindo valores do array MeuNome na nossa variavel temporária chama id.

_root.meuNome = this.id;

// Imprimindo os valores.
//_root.detalhes.text = this.id;

var envia:LoadVars = new LoadVars;

var recebe:LoadVars = new LoadVars;

envia.id_noticia =this.id;

envia.sendAndLoad("http://localhost/coltex/noticia.php",recebe,"POST");
}




CÓDIGO EM PHP
php.php

<?php include("conecta/conn.php");?>

<?php
// desenvolvido por ISABEL

if($numero)
{

$sql="SELECT * FROM noticias ORDER BY id_noticia DESC LIMIT '$inicio','$numero'";
$query=mysql_query($sql);


$limita = "$sql LIMIT $inicio,$pág_views";
$executa = mysql_query($limita);
$linhas = mysql_num_rows($query);

$n = 0;


while($i = mysql_fetch_array($executa)){
$id_noticia .=$i[0].",";
$data1 .= $i[1].",";
}

}
else
{
$sql="SELECT * FROM noticias ORDER BY id_noticia DESC LIMIT 5";
$res=mysql_query($sql);
$total=mysql_num_rows($res);

//n armazena os loops para comparação

$n = 0;


while($i = mysql_fetch_array($res)){
$id_noticia .=$i[0].",";
$data1 .= $i[1].",";

// verifica se coloca a virgula no ultimo loop

if($n != $total -1){
$var_url .= $i[2].",";
} else {
$var_url .= $i[2];
}
$n++;

}
}

$nomes=$var_url;
$links = $id_noticia;
$datanot=$data1;

echo "&nomes=$nomes&links=$links&datanot=$datanot&inicio=$inicio";

//codifica a variavel nome
//print utf8_encode($nomes);

?>


noticia.php

<?php include("conecta/conn.php");?>

<?php

if (!$_POST['id_noticia']){
$sql2="SELECT * FROM noticias order by id_noticia desc";
$res2=mysql_query($sql2);
$row = mysql_fetch_array($res2);
$id_noticia= $row['id_noticia'];


} else {

$sql2="SELECT * FROM noticias where id_noticia = '$id_noticia'";
$res2=mysql_query($sql2);
$row = mysql_fetch_array($res2);

}


$sql_img="SELECT * FROM noticias,imagens WHERE noticias.id_noticia = imagens.id_noticia AND imagens.id_noticia = '$id_noticia'";

$res_img = mysql_query($sql_img);
$total = mysql_num_rows($res_img);

while ($row_img = mysql_fetch_array($res_img)) {


$id_img = $row_img[0];

//$id_img .= $row_img[0].",";


}

//$ima = explode(",",$id_img);


//for($i=0;$i<$total;$i++) {

//$imagens .= "&ima".$i."=".$ima[$i];

//}



$dat = explode("-",$row[1]);
$dia = $dat[2];
$mes =$dat[1];
$ano =$dat[0];


$datanot = $dia."/".$mes."/".$ano;

print "&datanot=".$datanot."&titulo=".$row[2]."&noticia=".$row[3]."&imagem=".$id_img."&total=".$total;


?>


POR FAVOR MEU AJUDEMMM ohmy.gif blink.gif thumbsup.gif

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic



Publicidade




2 User(s) are reading this topic
0 membro(s), 2 visitante(s) e 0 membros anônimo(s)